Skip to content
Snippets Groups Projects
Commit 89cb2ca3 authored by Gijs Schoonderbeek's avatar Gijs Schoonderbeek
Browse files

Update for speed testing

parent aa87441a
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,7 @@ import sys
from time import *
DEBUG = False #True
SLOW = False
class I2C:
......@@ -39,7 +40,8 @@ class I2C:
for cnt in range(bytes_to_read):
ret_value += (hex(rd_value[cnt])[2:])
ret_ack = 1
# sleep(0.2)
if SLOW:
sleep(0.2)
except IOError, err:
ret_ack = 0
ret_value = 'ffff'
......@@ -56,7 +58,8 @@ class I2C:
try:
rd_value.append(bus.read_byte(self.I2C_Address))
ret_ack = 1
# sleep(0.2)
if SLOW:
sleep(0.2)
except IOError, err:
ret_ack = 0
rd_value.append(0)
......@@ -71,6 +74,7 @@ class I2C:
try:
bus.write_i2c_block_data(self.I2C_Address, register, [data])
ret_ack = 1
if SLOW:
sleep(0.3)
except IOError, err:
ret_ack = 0
......@@ -84,6 +88,7 @@ class I2C:
try:
ret_value = bus.read_i2c_block_data(self.I2C_Address, register, register)
ret_ack = 1
if SLOW:
sleep(0.3)
except IOError, err:
ret_ack = 0
......
......@@ -29,7 +29,7 @@ else:
I2CBUSNR = 3
DEBUG = False
DEBUG = True #False
class Unb2cClass:
#
......@@ -116,19 +116,30 @@ class Unb2cClass:
pol.read_all()
return True
def read_temp(self):
#
# Function to read all monitoring points of the UniBoard
#
for node in self.nodes:
node.read_temp()
for pol in self.pols:
pol.read_temp()
return True
def print_status(self):
#
# Function to dump monitoring information on the screen
#
for color in list(LED_COLORS.keys()):
print(color)
self.front_led(LED_COLORS[color])
# for color in list(LED_COLORS.keys()):
# print(color)
# self.front_led(LED_COLORS[color])
for node in self.nodes:
node.print_status()
print("Status central UniBoard2 components")
for pol in self.pols:
pol.print_status()
self.wr_rd_eeprom()
# self.wr_rd_eeprom()
return True
......@@ -169,6 +180,17 @@ class NodeClass:
for qsfp in self.qsfp:
qsfp.read_all()
def read_temp(self):
#
# Function to read all monitoring points of one FPGA node
#
self.set_i2c_switches()
for pol in self.pols:
pol.read_temp()
for ddr in self.ddr:
ddr.read_all()
def print_status(self):
#
# Function to dump all monitoring points of one FPGA node on the screen
......@@ -179,8 +201,8 @@ class NodeClass:
pol.print_status()
for ddr in self.ddr:
ddr.print_status()
for qsfp in self.qsfp:
qsfp.print_status()
# for qsfp in self.qsfp:
# qsfp.print_status()
def set_i2c_switches(self):
#
......@@ -280,7 +302,7 @@ class QsfpClass:
#
# Function to dump all monitoring information of a QSFP cage on the screen
#
if self.status:
# if self.status:
stri = "Slot {0} : QSFP Temperature QSFP {1:3.2f} gr. C Voltage {2:3.2f} V".format(self.port, self.temp, self.volt)
print(stri)
......@@ -413,13 +435,18 @@ class PolClass:
if self.status:
if type == "node":
self.set_i2c_switch()
vout = 999
cnt = 0
while (vout > 10) & (cnt < 10):
ret_ack, vout_mod = self.pol_dev.read_bytes(LP_VOUT_MODE, 1)
ret_ack, raw_value = self.pol_dev.read_bytes(LP_VOUT, 2)
vout_mod = int(vout_mod, 16)
ret_value = []
ret_value.append(int(raw_value[:2], 16))
ret_value.append(int(raw_value[2:], 16))
self.vout = calc_lin_3bytes(ret_value, [vout_mod])
vout = calc_lin_3bytes(ret_value, [vout_mod])
cnt += 1
self.vout = vout
else:
self.vout = 999
......@@ -429,11 +456,16 @@ class PolClass:
#
if self.status:
self.set_i2c_switch()
iout = 999
cnt = 0
while (iout > 200) & (cnt < 10):
ret_ack, raw_value = self.pol_dev.read_bytes(LP_IOUT, 2)
ret_value = []
ret_value.append(int(raw_value[:2], 16))
ret_value.append(int(raw_value[2:], 16))
self.iout = calc_lin_2bytes(ret_value)
iout = calc_lin_2bytes(ret_value)
cnt += 1
self.iout = iout
else:
self.iout = 999
......@@ -443,11 +475,17 @@ class PolClass:
#
if self.status:
self.set_i2c_switch()
temp = 999
cnt = 0
while (temp > 160) & (cnt < 25):
ret_ack, raw_value = self.pol_dev.read_bytes(LP_temp, 2)
ret_value = []
ret_value.append(int(raw_value[:2], 16))
ret_value.append(int(raw_value[2:], 16))
self.temp = calc_lin_2bytes(ret_value)
temp = calc_lin_2bytes(ret_value)
cnt += 1
if cnt < 9:
self.temp = temp
else:
self.temp = 999
......@@ -477,8 +515,14 @@ def main():
#
unb = Unb2cClass()
if unb.wr_rd_eeprom(value=0x34):
while True:
print("---------- READ All -----------")
unb.read_all()
unb.print_status()
for cnt in range(25):
print("---------- READ TEMPS ONLY -----------")
unb.read_temp()
unb.print_status()
if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment