st-ten-1/src/test/multicomp.py

34 lines
760 B
Python
Raw Normal View History

2022-07-19 14:09:26 +00:00
import time
import serial
2022-08-01 11:29:12 +00:00
# tester_port="/dev/ttyUSB0"
tester_port = "COM1"
2022-07-19 14:09:26 +00:00
conn = serial.Serial(
2022-08-01 11:29:12 +00:00
tester_port,
2022-07-19 14:09:26 +00:00
baudrate=115200,
stopbits=serial.STOPBITS_ONE,
parity=serial.PARITY_NONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
2022-08-23 14:00:04 +00:00
cmd_list = [
["*IDN?\n", True], # QUERY ID
["CONF:RES 500\n", False], # SET RESISTANCE MEASURE, 500 Ohm range
["MEAS?\n", True], # GET MEASURE
["MEAS?\n", True], # GET MEASURE
["MEAS?\n", True], # GET MEASURE
]
2022-07-19 14:09:26 +00:00
2022-08-23 14:00:04 +00:00
for [cmd, expect_response] in cmd_list:
2022-07-19 14:09:26 +00:00
conn.write(bytes(cmd, encoding="ascii"))
if expect_response:
response = conn.readline()
2022-07-20 17:29:11 +00:00
print(f"{cmd} RESPONSE: " + response.decode("ascii"))
2022-07-19 14:09:26 +00:00
else:
print(f"{cmd}")
time.sleep(1)
conn.close()