Open Wind-stormger opened 1 year ago
Hey @Wind-stormger and thanks for submitting this issue. Where do you run your snippet? Do you run that using mpbridge's dev
modes' REPL
?
Yes.
At present, most ESP32S3 development boards use the USB-CDC function provided by the built-in USB interface to realize serial communication, which eliminates the need for additional UART-to-USB chips.
But the fly in the ointment is that when the hardware resets, it will cause disconnection.
It would be great if it could automatically reconnect to the REPL after a hardware reset.
I put forward an idea, when using REPL, if you encounter an unexpected disconnection, of course, this generally refers to the USB device hardware reset, delay about 1 second to try to connect to REPL. @AmirHmZz
@Wind-stormger Do you encounter this issue with mpbridge v1.4.0
?
@AmirHmZz Nice to see your release, I will upgrade it and take a look
@AmirHmZz Hmm, doesn't work very well
> mpbridge dev --auto-reset soft COM21
...
...
...
MicroPython v1.21.0 on 2023-10-06; Generic ESP32S3 module with ESP32S3
Type "help()" for more information.
>>> import machine
>>> machine.reset()
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\Wind\AppData\Local\Programs\Python\Python311\Scripts\mpbridge.exe\__main__.py", line 7, in <module>
File "C:\Users\Wind\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1130, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Wind\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1055, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "C:\Users\Wind\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Wind\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Wind\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 760, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Wind\AppData\Local\Programs\Python\Python311\Lib\site-packages\mpbridge\shell.py", line 125, in dev
bridge.start_dev_mode(port, dir_path, auto_reset=auto_reset, no_prompt=no_prompt)
File "C:\Users\Wind\AppData\Local\Programs\Python\Python311\Lib\site-packages\mpbridge\bridge.py", line 87, in start_dev_mode
start_repl(port)
File "C:\Users\Wind\AppData\Local\Programs\Python\Python311\Lib\site-packages\mpbridge\bridge.py", line 106, in start_repl
do_repl(state, argparse_repl().parse_args([]))
File "C:\Users\Wind\AppData\Local\Programs\Python\Python311\Lib\site-packages\mpremote\repl.py", line 89, in do_repl
do_repl_main_loop(
File "C:\Users\Wind\AppData\Local\Programs\Python\Python311\Lib\site-packages\mpremote\repl.py", line 10, in do_repl_main_loop
console_in.waitchar(state.transport.serial)
File "C:\Users\Wind\AppData\Local\Programs\Python\Python311\Lib\site-packages\mpremote\console.py", line 99, in waitchar
while not (self.inWaiting() or pyb_serial.inWaiting()):
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Wind\AppData\Local\Programs\Python\Python311\Lib\site-packages\serial\serialutil.py", line 594, in inWaiting
return self.in_waiting
^^^^^^^^^^^^^^^
File "C:\Users\Wind\AppData\Local\Programs\Python\Python311\Lib\site-packages\serial\serialwin32.py", line 259, in in_waiting
raise SerialException("ClearCommError failed ({!r})".format(ctypes.WinError()))
serial.serialutil.SerialException: ClearCommError failed (PermissionError(13, 'The device does not recognize the command.', None, 22))
@Wind-stormger I will take a look at that problem.
Is there a way to automatically reconnect the serial port REPL during any hard reset? 🤔