serial-device/writer.py

25 lines
508 B
Python
Raw Normal View History

2023-10-01 22:41:21 +03:00
from time import sleep
import yaml
from transport.serial import Transport
config_name = "config.yml"
with open(config_name) as f:
config = yaml.load(f, Loader=yaml.FullLoader)
connector = Transport(config["writer"]["transport"])
commands_list = ['GET_A', 'GET_B', 'GET_C', 'GET_NORESP', 'INVALID_CMD']
while (True):
for cmd in commands_list:
print('Write: ' + cmd)
connector.writeline(cmd)
sleep(0.5)
print("Response: "+connector.readline())
sleep(1)