15
6
I have five USB cameras, same brand, same model (Canyon CNR-FWC120H). They are used to monitor different scenes 24/7. I need to somehow identify which camera is which from the Linux (Debian) console or programmatically (any language).
I’ve tried looking at the output of lsusb -vvv
, there is a field iSerial
which should be different for each camera but unfortunately this manufacturer decided not to bother and all cameras have the same serial at that place: 200901010001
Is there any other way I could identify which camera is which independently of USB ports to which they are connected because unfortunately in my specific scenario I can not rely on the fact that the same camera will always be connected to the same port.
UPDATE After some discussion in the comments I realize this is mission impossible. So forget the last paragraph or if you do have some ingenious idea, please, you are welcome to present it. I’m now interested if I could identify which USB port the device is connected to; I use the built-in USB ports on the motherboard and additional PCI USB controller cards to accommodate the cameras with enough bandwidth. I would need to uniquely identify the port, and the port number/identification should not change if for example the machine reboots and for some reason the USB controllers get initialized in different order. Is that possible?
UPDATE 2 I see in my logs for one of the cameras the following info:
[Wed Apr 30 18:35:02 2014] uvcvideo: Found UVC 1.00 device FULL HD 1080P Webcam (0bda:58b0)
[Wed Apr 30 18:35:02 2014] input: FULL HD 1080P Webcam as /devices/pci0000:00/0000:00:01.0/0000:01:00.0/usb3/3-2/3-2:1.0/input/input4
Using that, I’ve called this command:
udevadm info --query=all --path=/devices/pci0000:00/0000:00:01.0/0000:01:00.0/usb3/3-2/3-2:1.0/input/input4
And got this:
P: /devices/pci0000:00/0000:00:01.0/0000:01:00.0/usb3/3-2/3-2:1.0/input/input4
E: DEVPATH=/devices/pci0000:00/0000:00:01.0/0000:01:00.0/usb3/3-2/3-2:1.0/input/input4
E: EV=3
E: ID_BUS=usb
E: ID_INPUT=1
E: ID_INPUT_KEY=1
E: ID_MODEL=FULL_HD_1080P_Webcam
E: ID_MODEL_ENC=FULL\x20HD\x201080P\x20Webcam
E: ID_MODEL_ID=58b0
E: ID_PATH=pci-0000:01:00.0-usb-0:2:1.0
E: ID_PATH_TAG=pci-0000_01_00_0-usb-0_2_1_0
E: ID_REVISION=5801
E: ID_SERIAL=Generic_FULL_HD_1080P_Webcam_200901010001
E: ID_SERIAL_SHORT=200901010001
E: ID_TYPE=video
E: ID_USB_DRIVER=uvcvideo
E: ID_USB_INTERFACES=:0e0100:0e0200:010100:010200:
E: ID_USB_INTERFACE_NUM=00
E: ID_VENDOR=Generic
E: ID_VENDOR_ENC=Generic
E: ID_VENDOR_ID=0bda
E: KEY=100000 0 0 0
E: MODALIAS=input:b0003v0BDAp58B0e5801-e0,1,kD4,ramlsfw
E: NAME="FULL HD 1080P Webcam"
E: PHYS="usb-0000:01:00.0-2/button"
E: PRODUCT=3/bda/58b0/5801
E: PROP=0
E: SUBSYSTEM=input
E: UDEV_LOG=3
E: USEC_INITIALIZED=41090223
The things that differ between the cameras are DEVPATH
, ID_PATH
, ID_PATH_TAG
, PHYS
and (most interesting) USEC_INITIALIZED
. Now the first four elements are probably related to the USB port, but the last one USEC_INITIALIZED
looks like some sort of serial number. I can’t find any info about what it actually represents. Does anyone know anything about it? I thought that it is maybe the time in micro seconds when the camera initialized but the camera that initialized after this one has USEC_INITIALIZED=17919751
, and then the one after that USEC_INITIALIZED=25609278
so it seems rather random. I’ll try to reboot the system and see, but I need to wait for a convenient time to do that.
And if anyone is wondering why I don’t just try reconnecting a camera and see if that remains the same. The answer is that I’m operating this PC remotely, and I’m investigating all this to prepare the system to be fully autonomous for any potential event in the future. Which for example might include disconnecting the cameras from USB ports.
Pls see my answer, I think I have found an adequate solution for you. – MariusMatutiae – 2016-03-04T10:40:10.793
Can it be non-programatic / non-software too? eg by marking the camera front glass with a marker (different colors)? If there are no differences in the hardware and/or serials then I doubt this will be possible without custom reprogramming, you could however connect the camera's via relays/hub's which ARE different? – Gizmo – 2014-04-30T15:18:00.090
Unfortunately no for the marker idea, because I must not introduce anything to the picture itself. I was wondering if there is a possibility to overwrite the cameras serial number? Or any other camera setting/info... Does something like that exist? Writable, persistent memory? – Ivan Kovacevic – 2014-04-30T15:24:12.057
This is going to be really hard, especially when no unique information for the device's is provided, see this: http://stackoverflow.com/questions/14053764/how-to-identify-uniquely-an-usb-device . As for overwriting the memory, you could try to find a firmware flashing utility, identify the serial in the firmware and HEX-EDIT it to something you like? However I can't find any tools for it. If you can find a way to change the usb device descriptor then it would be easy from there on.
– Gizmo – 2014-04-30T15:27:29.780You can try the HID Descriptor tool here - http://www.usb.org/developers/hidpage/ - Ofcourse, only if your cam is HID
– Gizmo – 2014-04-30T15:34:05.833damn, yup I guess this is impossible, there is also no firmware for this model so that idea is out too. I guess the only thing I could do is to enforce that each camera stays connected to the same port on the PC all the time... I will modify my question. – Ivan Kovacevic – 2014-04-30T15:35:16.397
That HID Descriptor tool is Windows only I believe. But anyhow I don't think I would have much luck with that as I've checked now that only two devices report they are HID devices on my system and these are not the cameras. – Ivan Kovacevic – 2014-04-30T15:46:06.013
Then I think your only chance is to use a USB hub which supports unique identification (one usb hub - one camera) – Gizmo – 2014-04-30T15:50:07.447
I would really wish to avoid that(buying new hardware). See my update to the question. – Ivan Kovacevic – 2014-04-30T15:55:30.330
As for your update, I don't know how it's on linux but on windows the usb port numbers always remain the same, maybe this and this could be of help.
– Gizmo – 2014-04-30T16:19:21.407It gave me some "inspiration". I've added another update to my question. – Ivan Kovacevic – 2014-04-30T18:17:22.557
The USEC_INITIALIZED, is, probably - the timestamp at which the device has been initialized, sorry for destroying your hopes XD [unsigned int - second initialized], can you tell us by how much the numbers differ and if they change on reboot? (just to be sure, maybe I'm wrong) – Gizmo – 2014-04-30T18:30:14.627
It probably is the timestamp :-/ But it's a weird timestamp :). I've again modified the question. I've added USEC values from three different cameras, all initialized one after another(according to dmesg output) – Ivan Kovacevic – 2014-04-30T18:37:44.767
maybe it's the best to contact the manufacturer and ask for a firmware file + flash utility or some other utilities? If the camera's have some IO pins in them maybe you could connectto it and telnet to the camera to change the ID – Gizmo – 2014-04-30T19:03:26.657
To contact the manufacturer might be an option although I wouldn't put much hopes into that. They do have firmware updates for some other gadgets but not for this camera. So I suppose there is a reason for that and somehow I doubt they would be willing to provide one so I can hack it :). But hey I might try it... Regarding your second idea I did already disassemble these cameras but I did not spot any IO pins :-/ so it's probably over USB. – Ivan Kovacevic – 2014-04-30T19:20:42.230
What about toggling the power for the usb ports of each camera via sysfs? It's easy enough if you have an older kernel. – micke – 2014-04-30T22:19:22.217
I have the latest Debian stable(wheezy). Kernel: Linux 3.2.0-4-amd64 x86_64. What is you idea? You mean so I can check USEC_INITIALIZED? – Ivan Kovacevic – 2014-04-30T23:23:40.640