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

后端 未结 5 1219
孤街浪徒
孤街浪徒 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 03:57

    Don't forget that you have two problems here :

    • Detecting device insertion / removal
    • Properly terminating your application.

    The first problem has been adressed by Zifre.

    But the second problem remains : your Linux app should not be segfaulting when the device is removed, and I think the two problems are unrelated : if the device is removed in the middle of a write or read system call, then those system call will return with an error before you get any notification, and this should not segfault your app.

提交回复
热议问题