Peter Selinger
2007-Oct-31 14:29 UTC
[Nut-upsdev] NUT usbhid -- trying to write USB (sub)drivers
Hi Rok, I retired from working on NUT a few months ago, so I don't have the most up-to-date info. But the guys on the nut-upsdev mailing list (cc'd above) are very helpful. Both of your devices (or nearly identical ones) have been seen on the mailing lists before. The Sweex was first mentioned in a message by Eli Wapniarski on 14 Jun 2006 on nut-upsuser, and was most recently discussed in a message by Peter van Valderen on 20 May 2007 on nut-upsdev. The PowerMust device was discussed by Carlos Rodrigues on the nut-upsdev list on Fri, 14 Apr 2006, and by Guillaume JAOUEN on nut-upsdev near 16 Feb 2007. Note that these devices may be packaged under a different name, but it's still likely the same device. As far as I remember, the Sweex uses an unknown protocol, and the PowerMust probably is (or can be) supported by the megatec_usb driver. Neither device uses the HID protocol, and therefore neither will be supportable by a usbhid-ups subdriver. -- Peter Rok =?utf-8?q?Pape=C5=BE?= wrote:> > Hello Peter. > > I've noticed that 2 of my UPSes: > 1. PowerMust 800 USB, 800VA > 2. Sweex PP100, 1000VA > ... are not supported in NUT. > > I've found your nice document on writing USB subdriver and > decided to give it a go. The NUT version I'm using is a > development from the SVN trunk. > > My ups.conf has the following entries: > > [PowerMust_800_USB] > driver = usbhid-ups > port = auto > vendorid = 06da > > [sweex_PP100] > driver = usbhid-ups > port = auto > vendorid = 0925 > > I needed to add those becouse the 'auto' command seems not > to be supported in the SVN trunk version. > trunk]$ svn update > At revision 1150. > > My C coding skills have been neglected lately so I've decided > to give it a try at writing a (sub)driver for these two > UPSes. From the appended output I think that a simple > sub-driver for usbhid won't do the trick :((. > > Could you please give me some advices/RTFM pointers > on how to tackle these devices ? I do have Windows XP > software for them and the USB Snoopy caught some trash > from them but my USB skills are somewhere around zero ;). > > I'm OK with C, C++. Know a bit about driver development > but never did any work for NUT or USB devices, so > any advice is very welcomed. > > ====================================================> Sweex PP100 is reported as: > ================> # cat lsusb > > Bus 001 Device 004: ID 0925:1234 Lakeview Research > Device Descriptor: > bLength 18 > bDescriptorType 1 > bcdUSB 1.10 > bDeviceClass 0 (Defined at Interface level) > bDeviceSubClass 0 > bDeviceProtocol 0 > bMaxPacketSize0 8 > idVendor 0x0925 Lakeview Research > idProduct 0x1234 > bcdDevice 0.01 > iManufacturer 1 ? > iProduct 2 UPS USB MON V1.4 > iSerial 0 > bNumConfigurations 1 > Configuration Descriptor: > bLength 9 > bDescriptorType 2 > wTotalLength 34 > bNumInterfaces 1 > bConfigurationValue 1 > iConfiguration 0 > bmAttributes 0x80 > MaxPower 100mA > Interface Descriptor: > bLength 9 > bDescriptorType 4 > bInterfaceNumber 0 > bAlternateSetting 0 > bNumEndpoints 1 > bInterfaceClass 3 Human Interface Devices > bInterfaceSubClass 0 No Subclass > bInterfaceProtocol 0 None > iInterface 0 > HID Device Descriptor: > bLength 9 > bDescriptorType 33 > bcdHID 1.00 > bCountryCode 0 Not supported > bNumDescriptors 1 > bDescriptorType 34 Report > wDescriptorLength 78 > Report Descriptors: > ** UNAVAILABLE ** > Endpoint Descriptor: > bLength 7 > bDescriptorType 5 > bEndpointAddress 0x81 EP 1 IN > bmAttributes 3 > Transfer Type Interrupt > Synch Type None > Usage Type Data > wMaxPacketSize 0x0006 1x 6 bytes > bInterval 1 > > > /opt/nut/bin/usbhid-ups -u root -DD -x explore -x vendorid=0925 -a sweex_PP100 > > debug level is '2' > upsdrv_initups... > Checking device (0925/1234) (001/007) > - VendorID: 0925 > - ProductID: 1234 > - Manufacturer: ? > - Product: UPS USB MON V1.4 > - Serial Number: unknown > - Bus: 001 > Trying to match device > Device matches > HID descriptor length 78 > Report Descriptor size = 78 > Using subdriver: EXPLORE HID 0.1 > Path: ffa00001.ffa00002.ffa10003, Type: Input, ReportID: 0x00, Offset: 0, Size: 8, Value: 0.000000 > Path: ffa00001.ffa00002.ffa10004, Type: Input, ReportID: 0x00, Offset: 0, Size: 8, Value: 0.000000 > Path: ffa00001.ffa00002.ffa10005, Type: Input, ReportID: 0x00, Offset: 0, Size: 8, Value: 0.000000 > Path: ffa00001.ffa00002.ffa10006, Type: Input, ReportID: 0x00, Offset: 0, Size: 8, Value: 0.000000 > Path: ffa00001.ffa00002.ffa10007, Type: Input, ReportID: 0x00, Offset: 0, Size: 8, Value: 0.000000 > Path: ffa00001.ffa00002.ffa10008, Type: Input, ReportID: 0x00, Offset: 0, Size: 8, Value: 0.000000 > Path: ffa00001.ffa00002.ffa10009, Type: Output, ReportID: 0x00, Offset: 0, Size: 8, Value: 0.000000 > Path: ffa00001.ffa00002.ffa1000a, Type: Output, ReportID: 0x00, Offset: 0, Size: 8, Value: 0.000000 > Path: ffa00001.ffa00002.ffa1000b, Type: Output, ReportID: 0x00, Offset: 0, Size: 8, Value: 0.000000 > Path: ffa00001.ffa00002.ffa1000c, Type: Output, ReportID: 0x00, Offset: 0, Size: 8, Value: 0.000000 > Network UPS Tools: 0.29 USB communication driver - core 0.32 (2.3.0-1150) > > Report descriptor retrieved (Reportlen = 78) > =46ound HID device > Detected a UPS: ?/UPS USB MON V1.4 > upsdrv_initinfo... > upsdrv_updateinfo... > Quick update... > dstate_init: sock /var/state/ups/usbhid-ups-sweex_PP100 open on fd 5 > upsdrv_updateinfo... > Quick update... > upsdrv_updateinfo... > Quick update... > Signal 2: exiting > upsdrv_cleanup... > > [This keeps repeating to infinity so I Ctrl+C] > > The Values stay the same no matter if I turn UPS on/off or > have it on mains or on battery. UPS comes with some dumb > Windows software which can only tell as much > as a contact closure device: on mains, on batter, battery low. > ==================================================> PowerMust 8000 USB is reported as: > ====================> # cat lsusb > > Bus 001 Device 005: ID 06da:0003 Phoenixtec Power Co., Ltd > Device Descriptor: > bLength 18 > bDescriptorType 1 > bcdUSB 1.10 > bDeviceClass 0 (Defined at Interface level) > bDeviceSubClass 0 > bDeviceProtocol 0 > bMaxPacketSize0 8 > idVendor 0x06da Phoenixtec Power Co., Ltd > idProduct 0x0003 > bcdDevice 4.00 > iManufacturer 3 > iProduct 1 USB UPS > iSerial 0 > bNumConfigurations 1 > Configuration Descriptor: > bLength 9 > bDescriptorType 2 > wTotalLength 34 > bNumInterfaces 1 > bConfigurationValue 1 > iConfiguration 0 > bmAttributes 0xa0 > Remote Wakeup > MaxPower 100mA > Interface Descriptor: > bLength 9 > bDescriptorType 4 > bInterfaceNumber 0 > bAlternateSetting 0 > bNumEndpoints 1 > bInterfaceClass 3 Human Interface Devices > bInterfaceSubClass 0 No Subclass > bInterfaceProtocol 0 None > iInterface 0 > HID Device Descriptor: > bLength 9 > bDescriptorType 33 > bcdHID 1.11 > bCountryCode 0 Not supported > bNumDescriptors 1 > bDescriptorType 34 Report > wDescriptorLength 27 > Report Descriptors: > ** UNAVAILABLE ** > Endpoint Descriptor: > bLength 7 > bDescriptorType 5 > bEndpointAddress 0x81 EP 1 IN > bmAttributes 3 > Transfer Type Interrupt > Synch Type None > Usage Type Data > wMaxPacketSize 0x0008 1x 8 bytes > bInterval 20 > > # /opt/nut/bin/usbhid-ups -u root -DD -x explore -x vendorid=0925 -a PowerMust_800_USB > Network UPS Tools: 0.29 USB communication driver - core 0.32 (2.3.0-1150) > > debug level is '2' > upsdrv_initups... > Checking device (06DA/0003) (001/008) > - VendorID: 06da > - ProductID: 0003 > - Manufacturer: OMRON > - Product: USB UPS > - Serial Number: unknown > - Bus: 001 > Trying to match device > Device matches > HID descriptor length 27 > Report Descriptor size = 27 > Using subdriver: EXPLORE HID 0.1 > Can't retrieve Report 0: Broken pipe > Path: ff000001.ff000002, Type: Input, ReportID: 0x00, Offset: 0, Size: 8 > Can't retrieve Report 0: Broken pipe > Path: ff000001.ff000002, Type: Output, ReportID: 0x00, Offset: 0, Size: 8 > Report descriptor retrieved (Reportlen = 27) > =46ound HID device > Detected a UPS: OMRON/USB UPS > upsdrv_initinfo... > upsdrv_updateinfo... > Quick update... > dstate_init: sock /var/state/ups/usbhid-ups-PowerMust_800_USB open on fd 5 > upsdrv_updateinfo... > Quick update... > upsdrv_updateinfo... > Quick update... > upsdrv_updateinfo... > Quick update... > Signal 2: exiting > upsdrv_cleanup... > [Ctrl+C] > > This one doesn't even display path. > > -- > best regards, > Rok Pape=C5=BE. >