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
08aa6505
Commit
08aa6505
authored
2 years ago
by
Gijs Schoonderbeek
Browse files
Options
Downloads
Patches
Plain Diff
update during testing APSPU from production
parent
aaab3915
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
APSPU_I2C.py
+2
-1
2 additions, 1 deletion
APSPU_I2C.py
I2C_serial_pi.py
+15
-13
15 additions, 13 deletions
I2C_serial_pi.py
I2C_serial_pi2.py
+16
-1
16 additions, 1 deletion
I2C_serial_pi2.py
apspu_lib.py
+9
-2
9 additions, 2 deletions
apspu_lib.py
with
42 additions
and
17 deletions
APSPU_I2C.py
+
2
−
1
View file @
08aa6505
...
@@ -56,7 +56,8 @@ LP_VOUT_UV_LIMIT = 0x44
...
@@ -56,7 +56,8 @@ LP_VOUT_UV_LIMIT = 0x44
LP_STORE_USER_ALL
=
0x15
LP_STORE_USER_ALL
=
0x15
LP_ON_OFF_CONFIG
=
0x02
LP_ON_OFF_CONFIG
=
0x02
LP_OPERATION
=
0x01
LP_OPERATION
=
0x01
LP_WRITE_PROTECT
=
0x10
LP_STORE_DEFAULT_ALL
=
0x12
#
#
# Central I2C Devices
# Central I2C Devices
#
#
...
...
This diff is collapsed.
Click to expand it.
I2C_serial_pi.py
+
15
−
13
View file @
08aa6505
...
@@ -42,11 +42,11 @@ class I2C:
...
@@ -42,11 +42,11 @@ class I2C:
ret_ack
=
1
ret_ack
=
1
if
SLOW
:
if
SLOW
:
sleep
(
0.2
)
sleep
(
0.2
)
except
IOError
,
err
:
except
IOError
:
ret_ack
=
0
ret_ack
=
0
ret_value
=
'
ffff
'
ret_value
=
'
ffff
'
if
DEBUG
:
if
DEBUG
:
print
(
"
Reading error
"
)
print
(
"
Reading
IO-
error
"
)
return
ret_ack
,
ret_value
return
ret_ack
,
ret_value
...
@@ -60,27 +60,29 @@ class I2C:
...
@@ -60,27 +60,29 @@ class I2C:
ret_ack
=
1
ret_ack
=
1
if
SLOW
:
if
SLOW
:
sleep
(
0.2
)
sleep
(
0.2
)
except
IOError
,
err
:
except
IOError
:
ret_ack
=
0
ret_ack
=
0
rd_value
.
append
(
0
)
rd_value
.
append
(
0
)
if
DEBUG
:
if
DEBUG
:
print
(
"
Reading error
"
)
print
(
"
IO-
Reading error
"
)
for
cnt
in
range
(
bytes_to_read
):
for
cnt
in
range
(
bytes_to_read
):
ret_value
+=
(
hex
(
rd_value
[
cnt
])[
2
:])
ret_value
+=
(
hex
(
rd_value
[
cnt
])[
2
:])
return
ret_ack
,
ret_value
return
ret_ack
,
ret_value
def
write_bytes
(
self
,
register
,
data
):
def
write_bytes
(
self
,
register
,
data
):
bus
=
smbus
.
SMBus
(
self
.
bus_nr
)
bus
=
smbus
.
SMBus
(
self
.
bus_nr
)
if
type
(
data
)
is
not
list
:
data
=
[
data
]
try
:
try
:
bus
.
write_i2c_block_data
(
self
.
I2C_Address
,
register
,
[
data
]
)
bus
.
write_i2c_block_data
(
self
.
I2C_Address
,
register
,
data
)
ret_ack
=
1
ret_ack
=
1
if
SLOW
:
if
SLOW
:
sleep
(
0.3
)
sleep
(
0.3
)
except
IOError
,
err
:
except
IOError
:
ret_ack
=
0
ret_ack
=
0
ret_value
=
0
ret_value
=
0
if
DEBUG
:
if
DEBUG
:
print
(
"
Write error
"
)
print
(
"
Write
IO-
error
"
)
return
ret_ack
return
ret_ack
def
write_register
(
self
,
register
):
def
write_register
(
self
,
register
):
...
@@ -90,11 +92,11 @@ class I2C:
...
@@ -90,11 +92,11 @@ class I2C:
ret_ack
=
1
ret_ack
=
1
if
SLOW
:
if
SLOW
:
sleep
(
0.3
)
sleep
(
0.3
)
except
IOError
,
err
:
except
IOError
:
ret_ack
=
0
ret_ack
=
0
ret_value
=
0
ret_value
=
0
if
DEBUG
:
if
DEBUG
:
print
(
"
Write error
"
)
print
(
"
Write
IO-
error
"
)
return
ret_ack
return
ret_ack
def
write_pointer
(
self
,
register
):
def
write_pointer
(
self
,
register
):
...
@@ -104,11 +106,11 @@ class I2C:
...
@@ -104,11 +106,11 @@ class I2C:
ret_ack
=
1
ret_ack
=
1
if
SLOW
:
if
SLOW
:
sleep
(
0.3
)
sleep
(
0.3
)
except
IOError
,
err
:
except
IOError
:
ret_ack
=
0
ret_ack
=
0
ret_value
=
0
ret_value
=
0
if
DEBUG
:
if
DEBUG
:
print
(
"
Write error
"
)
print
(
"
Write
IO-
error
"
)
return
ret_ack
return
ret_ack
def
ack_check
(
self
):
def
ack_check
(
self
):
...
@@ -119,11 +121,11 @@ class I2C:
...
@@ -119,11 +121,11 @@ class I2C:
ret_ack
=
1
ret_ack
=
1
if
SLOW
:
if
SLOW
:
sleep
(
0.3
)
sleep
(
0.3
)
except
IOError
,
err
:
except
IOError
:
ret_ack
=
0
ret_ack
=
0
ret_value
=
0
ret_value
=
0
if
DEBUG
:
if
DEBUG
:
print
(
"
No ACK
"
)
print
(
"
No ACK
IO-Error
"
)
return
ret_ack
return
ret_ack
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
I2C_serial_pi2.py
+
16
−
1
View file @
08aa6505
...
@@ -97,7 +97,8 @@ class I2C:
...
@@ -97,7 +97,8 @@ class I2C:
def
write_pointer
(
self
,
register
):
def
write_pointer
(
self
,
register
):
bus
=
pi
.
i2c_open
(
self
.
bus_nr
,
self
.
I2C_Address
)
bus
=
pi
.
i2c_open
(
self
.
bus_nr
,
self
.
I2C_Address
)
try
:
try
:
pi
.
i2c_read_device
(
bus
,
1
)
# pi.i2c_read_device(bus, 1)
pi
.
i2c_read_device
(
bus
,
register
)
ret_ack
=
1
ret_ack
=
1
if
SLOW
:
if
SLOW
:
sleep
(
0.3
)
sleep
(
0.3
)
...
@@ -109,6 +110,20 @@ class I2C:
...
@@ -109,6 +110,20 @@ class I2C:
pi
.
i2c_close
(
bus
)
pi
.
i2c_close
(
bus
)
return
ret_ack
return
ret_ack
def
write_register
(
self
,
register
):
bus
=
pi
.
i2c_open
(
self
.
bus_nr
,
self
.
I2C_Address
)
try
:
ret_value
=
pi
.
i2c_write_device
(
bus
,
[
register
])
ret_ack
=
1
if
SLOW
:
sleep
(
0.3
)
except
IOError
:
ret_ack
=
0
ret_value
=
0
if
DEBUG
:
print
(
"
No ACK
"
)
return
ret_ack
def
ack_check
(
self
):
def
ack_check
(
self
):
bus
=
smbus
.
SMBus
(
self
.
bus_nr
)
bus
=
smbus
.
SMBus
(
self
.
bus_nr
)
try
:
try
:
...
...
This diff is collapsed.
Click to expand it.
apspu_lib.py
+
9
−
2
View file @
08aa6505
...
@@ -25,7 +25,7 @@ from APSPU_I2C import *
...
@@ -25,7 +25,7 @@ from APSPU_I2C import *
if
os
.
name
==
"
posix
"
:
if
os
.
name
==
"
posix
"
:
from
I2C_serial_pi
2
import
*
from
I2C_serial_pi
import
*
else
:
else
:
from
I2C_serial
import
*
from
I2C_serial
import
*
...
@@ -84,6 +84,7 @@ class ApspuClass:
...
@@ -84,6 +84,7 @@ class ApspuClass:
f
"
set
{
1.2
*
VOUT_POLS
[
pol
.
name
]
}
read back
{
ov_out
}
"
)
f
"
set
{
1.2
*
VOUT_POLS
[
pol
.
name
]
}
read back
{
ov_out
}
"
)
exit
()
exit
()
pol
.
set_on_off_config
()
pol
.
set_on_off_config
()
pol
.
on_off
(
True
)
pol
.
write_to_nvm
()
pol
.
write_to_nvm
()
print
(
"
Done
"
)
print
(
"
Done
"
)
...
@@ -269,6 +270,7 @@ class PolClass:
...
@@ -269,6 +270,7 @@ class PolClass:
#
#
ret_ack
=
False
ret_ack
=
False
if
self
.
status
:
if
self
.
status
:
ret_ack
=
self
.
pol_dev
.
write_bytes
(
LP_WRITE_PROTECT
,
[
0
])
set_value
=
int
(
value
*
(
2
**
11
))
set_value
=
int
(
value
*
(
2
**
11
))
hex_set_value
=
hex
(
set_value
)
hex_set_value
=
hex
(
set_value
)
wr_value
=
(
hex_set_value
[
4
:
6
]
+
hex_set_value
[
2
:
4
])
wr_value
=
(
hex_set_value
[
4
:
6
]
+
hex_set_value
[
2
:
4
])
...
@@ -306,7 +308,12 @@ class PolClass:
...
@@ -306,7 +308,12 @@ class PolClass:
#
#
# return is always True
# return is always True
#
#
ret_ack
=
self
.
pol_dev
.
write_bytes
(
LP_STORE_USER_ALL
,
0
)
ret_ack
=
self
.
pol_dev
.
write_register
(
0x15
)
# command = f"i2cset -y 1 0x{CTR_POLS[self.name]:02X} 0x15 cp"
# print(command)
# os.system(command)
# os.system(command)
sleep
(
5
)
return
True
return
True
def
read_vin
(
self
):
def
read_vin
(
self
):
...
...
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