-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4645396
commit 0c3413a
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
api/src/opentrons/hardware_control/modules/tc_messenger.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()) |