mirror of
https://github.com/erjiang/usbscale.git
synced 2025-06-28 09:00:58 -06:00
Fix duplicate scale detection in find_nth_scale
This commit is contained in:
parent
efccef3334
commit
219c9b4ec2
@ -463,8 +463,8 @@ static libusb_device* find_nth_scale(libusb_device **devs, int index)
|
|||||||
uint16_t last_device_address = 0;
|
uint16_t last_device_address = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Loop through each USB device, and for each device, loop through the
|
// Loop through each USB device and check if it's one of the
|
||||||
// scales list to see if it's one of our listed scales.
|
// supported scales listed in scales.h.
|
||||||
//
|
//
|
||||||
while ((dev = devs[i++]) != NULL) {
|
while ((dev = devs[i++]) != NULL) {
|
||||||
|
|
||||||
@ -474,9 +474,7 @@ static libusb_device* find_nth_scale(libusb_device **devs, int index)
|
|||||||
fprintf(stderr, "failed to get device descriptor");
|
fprintf(stderr, "failed to get device descriptor");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
int i;
|
if (is_scale(desc.idVendor, desc.idProduct)) {
|
||||||
for (i = 0; i < NSCALES; i++) {
|
|
||||||
if (is_scale(desc.idVendor, desc.idProduct)) {
|
|
||||||
|
|
||||||
// Skip this device if it's the same as the last one.
|
// Skip this device if it's the same as the last one.
|
||||||
uint16_t this_device_address = (libusb_get_bus_number(dev) << 8) + libusb_get_device_address(dev);
|
uint16_t this_device_address = (libusb_get_bus_number(dev) << 8) + libusb_get_device_address(dev);
|
||||||
@ -520,7 +518,6 @@ static libusb_device* find_nth_scale(libusb_device **devs, int index)
|
|||||||
if (curr_index == index) {
|
if (curr_index == index) {
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user