-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconsole.py
executable file
·40 lines (32 loc) · 1.07 KB
/
console.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
#!/usr/bin/python
" Serial interface for uploading boneless firmware"
from serial.tools.miniterm import Miniterm
import serial
import time
the_port ="/dev/serial/by-id/usb-MicroPython_Board_in_FS_mode_e661410403178c2a-if00"
#the_port ="/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A700eCzo-if00-port0"
#the_port ="/dev/ttyUSB0"
class Console:
def __init__(self, port=the_port, baud=57600):
self.port = port
self.baud = baud
self.ser = serial.serial_for_url(
port, baud
)
# self.ser.dtr = 0
def attach(self):
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-l", "--list", action="store_true")
parser.add_argument("-v", "--verbose", action="store_true")
args = parser.parse_args()
term = Miniterm(self.ser)
term.set_rx_encoding("utf-8")
term.set_tx_encoding("utf-8")
term.exit_character = "\x1d"
print("Attach console")
term.start()
term.join(True)
if __name__ == "__main__":
c = Console()
c.attach()