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

后端 未结 5 1211
孤街浪徒
孤街浪徒 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:07

    I recently had a project which involved reading via an FTDI chip. I also tried using libftdi but found out that it is much simpler to use /dev/ttyUSB* for reading and writing. This way, you can use QFile('/dev/ttyUSB*') to write and read. You can also check if the device actually exists and it won't segfault. Of course, this is not a very 'Platform independent' way. To get a platform independent method, you can use a Serial library for Qt.

提交回复
热议问题