Server: Fix module loading, add warning when no argument, remove unneeded stuff

parent e17e1d85
......@@ -2,6 +2,7 @@
import serial
import time
import sys
sys.path.append('cytrill-server')
from srvr import start_srvr, ButtonEvent
move_y = 0
......@@ -77,74 +78,16 @@ def buttons_changed(device_name, event_list):
def main():
global move_y, move_z, move_r, move_servo, ser
ser = serial.Serial(sys.argv[1], 9600, timeout=1)
"""
if len(sys.argv) == 3 and sys.argv[2] == "play":
rec = open("recording", "r")
rec_str = rec.read()
if len(sys.argv)!=2:
print("Please specify serial device!")
exit()
for c in rec_str:
print(bytes(c, "utf-8"))
if c != " ":
ser.write(bytes(c, "utf-8"))
time.sleep(0.08)
return
"""
ser = serial.Serial(sys.argv[1], 9600, timeout=1)
start_srvr(callback=buttons_changed)
#rec = open("recording", "w")
while True:
time.sleep(100)
"""
try:
wrote_something = False
if move_y == 1:
ser.write(b"u")
print("u")
wrote_something = True
elif move_y == -1:
ser.write(b"d")
print("d")
wrote_something = True
if move_z == 1:
ser.write(b"f")
print("f")
wrote_something = True
elif move_z == -1:
ser.write(b"n")
print("n")
wrote_something = True
if move_r == 1:
ser.write(b"r")
print("r")
wrote_something = True
elif move_r == -1:
ser.write(b"l")
print("l")
wrote_something = True
if move_servo == 1:
ser.write(b"c")
print("c")
wrote_something = True
elif move_servo == -1:
ser.write(b"o")
print("o")
wrote_something = True
if not wrote_something:
rec.write(" ")
except:
pass
time.sleep(0.08)
"""
if __name__ == "__main__":
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment