[Nut-upsdev] Powerware PW5115 USB driver
Max E. Kuznecov
mek at mek.uz.ua
Wed Nov 7 17:00:35 UTC 2007
2007/11/7, Kjell Claesson <kjell.claesson at epost.tidanet.se>:
> Can not see that ther is any difference in handling.
>
> Part of the patch:
> ---------------
> void send_write_command(unsigned char *command, int command_length)
> @@ -29,7 +29,7 @@
> /* Add checksum */
> sbuf[command_length] = calc_checksum(sbuf);
> command_length += 1;
> - usb_set_descriptor(upsdev, USB_DT_STRING, 4, sbuf, command_length); /*
> Ignore error */
> + usb_control_msg(upsdev, 0x42, 0x0d, (0x00 << 8) + 0x0, 0, sbuf,
> command_length, 1000);
> }
> ----------------
>
> As you see it calls 'usb_set_descriptor' this is a function in nut_usb.c and
> look like this.
> -------------------------
> int usb_set_descriptor(usb_dev_handle *udev, unsigned char type,
> unsigned char index, void *buf, int size)
> {
> return usb_control_msg(udev, USB_ENDPOINT_OUT, USB_REQ_SET_DESCRIPTOR,
> (type << 8) + index, 0, buf, size, 1000);
> }
> ---------------------------
>
> So the only thing you do is send the command twise.
>
> Maybe Arjen can bring some light into this. As it is a usb (libusb) function.
> And the this is that in your control message you hardcode the
> USB_ENDPOINT_OUT, USB_REQ_SET_DESCRIPTOR, and type.
Well, not exactly, according to usb.h from libusb (and, well, usb
standard) USB_ENDPOINT_OUT is declared as 0x00 and here is 0x42 used
and similarly
USB_REQ_SET_DESCRIPTOR is 0x07 and not 0x0d, that is the point.
I've found neither of 0x42 nor 0x0d in libusb srcs
--
~syhpoon
More information about the Nut-upsdev
mailing list