-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserialReadTest2.py
More file actions
35 lines (26 loc) · 792 Bytes
/
serialReadTest2.py
File metadata and controls
35 lines (26 loc) · 792 Bytes
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
import time
import struct
from pySerialTransfer import pySerialTransfer
if __name__ == '__main__':
try:
link = pySerialTransfer.SerialTransfer('serial0')
link.open()
time.sleep(2) # allow some time for the Arduino to completely reset
print('Starting')
while True:
time.sleep(1)
while not link.available():
if link.status < 0:
print('ERROR: {}'.format(link.status))
else:
print('.',end='',flush=True)
time.sleep(0.25)
print()
response = link.rxBuff[:link.bytesRead]
binary_str = bytearray(response)
print(binary_str)
#unpacked_resp = struct.unpack('iiii', binary_str)
#print('RCVD: %s' % str(unpacked_resp))
print(' ')
except KeyboardInterrupt:
link.close()