-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserialmonitor.py
More file actions
26 lines (21 loc) · 759 Bytes
/
serialmonitor.py
File metadata and controls
26 lines (21 loc) · 759 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
import argparse
from src import uart_api
from time import sleep
if __name__ == "__main__":
print("Welcome to Serial Monitor")
ap = argparse.ArgumentParser()
ap.add_argument("-p", "--port", default="/dev/ttyUSB0", help="Enter Port Name")
ap.add_argument("-b", "--baudrate", default=9600, help="Enter Baud rate")
args = ap.parse_args()
uart = uart_api.UART_API(args.port, args.baudrate)
while True:
try:
print(uart.read())
sleep(1)
except KeyboardInterrupt:
user_input = input("Enter data to send or enter nothing to read further: ")
if user_input == "":
pass
else:
uart.write(user_input)
sleep(0.1)