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

Third step in classification

parent c980ab71
No related branches found
No related tags found
1 merge request!2Modified the scripts to run on Raspberry Pi.
......@@ -25,6 +25,11 @@ CTR_POWER_S_1V2 = 0x0F
CTR_POWER_CLK = 0x0D
CTR_POWER_QSFP_01 = 0x01
CTR_POWER_QSFP_23 = 0x02
CTR_POLS = {"CTR_POWER_S_1V0" : 0x0E,
"CTR_POWER_S_1V2" : 0x0F,
"CTR_POWER_CLK" : 0x0D,
"CTR_POWER_QSFP_01" : 0x01,
"CTR_POWER_QSFP_23" : 0x02}
LP_VOUT_MODE = 0x20
LP_VOUT = 0x8B #
......
......@@ -15,6 +15,72 @@ else:
from UniBoard2_I2C import *
I2CBUSNR=3
class c_unb2c:
def __init(self):
self.status=False
self.nodes=[]
self.pols=[]
for node_cnt in range(4):
self.nodes.append(c_node(node_cnt))
for pol in list(CTR_POLS.keys()):
self.pols.append(c_pol(pol))
self.dev_i2c_eeprom = I2C(EEPROM)
self.dev_i2c_eeprom = I2CBUSNR
def write_eeprom(self, data=0x01):
ret_ack, ret_value = self.dev_i2c_eeprom.read_bytes(0)
if ret_ack < 1:
print("no device found")
else:
self.dev_i2c_eeprom.write_bytes(0x00, data)
def read_eeprom(self, data):
ret_ack, ret_value = self.dev_i2c_eeprom.read_bytes(0)
if ret_ack < 1:
print("no device found")
else:
self.dev_i2c_eeprom.write_bytes(0x00, value)
ret_ack, ret_value = I2C_eeprom.read_bytes(0x00, 1)
return ret_value
def wr_rd_eeprom(self):
self.write_eeprom(0x12)
ret_value = self.read_eeprom()
stri = "Wrote to EEPROM: 0x{0:X}, Read from EEPROM: 0x{1} ".format(value, ret_value)
print(stri)
def front_led(collor):
main_switch = I2C(MAIN_I2C_SWITCH)
main_switch.bus = I2CBUSNR
ret_ack = main_switch.write_bytes(0x20,0x20) #select LED
if ret_ack < 1:
print("Main I2C switch not found")
else:
front = I2C(LED_DRIVER)
front.bus = I2CBUSNR
ret_ack = front.write_bytes(0x03, 0)
if ret_ack < 1:
print("Front LED driver not found")
else:
front.write_bytes(0x01, collor)
def read_all(self):
for node in self.nodes:
node.read_all()
for pol in self.nodes:
pol.read_all()
def print_status(self):
for color in list(LED_COLORS.keys()):
print(color)
self.front_led(LED_COLORS[color])
for node in self.nodes:
node.print_status()
for pol in self.nodes:
pol.print_status()
self.wr_rd_eeprom()
class c_node:
def __init__(self, number):
self.node_number = number
......@@ -39,6 +105,8 @@ class c_node:
qsfp.read_all()
def print_status(self):
stri = "Status of Node {0}".format(self.node_number)
print(stri)
for pol in self.pols:
pol.print_status()
for ddr in self.ddr:
......@@ -98,8 +166,8 @@ class c_qsfp:
self.select_qsfp()
ret_ack, raw_ret = self.qsfp_cage.read_bytes(QSFP_VOLT, 2)
if (ret_ack < 1) | (raw_ret[:2]=='ff') :
stri = "No QSFP found in port {0}".format(self.port)
print(stri)
# stri = "No QSFP found in port {0}".format(self.port)
# print(stri)
self.status=False
else:
ret_value=[]
......@@ -176,8 +244,8 @@ class c_pol:
sleep(0.1)
ret_ack, ret_value = self.pol_dev.read_bytes(0)
if ret_ack < 1:
stri = " Device {0} at address 0x{1:X} not found".format(self.name, LOC_POLS[self.name])
print(stri)
# stri = " Device {0} at address 0x{1:X} not found".format(self.name, LOC_POLS[self.name])
# print(stri)
self.status=False
else:
self.status=True
......@@ -414,22 +482,22 @@ if 0:
read_pol(node_cnt, LOC_POWER_CORE)
# read_pol(-1,0x01)
main_switch = I2C(MAIN_I2C_SWITCH)
main_switch.bus = I2CBUSNR
ret_ack = main_switch.write_bytes(0x0, 0x01) #select Node
if ret_ack < 1:
print("Main I2C switch not found")
else:
node_switch = I2C(NODE_I2C_SWITCH)
node_switch.bus = I2CBUSNR
ret_ack = node_switch.write_bytes(0x0, 0x20) #select DDR4
if ret_ack < 1:
print("Node I2C switch not found")
#main_switch = I2C(MAIN_I2C_SWITCH)
#main_switch.bus = I2CBUSNR
#ret_ack = main_switch.write_bytes(0x0, 0x01) #select Node
#if ret_ack < 1:
# print("Main I2C switch not found")
#else:
# node_switch = I2C(NODE_I2C_SWITCH)
# node_switch.bus = I2CBUSNR
# ret_ack = node_switch.write_bytes(0x0, 0x20) #select DDR4
# if ret_ack < 1:
# print("Node I2C switch not found")
for cnt in range(2):
node = c_node(cnt)
node.read_all()
node.print_status()
#for pol in list(LOC_POLS.keys()):
# polletje = c_pol(pol)
# polletje.print_status()
#for cnt in range(2):
# node = c_node(cnt)
# node.read_all()
# node.print_status()
unb = c_unb2c
unb.read_all()
unb.print_status()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment