Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
rshell
=========

support python version <= 3.12 on win; not support python >= 3.13;

Remote MicroPython shell.

This is a simple shell which runs on the host and uses MicroPython's
Expand Down
42 changes: 20 additions & 22 deletions rshell/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@
UART_BUFFER_SIZE = 32
BUFFER_SIZE = USB_BUFFER_SIZE
QUIET = False
RTS = ''
DTR = ''
SERIAL_EXCLUSIVE = True


# It turns out that just because pyudev is installed doesn't mean that
# it can actually be used. So we only bother to try if we're running
Expand Down Expand Up @@ -1676,6 +1676,8 @@ def write(self, buf):
class DeviceSerial(Device):

def __init__(self, port, baud, wait):
global SERIAL_EXCLUSIVE

self.port = port
self.baud = baud
self.wait = wait
Expand All @@ -1700,7 +1702,8 @@ def __init__(self, port, baud, wait):
self.dev_name_long = '%s at %d baud' % (port, baud)

try:
pyb = Pyboard(port, baudrate=baud, wait=wait, rts=RTS, dtr=DTR)
pyb = Pyboard(port, baudrate=baud,
wait=wait, exclusive = SERIAL_EXCLUSIVE)
except PyboardError as err:
print(err)
sys.exit(1)
Expand Down Expand Up @@ -2841,21 +2844,19 @@ def do_rsync(self, line):

def real_main():
"""The main program."""
global RTS
global DTR
global BUFFER_SIZE, SERIAL_EXCLUSIVE

try:
default_baud = int(os.getenv('RSHELL_BAUD'))
except:
default_baud = 115200
default_port = os.getenv('RSHELL_PORT')
default_rts = os.getenv('RSHELL_RTS') or RTS
default_dtr = os.getenv('RSHELL_DTR') or DTR
default_user = os.getenv('RSHELL_USER') or 'micro'
default_password = os.getenv('RSHELL_PASSWORD') or 'python'
default_editor = os.getenv('RSHELL_EDITOR') or os.getenv('VISUAL') or os.getenv('EDITOR') or 'vi'
default_color = sys.stdout.isatty()
default_nocolor = not default_color
global BUFFER_SIZE

try:
default_buffer_size = int(os.getenv('RSHELL_BUFFER_SIZE'))
except:
Expand Down Expand Up @@ -2890,18 +2891,6 @@ def real_main():
help="Set the serial port to use (default '%s')" % default_port,
default=default_port
)
parser.add_argument(
"--rts",
dest="rts",
help="Set the RTS state (default '%s')" % default_rts,
default=default_rts
)
parser.add_argument(
"--dtr",
dest="dtr",
help="Set the DTR state (default '%s')" % default_dtr,
default=default_dtr
)
parser.add_argument(
"-u", "--user",
dest="user",
Expand Down Expand Up @@ -2932,6 +2921,14 @@ def real_main():
help="Enable debug features",
default=False
)
parser.add_argument(
"--noexclusive",
dest="no_exclusive",
action="store_true",
help="Open the serial port Not use exclusive access mode"
" (default SERIAL_EXCLUSIVE is True)",
default=False
)
parser.add_argument(
"-n", "--nocolor",
dest="nocolor",
Expand Down Expand Up @@ -3034,8 +3031,9 @@ def real_main():

global ASCII_XFER
ASCII_XFER = args.ascii_xfer
RTS = args.rts
DTR = args.dtr

if args.no_exclusive:
SERIAL_EXCLUSIVE = False

if args.list:
listports()
Expand Down
Loading