Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python_test_scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
python_test_scripts
Commits
8bdc20da
Commit
8bdc20da
authored
4 years ago
by
Gijs Schoonderbeek
Browse files
Options
Downloads
Patches
Plain Diff
rb_unb2c.py tested on the pi
parent
0c47fba0
No related branches found
No related tags found
1 merge request
!2
Modified the scripts to run on Raspberry Pi.
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
I2C_serial_pi.py
+6
-4
6 additions, 4 deletions
I2C_serial_pi.py
rd_unb2c.py
+54
-43
54 additions, 43 deletions
rd_unb2c.py
with
60 additions
and
47 deletions
I2C_serial_pi.py
+
6
−
4
View file @
8bdc20da
...
...
@@ -22,7 +22,7 @@ import smbus
import
sys
from
time
import
*
DEBUG
=
True
DEBUG
=
False
#
True
class
I2C
:
...
...
@@ -39,6 +39,7 @@ class I2C:
for
cnt
in
range
(
bytes_to_read
):
ret_value
+=
(
hex
(
rd_value
[
cnt
])[
2
:])
ret_ack
=
1
# sleep(0.2)
except
IOError
,
err
:
ret_ack
=
0
ret_value
=
0
...
...
@@ -54,6 +55,7 @@ class I2C:
try
:
ret_value
.
append
(
bus
.
read_byte
(
self
.
I2C_Address
))
ret_ack
=
1
# sleep(0.2)
except
IOError
,
err
:
ret_ack
=
0
ret_value
=
0
...
...
@@ -66,7 +68,7 @@ class I2C:
try
:
bus
.
write_i2c_block_data
(
self
.
I2C_Address
,
register
,
[
data
])
ret_ack
=
1
sleep
(
0.
2
)
sleep
(
0.
3
)
except
IOError
,
err
:
ret_ack
=
0
ret_value
=
0
...
...
@@ -77,9 +79,9 @@ class I2C:
def
write_pointer
(
self
,
register
):
bus
=
smbus
.
SMBus
(
self
.
bus_nr
)
try
:
ret_value
=
bus
.
read_i2c_block_data
(
self
.
I2C_Address
,
register
,
1
)
ret_value
=
bus
.
read_i2c_block_data
(
self
.
I2C_Address
,
register
,
register
)
ret_ack
=
1
sleep
(
0.
2
)
sleep
(
0.
3
)
except
IOError
,
err
:
ret_ack
=
0
ret_value
=
0
...
...
This diff is collapsed.
Click to expand it.
rd_unb2c.py
+
54
−
43
View file @
8bdc20da
...
...
@@ -34,7 +34,7 @@ def rw_eeprom(value=0xAB):
print
(
pr_stri
)
I2C_eeprom
.
write_bytes
(
0x00
,
value
)
ret_ack
,
ret_value
=
I2C_eeprom
.
read_bytes
(
0x00
,
1
)
stri
=
"
Wrote to EEPROM:
{
0}, Read from EEPROM: {1}
"
.
format
(
value
,
ret_value
)
stri
=
"
Wrote to EEPROM: 0
x{0:X
}, Read from EEPROM:
0x
{1}
"
.
format
(
value
,
ret_value
)
print
(
stri
)
def
front_led
(
value
=
0xFF
):
...
...
@@ -60,18 +60,28 @@ def front_led(value=0xFF):
front
.
write_bytes
(
0x01
,
0xf
)
def
read_pol
(
node_nr
,
i2c_addr
):
if
node_nr
>=
0
:
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
"
)
return
False
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
"
)
return
False
else
:
print
(
"
Central POL
"
)
main_switch
=
I2C
(
0x71
)
main_switch
.
bus
=
I2CBUSNR
ret_ack
=
main_switch
.
write_bytes
(
0x0
,
0x10
)
#select Pol
if
ret_ack
<
1
:
print
(
"
Main I2C switch not found
"
)
return
False
LOC_PWR
=
I2C
(
i2c_addr
)
LOC_PWR
.
bus
=
I2CBUSNR
ret_ack
,
ret_value
=
LOC_PWR
.
read_bytes
(
0
)
...
...
@@ -81,28 +91,27 @@ def read_pol(node_nr, i2c_addr):
# pr_stri = "Found device at address 0x{:02x}".format(LOC_PWR.I2C_Address)
# print(pr_stri)
ret_ack
,
vout_mod
=
LOC_PWR
.
read_bytes
(
LP_VOUT_MODE
,
1
)
ret_ack
,
r
et
_value
=
LOC_PWR
.
read_bytes
(
LP_VOUT
,
2
)
ret_ack
,
r
aw
_value
=
LOC_PWR
.
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
))
vout
=
calc_lin_3bytes
(
ret_value
,
vout_mod
)
stri
=
"
Output Current :{0:2.2f} A
"
.
format
(
iout
)
# print(stri)
vout
=
calc_lin_3bytes
(
ret_value
,
[
vout_mod
])
stri
=
"
Output voltage :{0: <5.2f} V
"
.
format
(
vout
)
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
)
stri
+=
"
Output Current :{0:2.2f} A
"
.
format
(
iout
)
# print(stri)
stri
+=
"
Output Current :{0: <5.2f} A
"
.
format
(
iout
)
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
)
stri
=
+
"
temperature :{0:
2
.2f} Deg C
"
.
format
(
temp
)
stri
+
=
"
temperature :{0:
<5
.2f} Deg C
"
.
format
(
temp
)
print
(
stri
)
return
True
def
read_ddr
(
node_nr
=
0
,
module
=
0
):
main_switch
=
I2C
(
0x71
)
...
...
@@ -166,7 +175,7 @@ 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
)
print
(
stri
)
if
1
:
if
0
:
rw_eeprom
(
0xCD
)
front_led
()
for
node_cnt
in
range
(
4
):
...
...
@@ -175,5 +184,7 @@ if 1:
for
node_cnt
in
range
(
4
):
for
qsfp_cnt
in
range
(
6
):
read_qsfp
(
node_nr
=
node_cnt
,
module
=
qsfp_cnt
)
else
:
for
node_cnt
in
range
(
4
):
read_pol
(
node_cnt
,
LOC_POWER_CORE
)
read_pol
(
-
1
,
0x01
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment