Maxwell,
I think I found a discrepancy
between our implementations that is going to be problematic.
In yours, you use libusb_get_port_number, but I
use libusb_get_device_address.
It looks like
libusb_get_port_number returns the last digit of
libusb_get_port_numbers, which is something like
1,3,1,1 so port_number is just 1. This allows conflicts since
port_number isn't unique, despite what the documentation
implies. The bus_number + device_address is the unique
combination required.
On my Linux machines,
device_address matches the sysfs node devnum (and bus_number
is busnum), while port_number matches the path: /sys/bus/usb/devices/<bus_number>-<port_numbers>/{busnum,devnum}
I don't know how much this changes
between systems, though, so I can't speak to whether this will
be the case with your machines.
What do you think?