1.利用libudev和select模式,启动线程监听usb设备插拔
XN_THREAD_PROC xnUSBUDEVEventsThread(XN_THREAD_PARAM pThreadParam)
{
struct udev *udev;
struct udev_device *dev;
struct udev_monitor *mon;
int fd;
/* Create the udev object */
udev = udev_new();
if (!udev) {
printf("Can't create udev\n");
exit(1);
}
/* This section sets up a monitor which will report events when
devices attached to the system change. Events include "add",
"remove", "change", "online", and "offline".
This section sets up and starts the monitoring. Events are
polled for (and delivered) later on.
It is important that the monitor be set up before the call to
udev_enumerate_scan_devices() so that events (and devices) are
not missed. For example, if enumeration happened first, there
would be no event generated for a device which was attached after
enumeration but before mon