Skip to content

Instantly share code, notes, and snippets.

@feuerrot
Created February 6, 2017 02:19
Show Gist options
  • Save feuerrot/8db7be862fd1ca0611997ce246afb477 to your computer and use it in GitHub Desktop.
Save feuerrot/8db7be862fd1ca0611997ce246afb477 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import serial
import time
import sys
ser = serial.Serial('/dev/ttyS4')
cmd = [
['a09', 'a1D', 'a1F', 'a0D'],
['a17', 'a12', 'a59', 'a08'],
['a5E', 'a06', 'a05', 'a03'],
['a18', 'a44', 'a0F', 'a51']
]
def usage():
print("Usage: {} [input] [output]".format(sys.argv[0]))
if len(sys.argv) != 3:
usage()
exit(1)
if (not sys.argv[1].isnumeric() or len(sys.argv[1]) != 1 or int(sys.argv[1]) < 1 or int(sys.argv[1]) > 4):
usage()
print("[input] must be between 1-4")
exit(1)
if (not sys.argv[2].isnumeric() or len(sys.argv[2]) != 1 or int(sys.argv[2]) < 1 or int(sys.argv[2]) > 4):
usage()
print("[output] must be between 1-4")
exit(1)
ser.write(cmd[int(sys.argv[1])-1][int(sys.argv[2])-1].encode('ASCII'))
time.sleep(0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment