Shop OBEX P1 Docs P2 Docs Learn Events
How to programatically identify USB RFID Reader 32395 Com port ? — Parallax Forums

How to programatically identify USB RFID Reader 32395 Com port ?

ths61ths61 Posts: 6
edited 2014-06-21 16:47 in Accessories
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.

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-06-20 09:36
    There are two options available (three if you want to mess with driver signatures). A higher level option and a lower level option. The higher level option really only works if you don't have any other FTDI VCP connected. In this case you can scan the descriptor, which in Windows (I don't know how it shows up in Linux) is 'USB Serial Port (COMxx)' where xx is the com port assigned.

    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.
  • ths61ths61 Posts: 6
    edited 2014-06-20 09:54
    ...

    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.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-06-20 10:24
    Oops, I missed the update somehow. As for your other concern which I also missed, there is a unique PID/VID associated with the FTDI chips.
  • ths61ths61 Posts: 6
    edited 2014-06-20 10:42
    FWIW, here is the dump information on Linux.

    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
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-06-20 14:06
    I see the Vendor ID (VID) of 0403 shows up.
  • ths61ths61 Posts: 6
    edited 2014-06-20 14:52
    I see the Vendor ID (VID) of 0403 shows up.

    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.
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2014-06-20 15:02
    Chris,

    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.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-06-20 16:02
    Interesting. As far as I know that is an FTDI number. I used their FT_Prog software to look at a QuickStart Board connected to my laptop and the screenshot below shows the PID/VID for that chip. The second capture shows the serial number for another FT232R chip I connected. If you untick the auto-generate you can change the serial number. You can also change the prefix. Changing some items in this software causes the drivers to become unsigned, so you have to be careful about that. The same IC is used on the RFID Reader USB.

    FT232RL.jpg
    FTDI_Serial.jpg
    638 x 741 - 147K
    638 x 741 - 183K
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2014-06-21 16:47
    You might be able to use something like this ...

    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
Sign In or Register to comment.