Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serial port is left hanging in OS if it gets physically disconnected #144

Closed
MartynasRim opened this issue Nov 20, 2023 · 1 comment
Closed

Comments

@MartynasRim
Copy link
Contributor

MartynasRim commented Nov 20, 2023

Expected Behavior

If serial port is disconnected - lib should listen to LISTENING_EVENT_PORT_DISCONNECTED event and call closePort to prevent hanging serial port reference. More info at - https://fazecast.github.io/jSerialComm/javadoc/com/fazecast/jSerialComm/SerialPort.html#getCommPorts()

Note that the array will also include any serial ports that your application currently has open, even if the devices attached to those ports become disconnected. As such, it is important that you always call closePort() on a SerialPort object if it becomes disconnected, which is detectable by inspecting the return values from the various read calls or by registering a SerialPortDataListener for the LISTENING_EVENT_PORT_DISCONNECTED event.

Actual Behavior

If serial port gets disconnected (physically) & connected again while we do have a connection established we will have to ports available in OS. For example /dev/ttyUSB0 & /dev/ttyUSB1.

Steps to Reproduce the Problem

  1. Check how many USB ports are available ls dev | grep ttyUSB
  2. Connect serial port
  3. Connect to port using ModbusSerialMaster
  4. Disconnect port physically and reattach it
  5. Check how many USB ports are available ls dev | grep ttyUSB - there should be 2 more ports allocated

Specifications

  • Version: 3.2.0
  • Platform: 12 (bookworm) Raspbian
  • Subsystem:
@MartynasRim MartynasRim changed the title Serial port is left hanging if Serial port is left hanging in OS if it gets physically disconnected Nov 20, 2023
@steveohara
Copy link
Owner

Merged change into latest snapshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants