Understanding vid/pid pairs

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
Peter Chaffe
Rank 1
Rank 1
Posts: 20
Joined: Fri Dec 02, 2011 12:25 pm

Understanding vid/pid pairs

Post by Peter Chaffe » Wed Dec 07, 2011 11:44 pm

Hi Gents,

I think I'm grasping some of the usbconfig.h defines, but have a problem here!
As an example I want to use a keyboard.

so;
USB-IDs-for-free.txt suggests preference to using "discrimination by serial number string"
Which makes me think I need to use

discrimination by serial number string:
---------------+---------------+-------------------------------------------
10203 (0x27db) | 5824 (0x16c0) | For USB Keyboards
---------------+---------------+-------------------------------------------

Yet in the statements within usbconfig.h it gives a keyboard example using "discrimination by textual name"

discrimination by textual name:
--------------+---------------+--------------------------------------------
1503 (0x05df) | 5824 (0x16c0) | For generic HID class devices (which are
| | NOT mice, keyboards or joysticks)
--------------+---------------+--------------------------------------------

But as you can see above it expressly says NOT for keyboards etc.

Can anyone shed some light? The vids are the same in both cases but the pids aren't.
Which should I use?


Second question is I don't understand to process to convert either of the above combinations into these hex number pairs?

#define USB_CFG_VENDOR_ID 0x42, 0x42
#define USB_CFG_DEVICE_ID 0x31, 0xe1 (example taken from 1-key-keyboard project)

Any help appreciated!


Edit.................

Think I can answer my own questions!

Q2) I think is someone elses vid/pid pair or just made up! that happens to work...

q1) I have ignored all else and chosen the recomended pair as per "USB-IDs-for-free.txt

10203 (0x27db) | 5824 (0x16c0) | For USB Keyboards

#define USB_CFG_VENDOR_ID 0xc0, 0x16
#define USB_CFG_DEVICE_ID 0xdb, 0x27

and it works fine!

xiangrui
Rank 1
Rank 1
Posts: 30
Joined: Sun Jan 01, 2012 5:19 am

Re: Understanding vid/pid pairs

Post by xiangrui » Wed Dec 26, 2012 8:54 pm

The VID/PID pair won't affect the device, unless they conflict with the existing device. This means, if you set some random numbers for the pair, it normally works fine. For more information about the pair, check the file USB-ID-FAQ.txt in the V-USB package.

I do have a question about the VID/PID pair for the USB keyboard/mice/joystick. V-USB provides shared VID/PID pairs for these device, if they are discriminated by serial number. However, the driver of these device is provided by operating system, and according to USB-IDs-for-free.txt, we can omit the serial number. But why don't the keyboard and mouse examples from V-USB use these pairs, rather use some pairs for demonstration only? Can anyone point out what I missed? Thanks.

-Xiangrui

xiangrui
Rank 1
Rank 1
Posts: 30
Joined: Sun Jan 01, 2012 5:19 am

Re: Understanding vid/pid pairs

Post by xiangrui » Thu Dec 27, 2012 6:07 pm

I read from the file usbconfig.h for HIDkeys examply that "We cannot use Obdev's free shared VID/PID pair because this is a HID." Does this imply that the pair 0x27db and 0x16c0 is "For USB Keyboards" which are not HID? It seems to me all USB keyboards I ever used are HID. Anyone can make this clear? Thanks.
-Xiangrui

Post Reply