Skip to content

Commit

Permalink
NEWS.adoc, drivers/apc_modbus.c: _apc_modbus_usb_callback(): handle c…
Browse files Browse the repository at this point in the history
…ommon return codes from matcher methods, like libusb1.c does [#2609]

Notably, handle active rejection of a candidate device by the matcher
properly - go try the next device!

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jan 29, 2025
1 parent fbf6594 commit 2c8663f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,10 @@ https://github.com/networkupstools/nut/milestone/11
to have fixed a Segmentation Fault seen in earlier NUT releases with
some of the devices supported by this driver. [#2427]
- apc_modbus driver should now properly handle mismatches of criteria passed
to the regular expression matcher (e.g. serial number) allowing several USB
devices to be monitored without conflict. [#2609]
- phoenixcontact_modbus driver: Introduced Phoenix Contact QUINT4-UPS/24DC
management (only new modbus addresses). [#2689, #2716]
Expand Down
10 changes: 10 additions & 0 deletions drivers/apc_modbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,16 @@ static int _apc_modbus_usb_callback(const modbus_usb_device_t *device)
if (ret == 1) {
/* known good hit */
break;
} else if (ret == 0) {
/* known active rejection */
upsdebugx(2, "%s: Device does not match - skipping", __func__);
/* go to next device that libmodbus would suggest and use this callback again */
return -1;
} else if (ret == -1) {
fatal_with_errno(EXIT_FAILURE, "%s: matcher", __func__);
} else if (ret == -2) {
upsdebugx(2, "%s: matcher: unspecified error", __func__);
return -1;
}

current_matcher = current_matcher->next;
Expand Down

0 comments on commit 2c8663f

Please sign in to comment.