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

Update rd_unb2c.py reading first POL working for current and temp.

parent 019e19ff
Branches
No related tags found
1 merge request!2Modified the scripts to run on Raspberry Pi.
...@@ -59,24 +59,44 @@ def front_led(value=0xFF): ...@@ -59,24 +59,44 @@ def front_led(value=0xFF):
sleep(0.2) sleep(0.2)
front.write_bytes(0x01, 0xf) front.write_bytes(0x01, 0xf)
def read_pol(i2c_addr): def read_pol(node_nr, i2c_addr):
main_switch = I2C(0x71)
main_switch.bus = I2CBUSNR
ret_ack = main_switch.write_bytes(0x0, 0x01<<node_nr) #select Node
if ret_ack < 1:
print("Main I2C switch not found")
else:
node_switch = I2C(0x72)
node_switch.bus = I2CBUSNR
ret_ack = node_switch.write_bytes(0x0, 0x20) #select DDR4
if ret_ack < 1:
print("Node I2C switch not found")
else:
LOC_PWR = I2C(i2c_addr) LOC_PWR = I2C(i2c_addr)
LOC_PWR.bus = I2CBUSNR LOC_PWR.bus = I2CBUSNR
ret_ack, ret_value = LOC_PWR.read_bytes(0) ret_ack, ret_value = LOC_PWR.read_bytes(0)
if ret_ack < 1: if ret_ack < 1:
print("no device found") print("no device found")
else: else:
pr_stri = "Found device at address 0x{:02x}".format(LOC_PWR.I2C_Address) # pr_stri = "Found device at address 0x{:02x}".format(LOC_PWR.I2C_Address)
print(pr_stri) # print(pr_stri)
ret_ack,ret_value = LOC_PWR.read_bytes(LP_VOUT, 2) ret_ack, vout_mod = LOC_PWR.read_bytes(LP_VOUT, 2)
vout = calc_lin_3bytes(ret_value, vout_mod) # vout_mod = int(vout_mod,16)
print("read = ", vout_mod) # vout = calc_lin_3bytes(ret_value, vout_mod)
ret_ack,ret_value = LOC_PWR.read_bytes(LP_IOUT, 2) ret_ack,raw_value = LOC_PWR.read_bytes(LP_IOUT, 2)
ret_value=[]
ret_value.append(int(raw_value[:2],16))
ret_value.append(int(raw_value[2:],16))
iout = calc_lin_2bytes(ret_value) iout = calc_lin_2bytes(ret_value)
print("Output Current :",iout) stri="Output Current :{0:2.2f} A".format(iout)
ret_ack,ret_value = LOC_PWR.read_bytes(LP_temp, 2) print(stri)
ret_ack,raw_value = LOC_PWR.read_bytes(LP_temp, 2)
ret_value=[]
ret_value.append(int(raw_value[:2],16))
ret_value.append(int(raw_value[2:],16))
temp = calc_lin_2bytes(ret_value) temp = calc_lin_2bytes(ret_value)
print("temperature :",temp) stri="temperature :{0:2.2f} Deg C".format(temp)
print(stri)
def read_ddr(node_nr = 0, module=0): def read_ddr(node_nr = 0, module=0):
main_switch = I2C(0x71) main_switch = I2C(0x71)
...@@ -140,10 +160,9 @@ def read_qsfp(node_nr = 0, module=0): ...@@ -140,10 +160,9 @@ def read_qsfp(node_nr = 0, module=0):
stri = "Voltage QSFP in slot {0} node {1} is {2:3.2f} V".format(module, node_nr, Power_in_mod) stri = "Voltage QSFP in slot {0} node {1} is {2:3.2f} V".format(module, node_nr, Power_in_mod)
print(stri) print(stri)
if 0: if 1:
rw_eeprom(0xCD) rw_eeprom(0xCD)
front_led() front_led()
else:
for node_cnt in range(4): for node_cnt in range(4):
for module_cnt in range(2): for module_cnt in range(2):
read_ddr(node_nr=node_cnt,module=module_cnt) read_ddr(node_nr=node_cnt,module=module_cnt)
...@@ -151,4 +170,4 @@ else: ...@@ -151,4 +170,4 @@ else:
for qsfp_cnt in range(6): for qsfp_cnt in range(6):
read_qsfp(node_nr = node_cnt, module=qsfp_cnt) read_qsfp(node_nr = node_cnt, module=qsfp_cnt)
for node_cnt in range(4): for node_cnt in range(4):
read_pol(LOC_POWER_CORE) read_pol(node_cnt, LOC_POWER_CORE)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment