Is PID = 0 a valid for usb device? - usb

I'm going to create device with Product Id (PID) = 0x0000, create driver for this device and sign it using Microsoft Windows Driver Kit (WDK). Is 0x0000 a valid PID for USB device in Windows?
PID=0x0000 will be a generic PID for all my devices (for development purposes), because I already have PID=0x0001, PID=0x0002 and so on.

Yes. As far as I know, there is nothing in the USB specification that prevents the product ID from being 0, so you should be fine. This listing of USB IDs contains several instances of USB devices with a product ID of 0.
Keep in mind that your product still must have a valid vendor ID, which you are supposed to get assigned to you by the USB Implementers Forum.

Related

USB hub and the identification of positions

I need to attach 8 devices of the same kind (RFID readers) to the 8 positions of the USB hub. I need to recognize which reader is not plugged-in. I also need to know which exact device sends the data (based on the physical location)
I am aware of "a path" related to an USB plug. However, I am still a newbie in the topic. Are the positions at the USB hub numbered always the same way, or are the numbers in the path assigned based on when the USB device is plugged in? In other words, can I tell whether a specific position at the USB hub is connected or not? Can I reliably determine which device sends the data based on the communication path?

How to query the serial number of a UVC camera?

I have two UVC cameras in a stereoscopic setup, controlled with a C++ MediaFoundation app. I need to uniquely identify them in order to assign left and right to each physical device. This camera model has a unique serial number in the USB descriptor. However I can't seem to find a way to get the serial number while enumerating using MediaFoundation.
The MF enumeration order of these cameras is not reliably in port order; 95% of the time, camera 1 is enumerated before camera 2, while on some machines, we get camera 2 before camera 1. So finding the serial number is very important.
Things I've tried:
MediaFoundation doesn't seem to provide a direct way to get the serial number at all
By querying the MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK attribute, you can get a USB symbolic link. The docs say this can be used to call SetupDiOpenDeviceInterface however this doesn't seem to be usable to get the serial number (or the USB descriptor) either.
WinUSB can be used to open some USB devices in a generic manner, so the USB descriptor might be accessible, but this method fails on these cameras also, after passing the handle from CreateFile.
IOCTL the lowest level method, apparently you can send a IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX to the hub device, with a port index, and it will return the descriptor from which you should be able to get the serial number. No idea how to get the hub device and port index from only the symlink though.
Related, but unresolved: How to get hardware ID when enumerating with Windows Media Foundation
I do not wish to reimplement half of the USBView example and enumerate the entire USB world just to get some specific info for a device for which I already have a handle.
Some symbolic links for USB devices can be parsed to extract the serial number, however in the case of composite devices (all the devices in question here) the symbolic link has the &MI_00# style format and does not contain the serial number in the symlink string. So it cannot simply be parsed out.
More generally, the Setup and related APIs in Win32 seem to make it easy to get information such as manufacturer, friendly name, and all sorts of other info. But serial number is conspicuously absent.
So how do you get the serial number associated with a MediaFoundation device instance?
You can do camera identification by USB port connection (Root-Hub-Port identifiers are the same if you don't connect new USB cards or hubs to the system)
Unfortunately StackOverflow doesn't give to attach images (I don't have good enough reputation).
I'll try to show data from debugger:
There is list of my available cameras
+Integrated_Webcam/R1.H2.P4/VID_1BCF&PID_2284&MI_00;
+HBVCAM FHD CAMERA/R4.H2.P4/VID_058F&PID_3821&MI_00;
+HD USB Camera/R5.H2.P5/VID_05A3&PID_9230&MI_00;
+Integrated_Webcam/R5.H2.P6/VID_1BCF&PID_2284&MI_00;
+Logitech HD Webcam C270/R1.H2.P1/VID_046D&PID_0825&MI_00;
Each string consists of Friendly camera name, Rx.Hx.Px camera connection port indexes, (i.e. Controller number"R"-Hub number"H"-Port number"P") and VID-PID-MI presentation string(vendor id, product id and interface number).
1st and 4th cameras are the same, but have different RHP indexes. These indexes I do use for camera identification.
I did USB enumerator which provides these indexes (I did this on the base of Microsoft USBView.exe application which is provided with sources in Windows SDK).
[1]: https://i.stack.imgur.com/6SQcS.png
Usually simple USB cameras (web cameras) doesn't have serial number or something like serial number is encoded inside USB instance ID. More expensive cameras have special drivers and you can read SN by driver.
I see only one way to know, what camera I do use now - by attached USB port. This port is unique... if you don't connect additional hubs or not insert additional USB interface cards in computer. There is USB enumeration process which provides Controller(Root)-Hub-Port enumeration indexes. I do use these indexes for camera identification.
Look on this dialog: you see 5 strings with 5 USB cameras descriptors. Each descriptor consists of "Friendly Camera Name", 3 enumeration indexes (Rx.Hx.Px) and camera vendor ID and product ID (VID and PID).
If I put different camera to the same port, my program will use this different camera. If several cameras of the same type are connected, I do differ between cameras by RHP indexes. For example, the first and the fourth camera in list are the same, but they have different
enter image description here

Way to differentiate two USB devices with same product/vendor ID in retropie

I am using a usb NES and usb SNES controller for emulators on retropie. I found out both of these controllers were made by the same vendor and have the same iProduct name, IdVendor, and IdProduct values, which makes my raspberry pi see these as the same device. Of course, now I keep overwriting config. Is there a way to do something where I can get this USB device name changed so the system can differentiate?
Both controllers show up in lsusb as "0079x0011 DragonRise inc, Gamepad" and have Product name as "2 USB Gamepad"

USB idproduct and idvendor

I am very new to USB interfacing and i am trying to build an application for WINCE 2013 device. In my device, one vendor's (let suppose 'X') VID and PID are using for USB mass storage device class.
Now, i have specific use case where communication should be built on USB rndis class. For this communication purpose we are using microsoft generic rndis driver as is (not a custom one). So, can i use the X's VID and PID(which i am using for MASS STORAGE class now) for the Rndis class too or need to purchase a new one again. I know that i can use any VID and PID during development stage but i need VID and PID's for production devices.
Or can i go with Microsoft VID, PID and compatible id's compatible for Microsoft generic rndis driver by changing only the Serial Number for devices?
Please suggest and thanks in advance! :-)
(Do let me know if the query is too vague to understand.)
It's difficult to find a definitive answer, but maybe we'll be able to extrapolate from this post by a Microsoft MVP (emphasis mine):
(...) you don't have to change MS's VID/PID anymore if
you use USB RNDIS to use ActiveSync.
Here's the official response from
Microsoft on this subject (as asked by a fellow MVP regarding a client
who had the same issue):
Question: Should they use the Microsoft PIDVID or create their own? If
they create their own, it means modifying the current .inf file and
therefore this means the driver will be unsigned and therefore may not
be able to be installed. In the past the Microsoft PIDVID gave warnings
to not use this. Now in 6.0 the warnings do not appear.
Answer: The answer is exactly the same as for Windows Mobile: For
ActiveSync usage, YES, you can use Microsoft's VID & PID for your scenario.
This is a change from documentation which says to get your own PID &
VID. Contrary to what the sample Registry file says, the OEM should ship
the device using Microsoft's VID & PID for USB-Serial ActiveSync client.
The latest OEM documentation confirms this (...)
Now, since you don't specifically mention ActiveSync, my understanding is that the above probably does not apply to your use case, which again means you will have to use your own VID and PID.
If you already own a VID/PID combination, I don't see any (legal) issues using this with RNDIS as well. It is the same device after all, and the USB host would load one of two different class (not custom) drivers to communicate with the device.
However, if you use your own VID/PID you will have to either
supply a signed INF file to end-users that contains your custom VID/PID, or
instruct users to manually select the RNDIS driver when your device is connected to the PC for the first time

Understanding "driverless" USB HID

I'm at the beginning of trying to develop a USB HID bootloader for a Kinetis processor, and getting no help from that department. I have made some modifications to Kinetis firmware designed for a similar processor(I'm using the KL26Z, the original code is for KL25Z), and I do now see the beginning of the USB enumeration(on a PC running W7). However, the PC asks for driver software, and I don't understand why, as I thought the whole point of going the HID route was that one didn't need to install drivers. So the device shows up under device manager, but as a non-working problem device. My problem is that I don't really know what should happen. Any insights would be welcome.
Here's what should happen: the computer will ask your device for its USB descriptors when it detects your device. The descriptors must have certain fields like bDeviceClass set properly to indicate that it is an HID. If the computer sees those fields, it will attach the HID driver to your device.
In the Device Manager, you should look at the "Compatible Ids" of your device. Do you see USB\Class_03 in that list? If so, that should match the driver input.inf that comes with Windows, so the INF file will be applied to your device, and you device will show up as "USB Input Device" in the Device Manager. If you don't see USB\Class_03 in your list then there is probably some problem with your device's USB descriptors or its USB stack.