View | Details | Raw Unified | Return to bug 249041 | Differences between
and this patch

Collapse All | Expand All

(-)sysutils/apcupsd/Makefile (-2 / +5 lines)
Lines 3-9 Link Here
3
3
4
PORTNAME=	apcupsd
4
PORTNAME=	apcupsd
5
PORTVERSION=	3.14.14
5
PORTVERSION=	3.14.14
6
PORTREVISION=	3
6
PORTREVISION=	4
7
CATEGORIES=	sysutils
7
CATEGORIES=	sysutils
8
MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}%20-%20Stable/${PORTVERSION}
8
MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}%20-%20Stable/${PORTVERSION}
9
9
Lines 31-37 Link Here
31
31
32
OPTIONS_DEFINE=	APCDUMB_DRV APCSMART_DRV CGI CLIENT_ONLY GAPCMON MODBUS \
32
OPTIONS_DEFINE=	APCDUMB_DRV APCSMART_DRV CGI CLIENT_ONLY GAPCMON MODBUS \
33
		MODBUS_USB PCNET_DRV SHUTDOWN_POWEROFF SNMP_DRV SNMP_DRV_OLD \
33
		MODBUS_USB PCNET_DRV SHUTDOWN_POWEROFF SNMP_DRV SNMP_DRV_OLD \
34
		TCP_WRAPPERS TEST_DRV USB_DRV
34
		TCP_WRAPPERS TEST_DRV USB_DRV USB_REPORTING
35
OPTIONS_DEFAULT=	APCDUMB_DRV APCSMART_DRV MODBUS MODBUS_USB PCNET_DRV \
35
OPTIONS_DEFAULT=	APCDUMB_DRV APCSMART_DRV MODBUS MODBUS_USB PCNET_DRV \
36
		SNMP_DRV TCP_WRAPPERS USB_DRV
36
		SNMP_DRV TCP_WRAPPERS USB_DRV
37
OPTIONS_SUB=	yes
37
OPTIONS_SUB=	yes
Lines 50-55 Link Here
50
TCP_WRAPPERS_DESC=	${LIBWRAP_DESC}
50
TCP_WRAPPERS_DESC=	${LIBWRAP_DESC}
51
TEST_DRV_DESC=		Test driver support
51
TEST_DRV_DESC=		Test driver support
52
USB_DRV_DESC=		USB driver support
52
USB_DRV_DESC=		USB driver support
53
USB_REPORTING_DESC=	Experimental patch for faulty USB reporting
53
54
54
APCDUMB_DRV_CONFIGURE_ENABLE=	dumb
55
APCDUMB_DRV_CONFIGURE_ENABLE=	dumb
55
APCSMART_DRV_CONFIGURE_ENABLE=	apcsmart
56
APCSMART_DRV_CONFIGURE_ENABLE=	apcsmart
Lines 75-80 Link Here
75
TEST_DRV_CONFIGURE_ENABLE=	test
76
TEST_DRV_CONFIGURE_ENABLE=	test
76
USB_DRV_CONFIGURE_ENABLE=	usb
77
USB_DRV_CONFIGURE_ENABLE=	usb
77
78
79
USB_REPORTING_EXTRA_PATCHES=	${PATCHDIR}/extra-patch-usb-reporting
80
78
.include <bsd.port.options.mk>
81
.include <bsd.port.options.mk>
79
82
80
post-patch-SHUTDOWN_POWEROFF-on:
83
post-patch-SHUTDOWN_POWEROFF-on:
(-)sysutils/apcupsd/files/extra-patch-usb-reporting (+51 lines)
Added Link Here
1
--- include/HidUps.h.orig	2015-02-08 18:00:05 UTC
2
+++ include/HidUps.h
3
@@ -107,6 +107,7 @@ class HidUps (private)
4
    /* Fetch a descriptor from an interface (as opposed to from the device) */
5
    int GetIntfDescr(
6
       unsigned char type, unsigned char index, void *buf, int size);
7
+   int GetIntfDescrLength(unsigned char index);
8
 
9
    bool init_device(struct usb_device *dev, const char *serno);
10
 
11
--- src/libusbhid/HidUps.cpp.orig	2015-02-08 18:00:05 UTC
12
+++ src/libusbhid/HidUps.cpp
13
@@ -244,6 +244,26 @@ int HidUps::GetIntfDescr(
14
                          (type << 8) + index, 0, (char*)buf, size, 1000);
15
 }
16
 
17
+/* Get the interface descriptor's length */
18
+int HidUps::GetIntfDescrLength(unsigned char index)
19
+{
20
+   /* usb_hid_descriptor  */
21
+   char buf[9];
22
+   memset(buf, 0, sizeof(buf));
23
+   int ret = usb_control_msg(_fd, USB_ENDPOINT_IN | USB_RECIP_INTERFACE,
24
+                            USB_REQ_GET_DESCRIPTOR,
25
+                            (USB_DT_HID << 8) + index, 0, (char*)buf, sizeof(buf), 1000);
26
+   
27
+   int len = MAX_SANE_DESCRIPTOR_LEN;
28
+   if (ret >= 0) {
29
+      /* wDescriptorLength */
30
+      int desclen = buf[7] | (buf[8] << 8);
31
+      if (desclen > 0)
32
+         len = desclen;
33
+   }
34
+   return len;
35
+}
36
+
37
 /*
38
  * Fetch the report descriptor from the device given an _fd for the
39
  * device's control endpoint. Descriptor length is written to the
40
@@ -255,8 +275,9 @@ unsigned char *HidUps::FetchReportDescr(int *rlen)
41
    unsigned char *ptr;
42
    int rdesclen;
43
 
44
-   ptr = (unsigned char*)malloc(MAX_SANE_DESCRIPTOR_LEN);
45
-   rdesclen = GetIntfDescr(USB_DT_REPORT, 0, ptr, MAX_SANE_DESCRIPTOR_LEN);
46
+   int desclen = GetIntfDescrLength(0);
47
+   ptr = (unsigned char*)malloc(desclen);
48
+   rdesclen = GetIntfDescr(USB_DT_REPORT, 0, ptr, desclen);
49
    if (rdesclen <= 0) {
50
       Dmsg(100, "Unable to get REPORT descriptor (%d).\n", rdesclen);
51
       free(ptr);
(-)sysutils/apcupsd/files/pkg-message.in (+4 lines)
Lines 18-23 Link Here
18
Please, read its man page, and if this is not the intended behavior you want,
18
Please, read its man page, and if this is not the intended behavior you want,
19
change it accordingly.
19
change it accordingly.
20
20
21
If connected via USB and apcaccess reports incomplete data consider enabling
22
the USB_REPORTING options via 'make config'.  This contains an experimental
23
patch that may fix some USB attach APC UPS.
24
21
In some systems where the shutdown can take a while (like in bhyve environment),
25
In some systems where the shutdown can take a while (like in bhyve environment),
22
you may want to change this behavior as follows:
26
you may want to change this behavior as follows:
23
27

Return to bug 249041