Skip to content
GitLab
Explore
Sign in
Register
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
11cdcf77
Commit
11cdcf77
authored
2 years ago
by
Gijs Schoonderbeek
Browse files
Options
Downloads
Patches
Plain Diff
Added I2C-switch check
parent
d4f5d8e5
No related branches found
No related tags found
1 merge request
!3
Apsct production
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
apsct_lib.py
+42
-1
42 additions, 1 deletion
apsct_lib.py
with
42 additions
and
1 deletion
apsct_lib.py
+
42
−
1
View file @
11cdcf77
...
...
@@ -18,6 +18,7 @@ import sys
import
APSCT_I2C
import
time
import
RPi.GPIO
as
gpio
import
random
sys
.
path
.
insert
(
0
,
'
.
'
)
import
os
if
os
.
name
==
"
posix
"
:
...
...
@@ -41,6 +42,9 @@ class ApsctClass:
self
.
pll_160
=
PllClass
(
"
160MHz
"
)
self
.
sensors
=
ApsctSensors
()
self
.
pps
=
PpsClass
()
self
.
i2cswitch
=
[]
for
addr
in
APSCT_I2C
.
i2c_switch_addr
:
self
.
i2cswitch
.
append
(
I2cSwitch
(
address
=
addr
))
def
read_IO_expanderis
(
self
):
#
...
...
@@ -103,6 +107,8 @@ class ApsctClass:
#
result
=
self
.
sensors
.
check_values
()
result
=
result
&
self
.
pps
.
check_timing
()
for
i2c_switch
in
self
.
i2cswitch
:
result
=
result
&
i2c_switch
.
check_switch
(
data
=
random
.
randint
(
0
,
2
**
8
))
if
self
.
frequency
==
"
200MHz
"
:
self
.
pll_200
.
read_lock
()
lock
=
self
.
pll_200
.
lock
...
...
@@ -358,6 +364,8 @@ class ApsctSensors:
self
.
power_supplies
=
list
(
APSCT_I2C
.
PWR_LOCATIONS
.
keys
())
self
.
voltages
=
{}
self
.
temperature
=
9999
self
.
dev_i2c_sensor
.
write_bytes
(
0xB0
,
0xB8
)
def
apsct_sensors
(
self
):
for
sens_line
in
range
(
7
):
...
...
@@ -367,6 +375,8 @@ class ApsctSensors:
def
read_all_voltages
(
self
):
for
pwr
in
self
.
power_supplies
:
self
.
voltages
[
pwr
]
=
self
.
read_voltage
(
APSCT_I2C
.
PWR_LOCATIONS
[
pwr
])
if
self
.
voltages
[
pwr
]
<
3
:
self
.
voltages
[
pwr
]
=
self
.
read_voltage
(
APSCT_I2C
.
PWR_LOCATIONS
[
pwr
])
return
True
def
check_values
(
self
):
...
...
@@ -384,6 +394,8 @@ class ApsctSensors:
if
not
(
0.9
*
expected
<
self
.
voltages
[
pwr
]
<
1.1
*
expected
):
result
=
False
print
(
f
"
Error:
{
pwr
:
<
9
}
expected:
{
expected
}
V read:
{
self
.
voltages
[
pwr
]
:
4.2
f
}
V
"
)
else
:
print
(
f
"
OK :
{
pwr
:
<
9
}
expected:
{
expected
}
V read:
{
self
.
voltages
[
pwr
]
:
4.2
f
}
V
"
)
if
not
(
15
<
self
.
temperature
<
50
):
result
=
False
print
(
f
"
Error temperature read
{
self
.
temperature
:
4.2
f
}
°C
"
)
...
...
@@ -405,7 +417,7 @@ class ApsctSensors:
print
(
stri
)
sleep
(
0.2
)
self
.
dev_i2c_sensor
.
write_bytes
(
channel_select_word
,
0xB8
)
sleep
(
0.
5
)
sleep
(
0.
2
)
ret_ack
,
ret_value
=
self
.
dev_i2c_sensor
.
read_last_reg
(
3
)
if
DEBUG
:
stri
=
"
Return value input 0 : 0x{0}
"
.
format
(
ret_value
)
...
...
@@ -485,3 +497,32 @@ class PpsClass:
print
(
f
"
, timing is OK:
{
timepps
:
4.2
f
}
s
"
)
self
.
timing
=
True
return
self
.
timing
class
I2cSwitch
:
#
# Class to check a I2C-switch
#
def
__init__
(
self
,
address
=
0x70
):
#
# Whats needed to measure the toggle on GPIO24
#
self
.
address
=
address
self
.
dev_i2c_switch
=
I2C
(
address
)
self
.
dev_i2c_switch
.
bus_nr
=
1
def
check_switch
(
self
,
data
=
0xa5
):
print
(
f
"
Check I2C switch at 0x
{
self
.
address
:
x
}
"
,
end
=
'
'
)
ret_ack
,
ret_value
=
self
.
dev_i2c_switch
.
read_bytes
(
0
)
if
ret_ack
<
1
:
print
(
"
I2C-Switch not found
"
)
return
False
else
:
self
.
dev_i2c_switch
.
write_bytes
(
0
,
data
)
ret_ack
,
ret_value
=
self
.
dev_i2c_switch
.
read_last_reg
(
1
)
read_value_int
=
int
(
ret_value
,
16
)
if
read_value_int
==
data
:
print
(
f
"
OK wrote 0x
{
data
:
02
X
}
read back 0x
{
read_value_int
:
02
X
}
"
)
return
True
else
:
print
(
f
"
ERROR wrote 0x
{
data
:
02
X
}
read back 0x
{
read_value_int
:
02
X
}
"
)
return
False
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