microsoft / vscode-serial-monitor

Serial Monitor that allows for reading and writing to serial ports. Official issue tracking repository for Microsoft's Serial Monitor VS Code extension.
MIT License
58 stars 7 forks source link

Serial port held open by remote VSCode and unable to reconnect #172

Open essele opened 7 months ago

essele commented 7 months ago

Type: Bug Report

When connecting to a remote VSCode session the first time everything works fine, and serial monitor is able to open the relevant serial port.

However if you disconnect, the VSCode server continues to run in the background, and the serial port remains open. (This is validated with lsof showing a process (node) having the port open.)

If you then reconnect, the "new instance" can't open the serial port because it's already open...

**** Failed to open the serial port /dev/ttyACM0 ****

If you completely remove the serial port (I can do that because it's USB) then you do get an error:

Serial port /dev/ttyACM0 disconnected. Waiting for reconnection...

.. so there is some linkage. But it feels like the handle to the port is somehow lost in the internals of vscode??

Or is it as simple as the monitoring started/not-started state is being lost?

To Reproduce Steps to reproduce the behavior:

  1. Have a remote system with a serial port
  2. On a client system, use VSCode remote to connect to the remote system
  3. "Start Monitoring" the serial port using Serial Monitor
  4. Kill the VSCode session
  5. Restart the VSCode session and reconnect
  6. The serial port shows as not being monitored i.e. button is Start Monitoring
  7. Click "Start Monitoring" and you get the error.
gcampbell-msft commented 7 months ago

@essele. Thanks for all of that information. Just to clarify, the issue is that the serial monitor is staying open on the remote machine, because you didn't stop monitoring on it. But if you disconnect from the remote VS Code, and then re-connect to the remote session, the extension initializes again (I think this is expected), it can't connect to the port because it's still open?

essele commented 7 months ago

Yes, that's a good summary (at least I believe that's what's happening.) I guess there are a couple of options (1) disconnect any open serial sessions anytime the extension re-initialises, or (2) re-establish any open session.

The second would be my preference, but I don't know anything about how this works behind the scenes.

OptifySudarshanPatil commented 3 months ago

Hi @essele @gcampbell-msft , Disconnecting and opening active serial connection session will cause (Any?) Arduino connected device to be restart again. (As it intentional in Arduino hardware). I think there should be gracefully way to handle this situation which will prevent any DTR and RTS pin toggle.

gcampbell-msft commented 3 weeks ago

@essele Can you confirm whether this issue is happening when the "auto-reconnect" button is disabled? Image