From 0c3413ac79c4d4d8fa45a355ad1a30a661519237 Mon Sep 17 00:00:00 2001 From: caila-marashaj Date: Mon, 6 May 2024 17:24:46 -0400 Subject: [PATCH] create tc-messenger script --- .../hardware_control/modules/tc_messenger.py | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 api/src/opentrons/hardware_control/modules/tc_messenger.py diff --git a/api/src/opentrons/hardware_control/modules/tc_messenger.py b/api/src/opentrons/hardware_control/modules/tc_messenger.py new file mode 100644 index 000000000000..e396bf4b3295 --- /dev/null +++ b/api/src/opentrons/hardware_control/modules/tc_messenger.py @@ -0,0 +1,41 @@ +import sys +from serial import Serial + +_READ_ALL = "readall" +_READ_LINE = "read" +_LID_AND_SEAL_STATUS = "status" +_MOVE_SEAL = "ms" +_DONE = "done" + + +def comms_loop(dev): + exit = False + command = input("enter a command\n") + if command == _READ_ALL: + print(dev.readlines()) + elif command == _READ_LINE: + print(dev.readline()) + elif command == _LID_AND_SEAL_STATUS: + dev.write("M119\n".encode()) + print(dev.readline()) + elif command == _MOVE_SEAL: + distance = input("enter distance in steps") + dev.write(f"M241.D {distance}\n") + print(dev.readline()) + elif command == _DONE: + exit = True + else: + dev.write(f"{command}\n") + print(dev.readline()) + + return exit + + +def _main(): + dev = Serial('/dev/ot_module_thermocycler0', 9600, timeout=2) + run = True + while run: + run = comms_loop(dev) + +if __name__ == '__main__': + sys.exit(_main()) \ No newline at end of file