-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsender-LQArmUI.py
executable file
·61 lines (52 loc) · 2.11 KB
/
sender-LQArmUI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/python3
import sys
import serial
import os
from config import config
import requests as req
ser = serial.Serial("/dev/ttyACM0", "9600")
os.system('clear')
print("")
print("-------------------------------------------")
print(" LQArmUI v0.2 - Modul przekazujacy")
print(" Urzadzenie: "+ser.portstr)
print("-------------------------------------------")
print(" Argumenty wejsciowe: "+ str(len(sys.argv)-1))
print("")
if len(sys.argv)-1>0:
if sys.argv[1][0] == "-":
if sys.argv[1]=="-cl":
while True:
userkom = input("~ ")
if userkom == "exit":
break
print(" Wysylam do Arduino "+ userkom)
## Wyslij do Arduino
ser.write(userkom.encode())
# r = req.post('http://'+ip+':5000/db/insert_logcmd',data={'log_newcmd': userkom, 'log_infc': 2})
if sys.argv[1]=="-u":
newcmd = sys.argv[2]
print(" Wysylam do Arduino"+ newcmd)
# r = req.post('http://'+ip+':5000/db/insert_logcmd',data={'log_newcmd': newcmd, 'log_infc': 2})
ser.write(newcmd.encode())
if sys.argv[1]=="-ar":
newcmd = sys.argv[2]
print(" Wysylam do Arduino"+ newcmd)
# r = req.post('http://'+ip+':5000/db/insert_logcmd',data={'log_newcmd': newcmd, 'log_infc': 1})
ser.write(newcmd.encode())
if sys.argv[1]=="-ui":
newcmd = sys.argv[2]
print(" Wysylam do Arduino"+ newcmd)
# r = req.post('http://'+ip+':5000/db/insert_logcmd',data={'log_newcmd': newcmd, 'log_infc': 0})
ser.write(newcmd.encode())
else:
newcmd = sys.argv[1]
print(" Wysylam do Arduino"+ newcmd)
## Wyslij do Arduino
ser.write(newcmd.encode())
# r = req.post('http://'+ip+':5000/db/insert_logcmd',data={'log_newcmd': newcmd.encode() , 'log_infc': 2})
print("")
print(" Nie ma nic wiecej do roboty...")
print("-------------------------------------------")
print("")
ser.close()