-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_communication_counters
executable file
·43 lines (33 loc) · 1.53 KB
/
read_communication_counters
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
#
from petsys import daqd
from time import sleep
import sys
daqd = daqd.Connection()
print("--- DAQ PORTS ---")
for portID in daqd.getActivePorts():
print("DAQ Port %2d: " % portID, "%12d transmitted %12d received (%d errors)" % daqd.getPortCounts(portID))
print("--- CONNECTED UNITSs ---")
for portID, slaveID in daqd.getActiveUnits():
mtx, mrx, mrxBad, slaveOn, stx, srx, srxBad = daqd.getFEBDCount1(portID, slaveID)
unit_variant = daqd.read_config_register(portID, slaveID, 16, 0x0022)
if (daqd.read_config_register(portID, slaveID, 64, 0xFFF8) & 0x1) != 0:
# This unit has the version code
unit_version = "0x%016X" % daqd.read_config_register(portID, slaveID, 64, 0xFFF0)
else:
unit_version = "n/a"
if daqd.read_config_register(portID, slaveID, 1, 0x0000) == 1:
# This is a FEB/D
fem_variant = daqd.read_config_register(portID, slaveID, 16, 0x0002)
print("Unit (%2d, %2d): FEB/D type:%04X fem:%04X ver:%s\n" % (portID, slaveID, unit_variant, fem_variant, unit_version), end=' ')
elif daqd.read_config_register(portID, slaveID, 1, 0x0001) == 1:
print("Unit (%2d, %2d): CLK&TGR type:%04X ver:%s\n" % (portID, slaveID, unit_variant, unit_version), end=' ')
else:
sys.stderr.write("ERROR: UNIT (%2d, %2d) is of unknown type!\n" % (portID, slaveID))
exit(1)
print(" MASTER link %12d transmitted %12d received (%d errors)" % (mtx, mrx, mrxBad))
if slaveOn:
print(" SLAVE link %12d transmitted %12d received (%d errors)" % (stx, srx, srxBad))
else:
print(" SLAVE link off")