Skip to content

Commit

Permalink
fixup! driver/*.c: report reconnection attempts as a "driver.state" [n…
Browse files Browse the repository at this point in the history
  • Loading branch information
jimklimov committed Jan 5, 2023
1 parent 3a3deee commit 771d66d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/richcomm_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,11 +638,13 @@ void upsdrv_updateinfo(void)
int ret, online, battery_normal;

if (!udev) {
dstate_setinfo("driver.state", "reconnect.trying");
ret = usb_device_open(&udev, &usbdevice, &device_matcher, &driver_callback);

if (ret < 0) {
return;
}
dstate_setinfo("driver.state", "reconnect.updateinfo");
}

ret = query_ups(reply);
Expand All @@ -651,6 +653,7 @@ void upsdrv_updateinfo(void)
usb_comm_fail("Query to UPS failed");
dstate_datastale();

dstate_setinfo("driver.state", "reconnect.trying");
usb_device_close(udev);
udev = NULL;

Expand Down
1 change: 1 addition & 0 deletions drivers/tripplite_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ static void usb_comm_fail(int res, const char *msg)
#endif

default:
dstate_setinfo("driver.state", "reconnect.trying");
upslogx(LOG_WARNING,
"%s: Device detached? (error %d: %s)",
msg, res, nut_usb_strerror(res));
Expand Down
3 changes: 3 additions & 0 deletions drivers/usbhid-ups.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,7 @@ void upsdrv_updateinfo(void)
return;
case LIBUSB_ERROR_IO: /* I/O error */
/* Uh oh, got to reconnect, with a special suggestion! */
dstate_setinfo("driver.state", "reconnect.trying");
interrupt_pipe_EIO_count++;
hd = NULL;
return;
Expand Down Expand Up @@ -1511,11 +1512,13 @@ static bool_t hid_ups_walk(walkmode_t mode)
case LIBUSB_ERROR_NO_MEM: /* Insufficient memory */
fallthrough_reconnect:
/* Uh oh, got to reconnect! */
dstate_setinfo("driver.state", "reconnect.trying");
hd = NULL;
return FALSE;

case LIBUSB_ERROR_IO: /* I/O error */
/* Uh oh, got to reconnect, with a special suggestion! */
dstate_setinfo("driver.state", "reconnect.trying");
interrupt_pipe_EIO_count++;
hd = NULL;
return FALSE;
Expand Down

0 comments on commit 771d66d

Please sign in to comment.