Fazecast / jSerialComm

Platform-independent serial port access for Java
GNU Lesser General Public License v3.0
1.35k stars 287 forks source link

Question about "cdc_acm 2-1.3:1.0: failed to set dtr/rts" #487

Closed Dominik-Helfenstein closed 1 year ago

Dominik-Helfenstein commented 1 year ago

Hi,

I am currently using v2.6.2 and somewhat randomly (maybe every few days) I receive the error message cdc_acm 2-1.3:1.0: failed to set dtr/rts from the Linux kernel module. I have read that this problem might come from a short drop of the supply voltage for the USB device. It might come from my USB device as well but I am not sure.

The problem is that the library does not recognize the error message. Messages are still being received from the USB device, but none can be sent. Currently, a custom watchdog checks whether a message has been sent and if the message couldn't be sent for 15s, it throws an error.

Have you seen this problem before or do you know more about this problem than me? And do you know if it is fixed in the latest version? Or is it solely a problem of my USB device (it has a custom firmware)?

I am happy about any information 🙂

Regards, Dominik

hedgecrw commented 1 year ago

I've never personally seen or heard of this message before, and since it's coming from the kernel, it's probably nothing I can do anything about in user space. One thing to try would be to register an event listener with jSerialComm to listen for LISTENING_EVENT_PORT_DISCONNECTED events and see if maybe this event gets thrown when that kernel error occurs. If so, you might be able to reconnect immediately when that happens. If no event is detected, then I'm not sure there's anything that can be done about it from the library...

Dominik-Helfenstein commented 1 year ago

In the past few weeks I have investigated a bit further and on Windows it detects the connection loss properly, but not on Linux. I've also experimented with the serial package in Rust and it detects the connection loss too and throws an error.

I will try your suggestion, thanks.

hedgecrw commented 1 year ago

Any update on this issue? Also, could you please test with the newest library version (2.10.1) as it has some updates to the flow control configuration code under-the-hood.

domhel commented 1 year ago

I test it within the next two weeks and will inform you

Dominik-Helfenstein commented 1 year ago

Hi,

2.10.1 has not fixed the issue without modification. However, the LISTENING_EVENT_PORT_DISCONNECTED introduced in 2.8.0 works perfectly. The event is triggered as soon as I provoke that the USB device loses connection. I can then restart the serial communication part of our software.

Thanks