4 ms·
What's preventing you from just picking at random an ID that hasn't been assigned? If you're a small-volume project, then presumably people will need to have c
by csense 12y ago
What's preventing you from just picking at random an ID that hasn't been assigned?
If you're a small-volume project, then presumably people will need to have custom kernel patches anyway and will be unlikely to actually have a device with a conflicting ID.
- nitrogen 12y agoThis would lead to potential ID collisions as the VID space isn't very big. So just use a well-known debugging ID and have your driver detect your device using other USB descriptor fields.
- userbinator 12y agoGiven that the full identification of a device is a VID:PID pair, and that's a 32-bit space, picking one at random is not very likely to result in a collision. Furthermore, this assumes true randomness and not "randomly pick one and then check online to see if some other device has already claimed it." It also assumes that your project isn't close enough to some existing one that you really need to define a completely new interface instead of just using or extending that of an existing device.
- tedivm 12y agoPeople tend to confuse the odds of two arbitrary strings colliding with the chances of a set of strings having a collision. 32bit space is not that big, and you have to take into account the birthday problem. If you do out the math it turns out there's a 50% chance of collision after only 77,163 hashes. http://preshing.com/20110504/hash-collision-probabilities/ http://preshing.com/20110504/hash-collision-probabilities/
- deleted 12y ago[deleted]
- nitrogen 12y agoOf course, nobody will connect thousands of USB devices to their computer. No, but there are thousands of preset IDs in the hundreds of drivers already present on the computer. For this reason, isn't it safe to pick a random 32-bit identifier? Devices don't just collide with others on the same computer, but with other drivers on the same computer. Edit: Unfortunately sillysaurus3 deleted the parent comment. It had an interesting summary of a simulation of the collision problem.
- deleted 12y ago[deleted]
- deleted 12y ago[deleted]
- FigBug 12y agoI believe the 32-bit id you select needs to be unique from all the ids your OS knows about or else it will install the wrong driver and may crash / encounter other issues. Of course the user could manually uninstall that driver and install a driver you provided. But randomly selecting an id doesn't make much sense. For example here are all the ids Linux knows about: http://www.linux-usb.org/usb.ids http://www.linux-usb.org/usb.ids. Obviously don't select Logitech, Microsoft, Canon, Samsung, etc. manufacture id. Either select an unused manufacture and then randomly select the device id. Or select a manufacturer id that is no longer used like US Robotics (I doubt they are making any new modems) and then randomly select a device id. As soon as make your device, connect it to a Windows machine which will try and find a driver -- if it doesn't, probably no conflict. If there is a conflict, it's with a product that distributes it's driver manually - so you don't have to worry. Or a product that doesn't exist yet, which could be an issue.
- zellyn 12y agoA good rough rule is to halve the power of two: so 2^16 = 65536, which is close enough to 77163.
- swimfar 12y agoThat's really cool. I tried it with the birthday problem[1] (real answer 23) and got 16 if I used whole exponents[2] and 19 with fractional exponents[3]. They're a little off but it gives you an idea of the value. [1] https://en.wikipedia.org/wiki/Birthday_problem https://en.wikipedia.org/wiki/Birthday_problem [2] 256 days=2^8, 16=2^4 [3] 365 days=2^8.51, 19=2^4.255
- Pinckney 12y agoThat doesn't matter to an individual developer. Why should they care if the set of all in use USB PIDs has collisions? It's only becomes a problem for them if their PID suffers a collision.
- Tinyyy 12y agoThe Birthday Problem is only relevant to find collisions between any 2 strings, but in this case the developer is only concerned about the probability of his own string clashing with someone else’s, thus the probability of a collision is only Number of taken strings / Number of total strings.
- fnordfnordfnord 12y agoNothing, which is why it is arguably a short-sighted move for USB-IF to charge such a large amount to hobbyists and such.
- tracker1 12y agoI'm surprised that the USB-IF itself doesn't have several hobbiest vendor ids that then hand out single PIDs for use (say at $25USD)