7 except ModuleNotFoundError
:
8 print("Please install pyserial module first.")
12 print('Usage: %s <baudrate>' % sys
.argv
[0])
14 baudrate
= int(sys
.argv
[1])
18 parity
=serial
.PARITY_NONE
,
19 stopbits
=serial
.STOPBITS_ONE
,
20 bytesize
=serial
.EIGHTBITS
27 while ser
.inWaiting() > 0:
31 print("HC-06 dongle not found. Abort.")
33 print('Enter your commands below.\r\nInsert "exit" to leave the application.')
38 inp
= inp
.encode('utf8')
46 ti
= time
.perf_counter()
49 if (ser
.in_waiting
> 0):
50 # When receiving data, reset timer and shorten timeout
51 ti
= time
.perf_counter()
55 # We stop either after 1s if no data or 50ms after last data received
56 if time
.perf_counter() - ti
> wait
:
59 print("<< " + out
.decode('utf8'))