Commit e6fdf5a1 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

Implemented new pulsetest-specific scripts

Two scripts were implemented. The first reads out the channel and the second
clears them.

Apart from that, a small change was added to pulsetest, which now displays a
correct message when the board ID is not the ASCII for "TBLO".
parent 4b52c802
#!/usr/bin/python
import sys
sys.path.append("../ei2c")
from ei2c import *
import ei2cdefine
from pulsetest import *
import binascii
if __name__ == "__main__":
# Get the IP, user and password for the ELMA crate from ei2cdefine.py
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
testelma = EI2C(ip, user, pwd)
testelma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
# Get board ID and gateware version, fail if incorrect
bloid = testelma.read(slot, 0x00)
fwvers = testelma.read(slot, 0x04) & 0xFF
if ( bloid != 0x54424c4f ):
print("Wrong board ID (%s)" % binascii.unhexlify("%s" % \
"{0:x}".format(bloid)))
sys.exit(1)
if ( fwvers != 0xff ):
print("Wrong version number (0x%02x)" % fwvers)
sys.exit(1)
# clear
testelma.write(slot, CHENREG, 0x00);
testelma.write(slot, CNTRST, 1);
testelma.write(slot, CNTRST, 0);
# Get channel counters
i = testelma.read(slot, C1IREG)
o = testelma.read(slot, C1OREG)
print("CH1 / i: %d / o: %d" % (i, o))
i = testelma.read(slot, C2IREG)
o = testelma.read(slot, C2OREG)
print("CH2 / i: %d / o: %d" % (i, o))
i = testelma.read(slot, C3IREG)
o = testelma.read(slot, C3OREG)
print("CH3 / i: %d / o: %d" % (i, o))
i = testelma.read(slot, C4IREG)
o = testelma.read(slot, C4OREG)
print("CH4 / i: %d / o: %d" % (i, o))
i = testelma.read(slot, C5IREG)
o = testelma.read(slot, C5OREG)
print("CH5 / i: %d / o: %d" % (i, o))
i = testelma.read(slot, C6IREG)
o = testelma.read(slot, C6OREG)
print("CH6 / i: %d / o: %d" % (i, o))
......@@ -38,6 +38,7 @@ import time
sys.path.append("../ei2c")
from ei2c import *
import ei2cdefine
import binascii
IDREG = 0x00
FWVREG = 0x04
......@@ -102,13 +103,19 @@ if __name__ == "__main__":
except:
print("Unexpected error: ", sys.exc_info()[0])
# Get board ID and gateware version, fail if incorrect
bloid = testelma.read(slot, 0x00)
fwvers = testelma.read(slot, 0x04) & 0xFF
if ( bloid != 0x54424c4f ) or ( fwvers != 0xff ):
if ( bloid != 0x54424c4f ):
print("Wrong board ID (%s)" % binascii.unhexlify("%s" % \
"{0:x}".format(bloid)))
sys.exit(1)
if ( fwvers != 0xff ):
print("Wrong version number (0x%02x)" % fwvers)
sys.exit(1)
# Reset chan. counters
testelma.write(slot, CHENREG, 0x00);
testelma.write(slot, CNTRST, 1);
testelma.write(slot, CNTRST, 0);
......
#!/usr/bin/python
import sys
sys.path.append("../ei2c")
from ei2c import *
import ei2cdefine
from pulsetest import *
import binascii
if __name__ == "__main__":
# Get the IP, user and password for the ELMA crate from ei2cdefine.py
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
testelma = EI2C(ip, user, pwd)
testelma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
# Get board ID and gateware version, fail if incorrect
bloid = testelma.read(slot, 0x00)
fwvers = testelma.read(slot, 0x04) & 0xFF
if ( bloid != 0x54424c4f ):
print("Wrong board ID (%s)" % binascii.unhexlify("%s" % \
"{0:x}".format(bloid)))
sys.exit(1)
if ( fwvers != 0xff ):
print("Wrong version number (0x%02x)" % fwvers)
sys.exit(1)
# Get channel counters
i = testelma.read(slot, C1IREG)
o = testelma.read(slot, C1OREG)
print("CH1 / i: %d / o: %d" % (i, o))
i = testelma.read(slot, C2IREG)
o = testelma.read(slot, C2OREG)
print("CH2 / i: %d / o: %d" % (i, o))
i = testelma.read(slot, C3IREG)
o = testelma.read(slot, C3OREG)
print("CH3 / i: %d / o: %d" % (i, o))
i = testelma.read(slot, C4IREG)
o = testelma.read(slot, C4OREG)
print("CH4 / i: %d / o: %d" % (i, o))
i = testelma.read(slot, C5IREG)
o = testelma.read(slot, C5OREG)
print("CH5 / i: %d / o: %d" % (i, o))
i = testelma.read(slot, C6IREG)
o = testelma.read(slot, C6OREG)
print("CH6 / i: %d / o: %d" % (i, o))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment