[Nut-upsdev] USB HID Spec help (passing strings)
Charles Lepple
clepple at gmail.com
Mon Aug 31 23:16:35 UTC 2015
On Aug 31, 2015, at 9:01 AM, Rob Groner <rgroner at RTD.com> wrote:
>
> iSerialNumber does not need to be unique per device - it is not very many bits wide.
>
> I’m pretty sure I don’t *need* iSerialNumber…I mean, I could just remove it from the report descriptor altogether. But since it is available to give, and we are writing each board’s serial number into flash as part of the micro-controller programming (we aren’t talking a staggering number of boards per year here), I figured I should try to send the actual serial number.
Right, I was trying to make clear that iSerialNumber can be 3 for every board (or 42 or whatever) even though every board returns a unique string when you request the string indexed by iSerialNumber.
>
> NUT and other tools match against the string returned from the "get string descriptor" request (not iSerialNumber itself - the string indexed by it) and the procedure for modifying that is going to be specific to each USB device controller.
>
> By this do you mean…just simply send the serial number as data (like all other report values) instead of as a string pointer index, and interpret the bytes on the NUT end? I have already written an RTD UPS driver for NUT, so adding a custom function isn’t a problem. I was trying to search through other drivers to find an example of where they passed a string without using the string index method.
No, just as a variable string descriptor.
>
> like PICs make this harder, but there is a C __attribute__ or something that you should be able to use). Otherwise, does your USB framework allow callbacks for arbitrary requests?
>
> Hmm…I’ll admit, I’ve never used __attribute__, and I honestly don’t know enough about how Microchip PIC32’s handle the USB framework to know. I’ll have to research both of those.
And I've never used a PIC32 :-) If it has a flat 32-bit address space, then forget what I said about __attribute__. It would only be for the smaller PICs that use different instructions (and different address spaces) for code and data.
> I wondered if I could somehow set the pointer for the iSerialNumber string index to the address of it in memory (in other words, load it from Flash into a global var, and then use that address when the iSerialNumber pointer is requested), but from how it is implemented, I couldn’t figure it out. I’ll look again.
http://ww1.microchip.com/downloads/en/AppNotes/01176A.pdf <http://ww1.microchip.com/downloads/en/AppNotes/01176A.pdf> has code (Example 6) that allows you to specify a custom function to generate the string descriptor responses. It looks like it should be fairly simple to special-case the serial number descriptor.
--
Charles Lepple
clepple at gmail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/nut-upsdev/attachments/20150831/51ecd25e/attachment-0001.html>
More information about the Nut-upsdev
mailing list