You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm always frustrated when I try to flash a chip using esptool, and I accidentally left a serial console open somewhere else, causing esptool to behave weirdly (since multiple programs are using the same serial port, some of the data on the serial port ends up in esptool and the other part end up in the serial console).
Describe the solution you'd like
This can be avoided by advisory locking the serial port; in pyserial, this can be done with pyserial/pyserial#206. A lot of programs already do this, but since this is advisory locking, it only helps if all programs you're using check the lock. See also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=734086
A one-line fix would be to add under this line https://github.com/espressif/esptool/blob/master/esptool/loader.py#L303self._port.exclusive = True. If you want to do something fancier, you can also catch the error, and maybe even display the program that is using it. For me, just seeing 'this port is already in use by another program' would already be useful.
Describe alternatives you've considered
No response
Additional context
This is on Linux; I don't think locking in pyserial is implemented in Windows, so it should not cause any issues there.
The text was updated successfully, but these errors were encountered:
github-actionsbot
changed the title
Use PySerial locking so the serial port isn't used by other programs
Use PySerial locking so the serial port isn't used by other programs (ESPTOOL-792)
Jan 11, 2024
Is your feature request related to a problem?
I'm always frustrated when I try to flash a chip using esptool, and I accidentally left a serial console open somewhere else, causing esptool to behave weirdly (since multiple programs are using the same serial port, some of the data on the serial port ends up in esptool and the other part end up in the serial console).
Describe the solution you'd like
This can be avoided by advisory locking the serial port; in pyserial, this can be done with pyserial/pyserial#206. A lot of programs already do this, but since this is advisory locking, it only helps if all programs you're using check the lock. See also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=734086
A one-line fix would be to add under this line https://github.com/espressif/esptool/blob/master/esptool/loader.py#L303
self._port.exclusive = True
. If you want to do something fancier, you can also catch the error, and maybe even display the program that is using it. For me, just seeing 'this port is already in use by another program' would already be useful.Describe alternatives you've considered
No response
Additional context
This is on Linux; I don't think locking in pyserial is implemented in Windows, so it should not cause any issues there.
The text was updated successfully, but these errors were encountered: