diff --git a/src/python/getSerial.py b/src/python/getSerial.py new file mode 100644 index 0000000000000000000000000000000000000000..1ed7e099d93bf028fd7b2c75a480b537d8e1adc6 --- /dev/null +++ b/src/python/getSerial.py @@ -0,0 +1,10 @@ +import serial, struct, time +ser = serial.Serial('COM3') # open serial port +print(ser.name) # check which port was really used +# ser.write(b'\x04') # write a string +# ser.write(struct.pack('>B',1)) +while True : + line = ser.readline() + print(line.decode().split('\r\n')[0]) + +ser.close() # close port \ No newline at end of file diff --git a/src/python/pythonRead.py b/src/python/pythonRead.py index 3126e0868fd90fbec5bc550d78c47ea817cc0627..f424d930564a877795d228e62e29f02248c17734 100644 --- a/src/python/pythonRead.py +++ b/src/python/pythonRead.py @@ -1,9 +1,9 @@ import serial, urllib.request, json, time, struct -with urllib.request.urlopen("https://tranquil-citadel-63668.herokuapp.com/api/status") as url: - data = json.loads(url.read().decode()) +# with urllib.request.urlopen("https://tranquil-citadel-63668.herokuapp.com/api/status") as url: +# data = json.loads(url.read().decode()) -year = data['year'] +# year = data['year'] # data['year'] = 4 @@ -17,10 +17,12 @@ year = data['year'] ser = serial.Serial() ser.baudrate = 19200 -ser.port = 'COM8' +ser.port = 'COM3' ser.timeout = 1 ser.open() + +count = 0 while True : ser.flush() # print(ser.readable) @@ -38,7 +40,12 @@ while True : # print(struct.unpack('p',ser.read())) # print(b) # print(ser.read(4)) - print(ser.readline(ser.inWaiting())) + line = ser.readline(ser.inWaiting()) + print(line) + print(list(line)) + print(line.decode('cp855')) + ser.write(2) + # print(line.decode('utf-8')) # print(struct.unpack('b',ser.read())) time.sleep(3) ser.close() \ No newline at end of file