Commit c698cd5a authored by Alén Arias Vázquez's avatar Alén Arias Vázquez 😎

added command to read status of each channel

parent 72e458ab
......@@ -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)03d %(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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment