[Nut-upsuser] Junda-tech

Louis LSJ Krüger zr6abc at gmail.com
Sat Oct 21 21:54:25 UTC 2017


Sorry for the late reply, I've first used the incorrect sending address.

On 17/10/17 15:15, Charles Lepple wrote:
> On Oct 17, 2017, at 8:48 AM, LLSJ Krüger <llsjk at lakruger.za.org> wrote:
>> Results of 'lsusb -vvv -d 3344:'
> [...]
>>           wDescriptorLength     136
>>          Report Descriptors:
>>            ** UNAVAILABLE **
>>
> Can you please re-run lsusb, possibly as root, to grab the contents of the "Report Descriptors" section? 

Bus 003 Device 003: ID 3344:0025 Leaguer Microelectronics (LME)
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x3344 Leaguer Microelectronics (LME)
  idProduct          0x0025
  bcdDevice            0.01
  iManufacturer           3 (error)
  iProduct                4 HID-UPS
  iSerial                 2 JD09U04
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           34
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.00
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     136
          Report Descriptor: (length is 136)
            Item(Global): Usage Page, data= [ 0x84 ] 132
                            Power Device Page
            Item(Local ): Usage, data= [ 0x04 ] 4
                            UPS
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Local ): Usage, data= [ 0x24 ] 36
                            Power Summary
            Item(Main  ): Collection, data= [ 0x02 ] 2
                            Logical
            Item(Global): Report ID, data= [ 0x01 ] 1
            Item(Local ): Usage, data= [ 0xfd ] 253
                            iManufacturer
            Item(Local ): String Index, data= [ 0x01 ] 1
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Report Count, data= [ 0x01 ] 1
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
            Item(Main  ): Feature, data= [ 0x22 ] 34
                            Data Variable Absolute No_Wrap Linear
                            No_Preferred_State No_Null_Position
Non_Volatile Bitfield
            Item(Global): Report ID, data= [ 0x02 ] 2
            Item(Local ): Usage, data= [ 0xfe ] 254
                            iProduct
            Item(Local ): String Index, data= [ 0x02 ] 2
            Item(Main  ): Feature, data= [ 0x22 ] 34
                            Data Variable Absolute No_Wrap Linear
                            No_Preferred_State No_Null_Position
Non_Volatile Bitfield
            Item(Global): Report ID, data= [ 0x03 ] 3
            Item(Local ): Usage, data= [ 0xff ] 255
                            iSerialNumber
            Item(Local ): String Index, data= [ 0x03 ] 3
            Item(Main  ): Feature, data= [ 0x22 ] 34
                            Data Variable Absolute No_Wrap Linear
                            No_Preferred_State No_Null_Position
Non_Volatile Bitfield
            Item(Global): Usage Page, data= [ 0x85 ] 133
                            Battery System Page
            Item(Global): Report ID, data= [ 0x06 ] 6
            Item(Local ): Usage, data= [ 0x8b ] 139
                            Rechargeable
            Item(Main  ): Feature, data= [ 0x22 ] 34
                            Data Variable Absolute No_Wrap Linear
                            No_Preferred_State No_Null_Position
Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x2c ] 44
                            Capacity Mode
            Item(Main  ): Feature, data= [ 0x22 ] 34
                            Data Variable Absolute No_Wrap Linear
                            No_Preferred_State No_Null_Position
Non_Volatile Bitfield
            Item(Global): Report ID, data= [ 0x04 ] 4
            Item(Local ): Usage, data= [ 0x83 ] 131
                            Design Capacity
            Item(Global): Logical Maximum, data= [ 0x64 ] 100
            Item(Main  ): Feature, data= [ 0x22 ] 34
                            Data Variable Absolute No_Wrap Linear
                            No_Preferred_State No_Null_Position
Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x67 ] 103
                            Full Charge Capacity
            Item(Main  ): Feature, data= [ 0x22 ] 34
                            Data Variable Absolute No_Wrap Linear
                            No_Preferred_State No_Null_Position
Non_Volatile Bitfield
            Item(Global): Report ID, data= [ 0x05 ] 5
            Item(Local ): Usage, data= [ 0x66 ] 102
                            Remaining Capacity
            Item(Main  ): Input, data= [ 0x22 ] 34
                            Data Variable Absolute No_Wrap Linear
                            No_Preferred_State No_Null_Position
Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x66 ] 102
                            Remaining Capacity
            Item(Main  ): Feature, data= [ 0xa2 ] 162
                            Data Variable Absolute No_Wrap Linear
                            No_Preferred_State No_Null_Position Volatile
Bitfield
            Item(Global): Usage Page, data= [ 0x84 ] 132
                            Power Device Page
            Item(Local ): Usage, data= [ 0x02 ] 2
                            Present Status
            Item(Main  ): Collection, data= [ 0x02 ] 2
                            Logical
            Item(Global): Usage Page, data= [ 0x85 ] 133
                            Battery System Page
            Item(Global): Report ID, data= [ 0x07 ] 7
            Item(Local ): Usage, data= [ 0xd0 ] 208
                            AC Present
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0x01 ] 1
            Item(Global): Report Size, data= [ 0x01 ] 1
            Item(Global): Report Count, data= [ 0x01 ] 1
            Item(Main  ): Input, data= [ 0xa2 ] 162
                            Data Variable Absolute No_Wrap Linear
                            No_Preferred_State No_Null_Position Volatile
Bitfield
            Item(Local ): Usage, data= [ 0x44 ] 68
                            Charging
            Item(Main  ): Input, data= [ 0xa2 ] 162
                            Data Variable Absolute No_Wrap Linear
                            No_Preferred_State No_Null_Position Volatile
Bitfield
            Item(Local ): Usage, data= [ 0x45 ] 69
                            Discharging
            Item(Global): Report Count, data= [ 0x06 ] 6
            Item(Main  ): Input, data= [ 0xa2 ] 162
                            Data Variable Absolute No_Wrap Linear
                            No_Preferred_State No_Null_Position Volatile
Bitfield
            Item(Global): Report ID, data= [ 0x08 ] 8
            Item(Local ): Usage, data= [ 0xd0 ] 208
                            AC Present
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0x01 ] 1
            Item(Global): Report Size, data= [ 0x01 ] 1
            Item(Global): Report Count, data= [ 0x01 ] 1
            Item(Main  ): Feature, data= [ 0xa2 ] 162
                            Data Variable Absolute No_Wrap Linear
                            No_Preferred_State No_Null_Position Volatile
Bitfield
            Item(Local ): Usage, data= [ 0x44 ] 68
                            Charging
            Item(Main  ): Feature, data= [ 0xa2 ] 162
                            Data Variable Absolute No_Wrap Linear
                            No_Preferred_State No_Null_Position Volatile
Bitfield
            Item(Local ): Usage, data= [ 0x45 ] 69
                            Discharging
            Item(Global): Report Count, data= [ 0x06 ] 6
            Item(Main  ): Feature, data= [ 0xa2 ] 162
                            Data Variable Absolute No_Wrap Linear
                            No_Preferred_State No_Null_Position Volatile
Bitfield
            Item(Main  ): End Collection, data=none
            Item(Main  ): End Collection, data=none
            Item(Main  ): End Collection, data=none
      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               1
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
  (Bus Powered)
>
> (Running "usbhid-ups" should have detached the kernel driver already, which should allow lsusb to retrieve that descriptor -- but if you have disconnected+reconnected the USB cable since testing, you will need to re-run "usbhid-ups" before "lsusb".)

>> ran usbhid-ups -DDDD -u root -x explore -x vendorid=3344 -x port=auto -a
>> myups >& /tmp/junda-tech.txt
>>
>> and then
>>
>> gen-usbhid-subdriver.sh < /tmp/junda-tech.txt' :
>>
> [...]
>> /* --------------------------------------------------------------- */
>> /* HID2NUT lookup table                                            */
>> /* --------------------------------------------------------------- */
>>
>> static hid_info_t jundatech_hid2nut[] = {
>>
>>   { "unmapped.ups.powersummary.capacitymode", 0, 0,
>> "UPS.PowerSummary.CapacityMode", NULL, "%.0f", 0, NULL },
>>   { "unmapped.ups.powersummary.designcapacity", 0, 0,
>> "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", 0, NULL },
>>   { "unmapped.ups.powersummary.fullchargecapacity", 0, 0,
>> "UPS.PowerSummary.FullChargeCapacity", NULL, "%.0f", 0, NULL },
>>   { "unmapped.ups.powersummary.presentstatus.acpresent", 0, 0,
>> "UPS.PowerSummary.PresentStatus.ACPresent", NULL, "%.0f", 0, NULL },
>>   { "unmapped.ups.powersummary.presentstatus.charging", 0, 0,
>> "UPS.PowerSummary.PresentStatus.Charging", NULL, "%.0f", 0, NULL },
>>   { "unmapped.ups.powersummary.presentstatus.discharging", 0, 0,
>> "UPS.PowerSummary.PresentStatus.Discharging", NULL, "%.0f", 0, NULL },
>>   { "unmapped.ups.powersummary.rechargeable", 0, 0,
>> "UPS.PowerSummary.Rechargeable", NULL, "%.0f", 0, NULL },
>>   { "unmapped.ups.powersummary.remainingcapacity", 0, 0,
>> "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", 0, NULL },
>>   { "unmapped.ups.powersummary.imanufacturer", 0, 0,
>> "UPS.PowerSummary.iManufacturer", NULL, "%.0f", 0, NULL },
>>   { "unmapped.ups.powersummary.iproduct", 0, 0,
>> "UPS.PowerSummary.iProduct", NULL, "%.0f", 0, NULL },
>>   { "unmapped.ups.powersummary.iserialnumber", 0, 0,
>> "UPS.PowerSummary.iSerialNumber", NULL, "%.0f", 0, NULL },
> This part looks promising - the UPS appears to implement a portion of the HID Power Device Class specification, rather than just being a HID-enabled USB-to-serial adapter.
>
> In the generated code, the capitalized names are HID PDC names, which you can search for in the nut/drivers/ directory to see how other vendors use them. The script just maps them to generic numbers, but the values are most useful if mapped to proper types. For instance:
>
> $ git grep UPS.PowerSummary.PresentStatus.ACPresent
>
> drivers/apc-hid.c:  { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info },
>
> drivers/belkin-hid.c:  { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, liebert_online_info },
>
> ...
>
> This indicates that the APC models tend to follow the spec, but that we had to add a custom mapping function for Belkin/Liebert since their boolean True value is often 1e-7 instead of 1.
>
> I would recommend checking the values to make sure that they match the labels, but static attributes such as CapacityMode, DesignCapacity, FullChargeCapacity and Rechargeable can get a HU_FLAG_STATIC or HU_FLAG_SEMI_STATIC flag (see drivers/usbhid-ups.h) so that the driver does not waste time polling them. Some values like iManufacturer, iProduct and iSerialNumber are likely duplicates of the values in the USB device descriptor, and do not need to be included.
>
Tnx. It is a lot of digging for me, but I will attempt it.




More information about the Nut-upsuser mailing list