Get unique serial number of USB device mounted to /dev folder

nhuanvd picture nhuanvd · Sep 4, 2013 · Viewed 18.8k times · Source

I attach 2 webcam to computer and it was listed in /dev folder: /dev/video0; /dev/video1.

Can you help me write C code to get serial number of webcam with input: /dev/video[0;1]

Answer

lessthanoptimal picture lessthanoptimal · Sep 26, 2015

Just ran into this same problem and it took a bit to find the solution. Any solution which starts with "just use lsusb" is incorrect. You can figure out the devices serial, but none of the extra information it provides help you determine which /dev/video it links to.

Solution:

/bin/udevadm info --name=/dev/video1 | grep SERIAL_SHORT

Output:

E: ID_SERIAL_SHORT=256DEC57