Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
DIOT reliability studies project
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Projects
DIOT reliability studies project
Commits
c698cd5a
Commit
c698cd5a
authored
Mar 29, 2022
by
Alén Arias Vázquez
😎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added command to read status of each channel
parent
72e458ab
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
cpx400dp.py
cpx400dp/cpx400dp.py
+16
-1
No files found.
cpx400dp/cpx400dp.py
View file @
c698cd5a
...
...
@@ -5,6 +5,11 @@ import argparse
class
CPX400DP
(
object
):
STATUS
=
{
0x0
:
'OFF'
,
0x1
:
'ON'
}
def
__init__
(
self
,
name
=
'CPX400DP'
,
devname
=
'/dev/ttyACM0'
,
baudrate
=
115200
,
log_level
=
logging
.
INFO
):
logging
.
basicConfig
(
format
=
'
%(asctime)
s.
%(msecs)03
d
%(name)
s-
%(levelname)-
s:
%(message)
s'
,
datefmt
=
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
,
level
=
log_level
)
self
.
name
=
name
...
...
@@ -75,7 +80,17 @@ class CPX400DP(object):
cmd
=
'OP'
+
str
(
chan
)
+
'?
\n
'
self
.
send_cmd
(
cmd
)
resp
=
self
.
recv_cmd
()
self
.
log
.
info
(
"Channel {} is {}"
.
format
(
chan
,
resp
))
state
=
int
(
resp
[
0
])
-
48
if
state
==
0
or
state
==
1
:
self
.
log
.
info
(
"The Channel {} is {}"
.
format
(
chan
,
self
.
STATUS
[
state
]))
return
bool
(
state
)
else
:
self
.
log
.
error
(
"Something was wrong reading status of channel {}"
.
format
(
chan
))
exit
()
def
get_status
(
self
):
for
j
in
range
(
2
):
self
.
CHAN_STATUS
[
j
]
=
self
.
get_status_chan
(
chan
=
j
+
1
)
def
setup_chan
(
self
,
chan
=
1
,
volts
=
10.0
,
amps
=
0.3
):
self
.
set_voltage
(
volts
=
volts
,
chan
=
chan
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment