Skip to content

Commit

Permalink
small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
marius.crisan committed Oct 23, 2023
1 parent bdacda1 commit 75f130c
Showing 1 changed file with 90 additions and 1 deletion.
91 changes: 90 additions & 1 deletion code/drv_ea/tests/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

####################### PROJECT IMPORTS #######################
from scpi_sniffer import *
from serial import PARITY_ODD, EIGHTBITS, STOPBITS_ONE
from serial import PARITY_ODD, EIGHTBITS, STOPBITS_ONE, Serial

####################### MODULE IMPORTS #######################
from drv_ea.src.wattrex_driver_ea import *
Expand Down Expand Up @@ -65,5 +65,94 @@ def main():
source.close()


def raw_example_ea_source():
'''
Quick test to check the conectivity with the device.
'''
serial = Serial(port = '/dev/ttyACM0',
baudrate = 9600,
bytesize = EIGHTBITS,
parity = PARITY_ODD,
stopbits = STOPBITS_ONE,
timeout = 1, #0.1
write_timeout = 1,
inter_byte_timeout = 1)
READ_INFO = 'IDN*?'
GET_MEAS = 'MEASure:ARRay?'
CURR_NOM = 'SYSTem:NOMinal:CURRent?'
VOLT_NOM = 'SYSTem:NOMinal:VOLTage?'
POWER = 'SYSTem:NOMinal:POWer?'
LOCK = 'SYSTem:LOCK:OWNer?'
LOCK_ON = 'SYSTem:LOCK: ON'
LOCK_OFF = 'SYSTem:LOCK: OFF'
OUTPUT_ON = 'OUTPut: ON'
OUTPUT_OFF = 'OUTPut: OFF'

read_info_send = (READ_INFO + '\n').encode()
read_meas_send = (GET_MEAS + '\n').encode()
empty_msg = bytes(('\n').encode())


serial.write((LOCK_ON + '\n').encode())
read = serial.readline()

ON = False
if ON:
serial.write((OUTPUT_ON + '\n').encode())


msg = 'STAT:OPERation:CONDition?'

time.sleep(1)
serial.write((msg + '\n').encode())
read = serial.readline()
read_dec = read.decode("utf-8")
log.info(f"Read: {read} - Dec: {read_dec}")

'''
0 = Output off
256 = CV
512 = CC
'''


# response = serial.write((LOCK_OFF + '\n').encode())
# log.info (f"Response: {response}")
# read = serial.readline()
# log.info(f"Read: {read}")

# response = serial.write((LOCK + '\n').encode())
# log.info (f"Response: {response}")
# read = serial.readline()
# log.info(f"Read: {read}")


# serial.write((OUTPUT_ON + '\n').encode())
# read = serial.readline()
# log.info(f"Read: {read}")

# serial.write((GET_MEAS + '\n').encode())
# read = serial.readline()
# log.info(f"Read: {read}")




# serial.write(empty_msg)
# read = serial.readline()
# read = serial.readline()

# serial.write(bytes(read_info_send))
# read = serial.readline()
# log.info(f"Read: {read}")


# serial.write(bytes(read_meas_send))
# read = serial.readline()
# log.info(f"Read: {read}")



if __name__ == '__main__':
main()
# raw_example_ea_source()

0 comments on commit 75f130c

Please sign in to comment.