arduino-libraries / Arduino_USBHostMbed5

Apache License 2.0
4 stars 10 forks source link

Way to retrieve the standard descriptor strings: Manufacturer, Product, Serial number #37

Open KurtE opened 9 months ago

KurtE commented 9 months ago

There are times, when a sketch may want to be have access to the information about what device is actually connected to their board. For example, suppose your sketch is setup to maybe handle two USBSerial objects, and both are connected. You may wish to query the Serial number to know which one is which....

For what is worth the USBHostGiga library appears to at least read them in and log them... Not sure yet if they are easily available to the user object...

But I believe with this library, the code does not even look at the indexes contained within the device descriptor. So it might be a little more problematic.

Might experiment with sketch code to see if I can ask to read the device descriptor again, and parse it myself, and then make a version of the Query Descriptor code that reads in strings.

KurtE commented 9 months ago

I added the code to my github project for maybe some USBHost classes, in this case for USB To Serial Adapters. https://github.com/KurtE/GIGA_USBHostMBed5_devices/blob/main/src/USBHostSerialDevice.cpp#L415-L509

You might want to consider adding similar to stuff to this library.

Also wish that maybe there was some base class, that most of your devices are derived from, that maybe have some basic standard methods, like to get these three strings, the product id, vendor id, etc...