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

Update script not working yet

parent d2c8d301
Branches
No related tags found
1 merge request!2Modified the scripts to run on Raspberry Pi.
...@@ -18,10 +18,10 @@ else: ...@@ -18,10 +18,10 @@ else:
from I2C_serial import * from I2C_serial import *
from UniBoard2_I2C import * from UniBoard2_I2C import *
I2CBUSNR=1 I2CBUSNR=3
LOC_PWR = I2C(LOC_POWER_SUPPLIES[0]) LOC_PWR = I2C(0x53)
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:
...@@ -30,13 +30,13 @@ else: ...@@ -30,13 +30,13 @@ 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)
value=[] value=[]
ret_ack,vout_mod = LOC_PWR.read_bytes(LP_VOUT_MODE, 1) ret_ack,vout_mod = LOC_PWR.read_bytes(0x00, 1)
ret_ack,ret_value = LOC_PWR.read_bytes(LP_VOUT, 2) # ret_ack,ret_value = LOC_PWR.read_bytes(LP_VOUT, 2)
vout = calc_lin_3bytes(ret_value, vout_mod) # vout = calc_lin_3bytes(ret_value, vout_mod)
print("vout = ", vout) print("read = ", vout_mod)
ret_ack,ret_value = LOC_PWR.read_bytes(LP_IOUT, 2) # ret_ack,ret_value = LOC_PWR.read_bytes(LP_IOUT, 2)
iout = calc_lin_2bytes(ret_value) # iout = calc_lin_2bytes(ret_value)
print("Output Current :",iout) # print("Output Current :",iout)
ret_ack,ret_value = LOC_PWR.read_bytes(LP_temp, 2) # ret_ack,ret_value = LOC_PWR.read_bytes(LP_temp, 2)
temp = calc_lin_2bytes(ret_value) # temp = calc_lin_2bytes(ret_value)
print("temperature :",temp) # print("temperature :",temp)
...@@ -4,13 +4,11 @@ Read Hardware info form UNB2C ...@@ -4,13 +4,11 @@ Read Hardware info form UNB2C
import sys import sys
import time import time
import os
sys.path.insert(0,'.') sys.path.insert(0,'.')
from UniBoard2_I2C import * from UniBoard2_I2C import *
if os.name =="posix":
from I2C_serial_pi import * from I2C_serial_pi import *
else: I2CBUSNR=3
from I2C_serial import *
I2CBUSNR=1
QSFP_PORT=[] QSFP_PORT=[]
QSFP_PORT.append(0x08) QSFP_PORT.append(0x08)
...@@ -21,23 +19,23 @@ QSFP_PORT.append(0x40) ...@@ -21,23 +19,23 @@ QSFP_PORT.append(0x40)
QSFP_PORT.append(0x80) QSFP_PORT.append(0x80)
def rw_eeprom(value=0xAB): def rw_eeprom(value=0xAB):
I2C_eeprom = I2C(0x53) I2C_eeprom = I2C(0x53, BUSNR=3)
I2C_eeprom.bus = I2CBUSNR
I2C_eeprom.write_bytes(0x00, value) I2C_eeprom.write_bytes(0x00, value)
I2C_eeprom.write_pointer(0x00) I2C_eeprom.read_bytes(0x00,1)
ret_ack, ret_value = I2C_eeprom.read_last_reg(1) # I2C_eeprom.write_pointer(0x00)
if ret_ack: # ret_ack, ret_value = I2C_eeprom.read_last_reg(1)
if 0: #ret_ack:
stri = "EEPROM readback : {0} ".format(ret_value) stri = "EEPROM readback : {0} ".format(ret_value)
print(stri) print(stri)
else: else:
print("ACK nok") print("ACK nok")
def front_led(value=0xFF): def front_led(value=0xFF, ADDRESS=0x71):
main_switch = I2C(0x71) main_switch = I2C(ADDRESS, BUSNR=I2CBUSNR)
main_switch.bus = I2CBUSNR # main_switch.bus = I2CBUSNR
main_switch.write_pointer(0x20) #select LED main_switch.write_pointer(0x20) #select LED
front = I2C(0x41) front = I2C(ADDRESS=0x41, BUSNR=I2CBUSNR)
front.bus = I2CBUSNR # front.bus = I2CBUSNR
front.write_bytes(0x03, 0) front.write_bytes(0x03, 0)
front.write_bytes(0x01, value) front.write_bytes(0x01, value)
sleep(0.5) sleep(0.5)
...@@ -83,7 +81,7 @@ def read_ddr(node_nr = 0, module=0): ...@@ -83,7 +81,7 @@ def read_ddr(node_nr = 0, module=0):
ret_value.append(int(raw_ret[0:2],16)) ret_value.append(int(raw_ret[0:2],16))
ret_value.append(int(raw_ret[2:4],16)) ret_value.append(int(raw_ret[2:4],16))
temp = (((ret_value[0] & 0x1F) * 0x100) + (ret_value[1] & 0xFC)) * 0.0625 temp = (((ret_value[0] & 0x1F) * 0x100) + (ret_value[1] & 0xFC)) * 0.0625
stri = "Temperature DDR4 in slot {0} node {1} is {2:3.2f} °C".format(module, node_nr, temp) stri = "Temperature DDR4 in slot {0} node {1} is {2:3.2f} C".format(module, node_nr, temp)
print(stri) print(stri)
def read_qsfp(node_nr = 0, module=0): def read_qsfp(node_nr = 0, module=0):
...@@ -111,13 +109,14 @@ def read_qsfp(node_nr = 0, module=0): ...@@ -111,13 +109,14 @@ def read_qsfp(node_nr = 0, module=0):
if 0: if 0:
rw_eeprom(0xCD) rw_eeprom(0xCD)
main_switch = I2C(0x71) else:
main_switch.bus = I2CBUSNR # main_switch= I2C(0x71)
node_switch = I2C(0x72) # main_switch.bus = I2CBUSNR
node_switch.bus = I2CBUSNR # node_switch = I2C(0x72)
main_switch.write_pointer(0x20) #select LED # node_switch.bus = I2CBUSNR
# main_switch.write_pointer(0x20) #select LED
front_led() front_led()
if 1: if 0:
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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment