rc = radiacode.RadiaCode() attaches to the first device libusb happens to discover. If you have multiple radiacode devices attached, perhaps one inside and one outside of an enclosure, you can't just do this
and trust libusb to get it right. Instead, you get an exception: USBError: [Errno 16] Resource busy
This diff adds a serial_number argument to the RadiaCode USB constructor which will then be used to attach only that device, eg. rc = radiacode.RadiaCode(serial_number="RC-102-000456") would attach to "RC-102-000456" even if "RC-103-000123" was found first.
radiacode.RadiaCode() still attaches to the first device.
radiacode.RadiaCode(serial_number="nonexistent") raises DeviceNotFound as expected.
rc = radiacode.RadiaCode()
attaches to the first device libusb happens to discover. If you have multiple radiacode devices attached, perhaps one inside and one outside of an enclosure, you can't just do thisand trust libusb to get it right. Instead, you get an exception:
USBError: [Errno 16] Resource busy
This diff adds a
serial_number
argument to the RadiaCode USB constructor which will then be used to attach only that device, eg.rc = radiacode.RadiaCode(serial_number="RC-102-000456")
would attach to "RC-102-000456" even if "RC-103-000123" was found first.radiacode.RadiaCode()
still attaches to the first device.radiacode.RadiaCode(serial_number="nonexistent")
raisesDeviceNotFound
as expected.And now you can do this too: