M
M
min4er2018-03-13 17:58:18
linux
min4er, 2018-03-13 17:58:18

How to set up hot swap usb device in linux?

Greetings!
The question is this. I am writing software for Linux that communicates with USB devices such as ttyUSB*/ttyACM*, it is necessary to implement recovery after a connection break. The problem occurs if the port was open at the time the device was redefined. The device in this case gets a new name (ttyUSB0->ttyUSB1), and the program stops seeing it. Wrote a UDEV rule that recreates a device with the same alias, but that doesn't help. There is only one alias (dev/mydevice) but it refers to when reconnecting to a new tty, and the file descriptor seems to be invalid. Are there any settings that could help get around this? The windows version of the software does not have such a problem, I can reconnect the USB device as much as I like ...
That is, the logic of the software as a result should be like this:
1. Opened the port.
2. We are waiting in the cycle for data from the port
3. There was a break in communication
4. Restoration of communication
5. Data came from the port
6. End of the cycle, closing the port.
On Windows it works, on Linux it doesn't...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question