Lines 561-569
static int phoenix_command(const char *cmd, char *buf, size_t buflen)
Link Here
|
561 |
* In order to read correct replies we need to flush the output buffers of the converter until we get no more data (ie, it times out). */ |
561 |
* In order to read correct replies we need to flush the output buffers of the converter until we get no more data (ie, it times out). */ |
562 |
switch (ret) |
562 |
switch (ret) |
563 |
{ |
563 |
{ |
564 |
case -EPIPE: /* Broken pipe */ |
564 |
case LIBUSB_ERROR_PIPE: /* Broken pipe */ |
565 |
usb_clear_halt(udev, 0x81); |
565 |
usb_clear_halt(udev, 0x81); |
566 |
case -ETIMEDOUT: /* Connection timed out */ |
566 |
case LIBUSB_ERROR_TIMEOUT: /* Connection timed out */ |
567 |
break; |
567 |
break; |
568 |
} |
568 |
} |
569 |
|
569 |
|
Lines 635-641
static int ippon_command(const char *cmd, char *buf, size_t buflen)
Link Here
|
635 |
ret = usb_control_msg(udev, USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE, 0x09, 0x2, 0, &tmp[i], 8, 1000); |
635 |
ret = usb_control_msg(udev, USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE, 0x09, 0x2, 0, &tmp[i], 8, 1000); |
636 |
|
636 |
|
637 |
if (ret <= 0) { |
637 |
if (ret <= 0) { |
638 |
upsdebugx(3, "send: %s (%d)", (ret != -ETIMEDOUT) ? usb_strerror() : "Connection timed out", ret); |
638 |
upsdebugx(3, "send: %s (%d)", (ret != LIBUSB_ERROR_TIMEOUT) ? usb_strerror() : "Connection timed out", ret); |
639 |
return ret; |
639 |
return ret; |
640 |
} |
640 |
} |
641 |
|
641 |
|
Lines 648-654
static int ippon_command(const char *cmd, char *buf, size_t buflen)
Link Here
|
648 |
|
648 |
|
649 |
/* Any errors here mean that we are unable to read a reply (which will happen after successfully writing a command to the UPS) */ |
649 |
/* Any errors here mean that we are unable to read a reply (which will happen after successfully writing a command to the UPS) */ |
650 |
if (ret <= 0) { |
650 |
if (ret <= 0) { |
651 |
upsdebugx(3, "read: %s (%d)", (ret != -ETIMEDOUT) ? usb_strerror() : "Connection timed out", ret); |
651 |
upsdebugx(3, "read: %s (%d)", (ret != LIBUSB_ERROR_TIMEOUT) ? usb_strerror() : "Connection timed out", ret); |
652 |
return ret; |
652 |
return ret; |
653 |
} |
653 |
} |
654 |
|
654 |
|
Lines 2124-2161
static int qx_command(const char *cmd, char *buf, size_t buflen)
Link Here
|
2124 |
|
2124 |
|
2125 |
switch (ret) |
2125 |
switch (ret) |
2126 |
{ |
2126 |
{ |
2127 |
case -EBUSY: /* Device or resource busy */ |
2127 |
case LIBUSB_ERROR_BUSY: /* Device or resource busy */ |
2128 |
fatal_with_errno(EXIT_FAILURE, "Got disconnected by another driver"); |
2128 |
fatal_with_errno(EXIT_FAILURE, "Got disconnected by another driver"); |
2129 |
|
2129 |
|
2130 |
case -EPERM: /* Operation not permitted */ |
2130 |
case LIBUSB_ERROR_PIPE: /* Broken pipe */ |
2131 |
fatal_with_errno(EXIT_FAILURE, "Permissions problem"); |
|
|
2132 |
|
2133 |
case -EPIPE: /* Broken pipe */ |
2134 |
if (usb_clear_halt(udev, 0x81) == 0) { |
2131 |
if (usb_clear_halt(udev, 0x81) == 0) { |
2135 |
upsdebugx(1, "Stall condition cleared"); |
2132 |
upsdebugx(1, "Stall condition cleared"); |
2136 |
break; |
2133 |
break; |
2137 |
} |
2134 |
} |
2138 |
#ifdef ETIME |
|
|
2139 |
case -ETIME: /* Timer expired */ |
2140 |
#endif /* ETIME */ |
2141 |
if (usb_reset(udev) == 0) { |
2135 |
if (usb_reset(udev) == 0) { |
2142 |
upsdebugx(1, "Device reset handled"); |
2136 |
upsdebugx(1, "Device reset handled"); |
2143 |
} |
2137 |
} |
2144 |
case -ENODEV: /* No such device */ |
2138 |
case LIBUSB_ERROR_NO_DEVICE: /* No such device */ |
2145 |
case -EACCES: /* Permission denied */ |
2139 |
case LIBUSB_ERROR_ACCESS: /* Permission denied */ |
2146 |
case -EIO: /* I/O error */ |
2140 |
case LIBUSB_ERROR_IO: /* I/O error */ |
2147 |
case -ENXIO: /* No such device or address */ |
2141 |
case LIBUSB_ERROR_NOT_FOUND: /* No such file or directory */ |
2148 |
case -ENOENT: /* No such file or directory */ |
|
|
2149 |
/* Uh oh, got to reconnect! */ |
2142 |
/* Uh oh, got to reconnect! */ |
2150 |
usb->close(udev); |
2143 |
usb->close(udev); |
2151 |
udev = NULL; |
2144 |
udev = NULL; |
2152 |
break; |
2145 |
break; |
2153 |
|
2146 |
|
2154 |
case -ETIMEDOUT: /* Connection timed out */ |
2147 |
case LIBUSB_ERROR_TIMEOUT: /* Connection timed out */ |
2155 |
case -EOVERFLOW: /* Value too large for defined data type */ |
2148 |
case LIBUSB_ERROR_OVERFLOW: /* Value too large for defined data type */ |
2156 |
#ifdef EPROTO |
|
|
2157 |
case -EPROTO: /* Protocol error */ |
2158 |
#endif |
2159 |
default: |
2149 |
default: |
2160 |
break; |
2150 |
break; |
2161 |
} |
2151 |
} |