6
\$\begingroup\$

I would like to identify a USB keyboard uniquely(something equivalent to unique mac-id for the Ethernet cards) on a computer. Does the USB HID profile has a support for such identification ? If so what is the field called ? I understand that VID and PID uniquely identify a make of keyboard from a vendor, but I am looking forward to identifying each keyboard separately.

PS : Asking the question on Elex SE, since I would have to implement this USB profile on AVR32.

\$\endgroup\$
4
  • \$\begingroup\$ Would bus:deviceNumber be an option? To my knowledge the port enumeration is static across reboots. \$\endgroup\$
    – jippie
    May 14, 2013 at 18:59
  • \$\begingroup\$ @jippie you never know if the enumeration order changes during a reboot. Sometimes a device will enumerate as the first device, and sometimes it will be the second or third. \$\endgroup\$
    – Passerby
    May 15, 2013 at 1:57
  • \$\begingroup\$ @Passerby The device number will change, but every USB port on the bus is uniquely identifable. A port on a hub has always the same number. \$\endgroup\$
    – jippie
    May 15, 2013 at 5:23
  • \$\begingroup\$ @PeterMotensen as been pointed out to you countless times in the past, making such utterly petty edits to ancient questions is anything but beneficial. Further, your deletion removed information which as absolutely critical to the question; without that it would appear to refer to an off-the-shelf keyboard, a very different situation than the custom keyboard project the question is actually about. \$\endgroup\$ Jun 15, 2019 at 1:49

2 Answers 2

2
\$\begingroup\$

The USB Serial Number is what you want. And Atmel has a small datasheet on how to implement it with their usb stack here.

Additionally, any of the user configurable USB descriptors could be used. Assuming you are using the same VID/PID pair, you still have the Device Release Number, Manufacturer String Descriptor (Manufacturer Name), Product String Descriptor (Product name), and the Serial Number Descriptor, all of which go into the basic usb device descriptor that is mandatory for any usb device. They are independent of the usb class (HID, CDC, Proprietary etc), all major OS can read them, and can be as unique as you need them to be.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ He's talking about the host side, I think, for use w/ commercial HID products, and not the device side. That's great info on how to use the unique Atmel ID to serialize. \$\endgroup\$ May 14, 2013 at 23:52
  • \$\begingroup\$ But why is that Atmel ID number unique? \$\endgroup\$ May 15, 2013 at 0:04
  • 1
    \$\begingroup\$ @ScottSeidman some atmel microcontrollers have unique ids, so you don't have to generate them code side. It's just a feature they have. For USB-HID, You can use up to any 10 byte variable to make a serial number. The whitesheet has two options for that. The unique ID pulled from the Flash_read_sn(pos) function, which you could replace with your own, or the usb_descriptors.h serial number define. And OP is obviously talking about making a AVR with usb-hid. His device will be a slave, connected to a computer. \$\endgroup\$
    – Passerby
    May 15, 2013 at 1:45
  • \$\begingroup\$ @Passerby are you suggesting putting the Atmel serial number in to HID profile serial number field ? \$\endgroup\$
    – Bleamer
    May 15, 2013 at 7:46
  • \$\begingroup\$ @Bleamer that's a option. But not all amtel devices have a unique serial number. I am simply suggesting to use the serial number field in the usb descriptor. What actual number you use can be arbitrary. \$\endgroup\$
    – Passerby
    May 15, 2013 at 8:59
6
\$\begingroup\$

I think it will vary by manufacturer. There is a serial number field, but many don't fill it in. USBDeview is a free app that will let you peek at all the fields for all the installed devices (http://www.nirsoft.net/utils/usb_devices_view.html). A screen capture for an HID device on my system is attached below. Install it (actually, no need to even unzip, it runs as an executable), and see if there's a unique ID in the devices you're talking about.

enter image description here

\$\endgroup\$
8
  • \$\begingroup\$ Unable to upvote but this thing definitely is in the direction to the answer. Thank you. \$\endgroup\$
    – Bleamer
    May 14, 2013 at 14:51
  • 2
    \$\begingroup\$ Verified my HP keyboard and Logitech mouse both have '0' as serial number. VendorID:productID is unique per product. On Linux the 'lsusb' command reveals the same information. \$\endgroup\$
    – jippie
    May 14, 2013 at 18:56
  • 1
    \$\begingroup\$ VendorID and ProductID SHOULD be unique per product, but everything is sort of up in the air for products without the official USB logo. I can easily see the same PID being used for products within a small company, or different HID devices that use the same hacker-board. Shouldn't be that way, but it might be. Big companies probably pay by the rules. \$\endgroup\$ May 14, 2013 at 19:09
  • \$\begingroup\$ Take the md5 or sha of all (or a subset of) the static properties listed above. If it has a serial number it will be unique. If not, the last plug/unplug date + the other info will tend to make it unique, or at least a close approximation. \$\endgroup\$
    – walrii
    May 15, 2013 at 0:51
  • \$\begingroup\$ @walrii a hash that includes a constantly changing date (or port number or would be useless, as it will never be the same again. You couldn't tell 1 device from 1000 devices, because they would change on every boot. \$\endgroup\$
    – Passerby
    May 15, 2013 at 1:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.