Commit 17a7bc21 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

software: Update timetag scripts to accomodate for ring buffer

Signed-off-by: Theodor-Adrian Stana's avatarTheodor Stana <t.stana@cern.ch>
parent 49b31e23
......@@ -52,7 +52,24 @@ if __name__ == "__main__":
chcnt = [0, 0, 0, 0, 0, 0]
while not empty:
# Get channel mask from meta register and convert it to channel number
# Read cycles and seconds counters
cyc = testelma.read(slot, 0x30)
sl = testelma.read(slot, 0x34)
sh = testelma.read(slot, 0x38)
# The seconds counter indicates actual seconds; the cycles counter
# indicates 8-ns cycles, so convert to ns
s = (sh << 32) | sl
ns = cyc*8
# Get contents of TBCSR
csr = testelma.read(slot, 0x3c)
empty = csr & (1 << 17)
if (empty):
break
used = csr & 0x7f
# Get channel mask from meta register
ch = testelma.read(slot, 0x2c) & 0x3f
# Increment channel counters if channel bit is set in FIFO
......@@ -77,20 +94,7 @@ if __name__ == "__main__":
#ch = 1 + int(math.log(ch)/math.log(2))
# Read cycles and seconds counters
cyc = testelma.read(slot, 0x30)
sl = testelma.read(slot, 0x34)
sh = testelma.read(slot, 0x38)
# The seconds counter indicates actual seconds; the cycles counter
# indicates 8-ns cycles, so convert to ns
s = (sh << 32) | sl
ns = cyc*8
# And print
csr = testelma.read(slot, 0x3c)
empty = csr & (1 << 17)
used = csr & 0x7f
sample = "(%3d) %s : %d.%09d sec" % (used, "{0:#08b}".format(ch)[2:], s, ns)
if 'f' in locals():
f.write(sample + '\n');
......
......@@ -18,7 +18,7 @@ if __name__ == "__main__":
for l in f:
t = l.split()[3]
ch = l.split()[1][2:]
ch = l.split()[1]
if t == ':':
t = l.split()[4]
ch = l.split()[2]
......
import sys
sys.path.append("../../ei2c")
import time
from ei2c import *
import ei2cdefine
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])
tail = testelma.read(slot, 0x24)
taih = testelma.read(slot, 0x28)
print("TAI counter value: %d" % ((taih << 32) | tail))
testelma.close()
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