mcuee / libusb-win32

libusb-win32 project official github repo
179 stars 49 forks source link

usb_open() failed sometimes #72

Open hellomanyi opened 2 months ago

hellomanyi commented 2 months ago

Hello, I found that there is a low probability that usb_open() cannot be opened when using libusb-win32. After analyzing libusb-1.0 and libusbK, I initially judged that the opening mode of CreateFile may cause it to fail to open; libusb-win32 uses exclusive mode; both libusb-1.0 and libusbK are opened in shared mode; why we open it in this way ? can we modify it to shared mode?

libusb-win32: CreateFile(dev_name, 0, 0, NULL, OPEN_EXISTING,FILE_FLAG_OVERLAPPED, NULL);

libusb-1.0 handle = CreateFileA(path, access, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);

Libusbk CreateFileA(DevicePathStrA, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL)

mcuee commented 1 month ago

What is the device in question?