How to programatically identify USB RFID Reader 32395 Com port ?
Newbie question here.
How can you programmatically identify the USB RFID Reader 32395 Com port ?
I have the card up and reading, but when different USB devices are plugged/unplugged, the Linux /dev/ttyUSBx entries tends to move around. Is there anything unique that can be looked for or some sort of write/read handshake to safely identify the device via software?
TIA
Update:
There is a Linux command "lsusb -v" which dumps verbose USB Device information. By looking at this information, the vendor and product identifiers tend to be redundant, but the "iSerial" identifier appears to be unique.
The unique "iSerial" identifier can be found using dmesg and "ls -l /dev/serial/by-id" and looking in /var/log/messages.
It appears the "iSerial" identifier could be used as a key if it is known a priori.
It would be great if there was a unique vendor and product identifier.
How can you programmatically identify the USB RFID Reader 32395 Com port ?
I have the card up and reading, but when different USB devices are plugged/unplugged, the Linux /dev/ttyUSBx entries tends to move around. Is there anything unique that can be looked for or some sort of write/read handshake to safely identify the device via software?
TIA
Update:
There is a Linux command "lsusb -v" which dumps verbose USB Device information. By looking at this information, the vendor and product identifiers tend to be redundant, but the "iSerial" identifier appears to be unique.
The unique "iSerial" identifier can be found using dmesg and "ls -l /dev/serial/by-id" and looking in /var/log/messages.
It appears the "iSerial" identifier could be used as a key if it is known a priori.
It would be great if there was a unique vendor and product identifier.
Comments
The lower level option (I have used this) is to use the FTDI API and scan for the unique serial number of the chip on the RFID Reader. In this case it wouldn't matter if you had other FTDI chips connected. You may be able to do this without the FTDI API, but I am not positive in Linux.
Hi Chris,
This is what I am doing as per my updated comments above. I use the "lsusb -v" option to identify and persist the unique serial number of each of the FTDI devices that I am using (there are more than 2). I am then able to use those unique serial numbers to resolve the path to the device at connect time (no FTDI API). It works great, no guessing.
I am now working on the reconnect code to handle unexpected hot USB disconnects and reconnects.
Thanks much.
The only unique information it returns is the "AM01US3U" identifier and the assigned device.
udevadm info --query=all -n /dev/ttyUSB1
P: /devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.2/2-2.2:1.0/ttyUSB1/tty/ttyUSB1
N: ttyUSB1
S: serial/by-id/usb-FTDI_FT232R_USB_UART_AM01US3U-if00-port0
S: serial/by-path/pci-0000:02:00.0-usb-0:2.2:1.0-port0
E: DEVLINKS=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AM01US3U-if00-port0 /dev/serial/by-path/pci-0000:02:00.0-usb-0:2.2:1.0-port0
E: DEVNAME=/dev/ttyUSB1
E: DEVPATH=/devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2.2/2-2.2:1.0/ttyUSB1/tty/ttyUSB1
E: ID_BUS=usb
E: ID_MM_CANDIDATE=1
E: ID_MODEL=FT232R_USB_UART
E: ID_MODEL_ENC=FT232R\x20USB\x20UART
E: ID_MODEL_FROM_DATABASE=FT232 USB-Serial (UART) IC
E: ID_MODEL_ID=6001
E: ID_PATH=pci-0000:02:00.0-usb-0:2.2:1.0
E: ID_PATH_TAG=pci-0000_02_00_0-usb-0_2_2_1_0
E: ID_REVISION=0600
E: ID_SERIAL=FTDI_FT232R_USB_UART_AM01US3U
E: ID_SERIAL_SHORT=AM01US3U
E: ID_TYPE=generic
E: ID_USB_DRIVER=ftdi_sio
E: ID_USB_INTERFACES=:ffffff:
E: ID_USB_INTERFACE_NUM=00
E: ID_VENDOR=FTDI
E: ID_VENDOR_ENC=FTDI
E: ID_VENDOR_FROM_DATABASE=Future Technology Devices International, Ltd
E: ID_VENDOR_ID=0403
E: MAJOR=188
E: MINOR=1
E: SUBSYSTEM=tty
E: UDEV_LOG=3
E: USEC_INITIALIZED=276224027381
This is the same Vendor ID value as other devices that I have plugged in, thus is ambiguous. Some devices are read/write and some are just read. All have the value 0403.
My access to the corporate drive is down... what FTDI chip is used in the USB RFID Card reader? ... It may be possible to directly communicate and/or poll a serial number ID from the FTDI chip. There may also be an NV-RAM option on the FTDI chip where the customer could add their own unique identifier.
dmesg | grep 'FTDI USB\|SerialNumber:\|idVendor\|idProduct'
...And search the output (see below) for the Vendor and Product ID. If that matches, validate the unique serial number. Lastly see where it is attached. If the USB device is disconnected then it will read "disconnected from ttyUSB0" rather than "attached to ttyUSB0" as in the example output below.
Example output:
[ 8442.953762] usb 5-1: New USB device found, idVendor=0403, idProduct=6001
[ 8442.953791] usb 5-1: SerialNumber: A600K2CK
[ 8442.967079] ftdi_sio 5-1:1.0: FTDI USB Serial Device converter detected
[ 8442.968399] usb 5-1: FTDI USB Serial Device converter now attached to ttyUSB0