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:
from I2C_serial import *
from UniBoard2_I2C import *
I2CBUSNR=1
I2CBUSNR=3
LOC_PWR = I2C(LOC_POWER_SUPPLIES[0])
LOC_PWR = I2C(0x53)
LOC_PWR.bus = I2CBUSNR
ret_ack, ret_value = LOC_PWR.read_bytes(0)
if ret_ack < 1:
......@@ -30,13 +30,13 @@ else:
pr_stri = "Found device at address 0x{:02x}".format(LOC_PWR.I2C_Address)
print(pr_stri)
value=[]
ret_ack,vout_mod = LOC_PWR.read_bytes(LP_VOUT_MODE, 1)
ret_ack,ret_value = LOC_PWR.read_bytes(LP_VOUT, 2)
vout = calc_lin_3bytes(ret_value, vout_mod)
print("vout = ", vout)
ret_ack,ret_value = LOC_PWR.read_bytes(LP_IOUT, 2)
iout = calc_lin_2bytes(ret_value)
print("Output Current :",iout)
ret_ack,ret_value = LOC_PWR.read_bytes(LP_temp, 2)
temp = calc_lin_2bytes(ret_value)
print("temperature :",temp)
ret_ack,vout_mod = LOC_PWR.read_bytes(0x00, 1)
# ret_ack,ret_value = LOC_PWR.read_bytes(LP_VOUT, 2)
# vout = calc_lin_3bytes(ret_value, vout_mod)
print("read = ", vout_mod)
# ret_ack,ret_value = LOC_PWR.read_bytes(LP_IOUT, 2)
# iout = calc_lin_2bytes(ret_value)
# print("Output Current :",iout)
# ret_ack,ret_value = LOC_PWR.read_bytes(LP_temp, 2)
# temp = calc_lin_2bytes(ret_value)
# print("temperature :",temp)
......@@ -4,13 +4,11 @@ Read Hardware info form UNB2C
import sys
import time
import os
sys.path.insert(0,'.')
from UniBoard2_I2C import *
if os.name =="posix":
from I2C_serial_pi import *
else:
from I2C_serial import *
I2CBUSNR=1
I2CBUSNR=3
QSFP_PORT=[]
QSFP_PORT.append(0x08)
......@@ -21,23 +19,23 @@ QSFP_PORT.append(0x40)
QSFP_PORT.append(0x80)
def rw_eeprom(value=0xAB):
I2C_eeprom = I2C(0x53)
I2C_eeprom.bus = I2CBUSNR
I2C_eeprom = I2C(0x53, BUSNR=3)
I2C_eeprom.write_bytes(0x00, value)
I2C_eeprom.write_pointer(0x00)
ret_ack, ret_value = I2C_eeprom.read_last_reg(1)
if ret_ack:
I2C_eeprom.read_bytes(0x00,1)
# I2C_eeprom.write_pointer(0x00)
# ret_ack, ret_value = I2C_eeprom.read_last_reg(1)
if 0: #ret_ack:
stri = "EEPROM readback : {0} ".format(ret_value)
print(stri)
else:
print("ACK nok")
def front_led(value=0xFF):
main_switch = I2C(0x71)
main_switch.bus = I2CBUSNR
def front_led(value=0xFF, ADDRESS=0x71):
main_switch = I2C(ADDRESS, BUSNR=I2CBUSNR)
# main_switch.bus = I2CBUSNR
main_switch.write_pointer(0x20) #select LED
front = I2C(0x41)
front.bus = I2CBUSNR
front = I2C(ADDRESS=0x41, BUSNR=I2CBUSNR)
# front.bus = I2CBUSNR
front.write_bytes(0x03, 0)
front.write_bytes(0x01, value)
sleep(0.5)
......@@ -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[2:4],16))
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)
def read_qsfp(node_nr = 0, module=0):
......@@ -111,13 +109,14 @@ def read_qsfp(node_nr = 0, module=0):
if 0:
rw_eeprom(0xCD)
main_switch = I2C(0x71)
main_switch.bus = I2CBUSNR
node_switch = I2C(0x72)
node_switch.bus = I2CBUSNR
main_switch.write_pointer(0x20) #select LED
else:
# main_switch= I2C(0x71)
# main_switch.bus = I2CBUSNR
# node_switch = I2C(0x72)
# node_switch.bus = I2CBUSNR
# main_switch.write_pointer(0x20) #select LED
front_led()
if 1:
if 0:
for node_cnt in range(4):
for module_cnt in range(2):
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