ports/sysutils/nut/files/patch-drivers_tripplite__usb.c
Cy Schubert 311484254a Nut USB drivers report a "permission error" without visible reasons
for the error even though permissions are OK (or the driver is run
as root).

Nut uses libusb-0.1 API, assuming return cods of < 0. FreeBSD provides
a libusb-0.1 wrapper howerver it uses libusb-1.0 error codes (which
are negative). This set of patches "teaches" nut libusb-1.0 error codes
as produced by FreeBSD.

Network UPS Tools (networkupstools.org) has a project to use libusb-1.0.
This commit is a stopgap fix until our upline implments lubusb-1.0
support in nut.

PR:		223117
Submitted by:	lev
2017-10-20 01:09:12 +00:00

20 lines
735 B
C

--- drivers/tripplite_usb.c.orig 2015-12-29 12:08:34 UTC
+++ drivers/tripplite_usb.c
@@ -499,7 +499,7 @@ void usb_comm_fail(int res, const char *msg)
static int try = 0;
switch(res) {
- case -EBUSY:
+ case LIBUSB_ERROR_BUSY:
upslogx(LOG_WARNING, "%s: Device claimed by another process", msg);
fatalx(EXIT_FAILURE, "Terminating: EBUSY");
break;
@@ -907,7 +907,7 @@ void upsdrv_initinfo(void)
if(tl_model != TRIPP_LITE_SMARTPRO ) {
ret = send_cmd(w_msg, sizeof(w_msg), w_value, sizeof(w_value)-1);
if(ret <= 0) {
- if(ret == -EPIPE) {
+ if(ret == LIBUSB_ERROR_PIPE) {
fatalx(EXIT_FAILURE, "Could not reset watchdog. Please check and"
"see if usbhid-ups(8) works with this UPS.");
} else {