diff --git a/NEWS.adoc b/NEWS.adoc index 4653a34e14..00c11d8fec 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -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] diff --git a/drivers/apc_modbus.c b/drivers/apc_modbus.c index 8e5ea3653d..3e9d6537af 100644 --- a/drivers/apc_modbus.c +++ b/drivers/apc_modbus.c @@ -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;