baryluk / fnirsi-usb-power-data-logger

Driver / Data logger for FNIRSI FNB48, FNIRSI C1 and FNIRSI FNB58 USB Power meter
MIT License
141 stars 14 forks source link

error: Resource busy #17

Closed PaulaScharf closed 10 months ago

PaulaScharf commented 10 months ago

I was trying to run this on Ubuntu 22.04 with Python 3.10.12 with a FNIRSI-FNB58 . When I connect the FNIRSI and run the program I get the error usb.core.USBError: [Errno 16] Resource busy.

I managed to get it working by adding the following code after line 69 of the fnirsi_logger.py:

i = dev[0].interfaces()[0].bInterfaceNumber
if dev.is_kernel_driver_active(i):
    try:
        dev.detach_kernel_driver(i)
    except usb.core.USBError as e:
        sys.exit("Could not detatch kernel driver from interface({0}): {1}".format(i, str(e)))

Not sure if this is the right way to solve this, but maybe it helps somebody else.

baryluk commented 10 months ago

Hi @PaulaScharf .

Interesting. We had similar code there before, but it was refactored few days ago, so maybe something did broke.

Let me check and test it.

baryluk commented 10 months ago

Yes, I can reproduce the issue. I will submit some changes to fix this soon.

baryluk commented 10 months ago

Should be fixed. Please pull the latest code.

Thanks for the report.

PaulaScharf commented 10 months ago

Thank you for the quick fix!