How to detect USB device disconnect under Linux/Qt/C++

后端 未结 5 1208
孤街浪徒
孤街浪徒 2021-01-03 03:37

I\'m writing a system (X-Platform Windows/Linux) that talks to a custom device using an FTDI USB chip. I use their D2XX driver for device open/close/read/write. So far, so

5条回答
  •  清酒与你
    2021-01-03 04:13

    Although what I'm about to tell you won't directly answer your question, it may give you a hint as to your next move.

    I use udev rules configured in '/etc/udev/rules.d/' which run various scripts. When a USB device gets connected/disconnected I run a script which sends a HUP signal to my binary. Since my requirements can handle a bit of lag it works perfectly fine for me.

    But my point is that maybe there is a udev library you can link to and register events programmatically (instead of scripts).

    Hope it helps... good luck!

提交回复
热议问题