0

I'm using Raspbian on a Raspberry pi 2. I have an RFID reader connected to it via USB.

My problem: The RFID USB device becomes unavailable at intermittent times and power cycling the device does not work.

My question: How can I query the device and know that it is alive? I can use lsusb and other tools, but, are they just querying the system for the last known information on the device or are they actually touching the device again and retrieving the information?

For those interested, here is my rough script run in cron:

    #!/bin/bash

    rfid_reader="$(lsusb |grep ffff:0035)"
    echo $rfid_reader
    bus="$(lsusb |grep ffff:0035|cut -c 5-7)"
    echo $bus
    device="$(lsusb |grep ffff:0035|cut -c 16-18)"
    echo $device
    # echo "$(./usbreset /dev/bus/usb/$bus/$device)"

    if [ -z "$rfid_reader" ]; then
        echo "rfid_reader is not available, restarting USB"
        echo 0x0 > /sys/devices/platform/bcm2708_usb/buspower
        echo 0x1 > /sys/devices/platform/bcm2708_usb/buspower
        sleep 5
        ifdown eth0
        sleep 5
        ifup eth0

    else
        echo $rfid_reader
        echo "rfid_reader is fine"
    fi

Where ffff:0035 is the ID of my USB RFID device from lsusb. Because the network adapter is integrated with USB it doesn't recover well from being cycled. The sleep and ifup/ifdown take care of this issue.

1 Answer 1

2

lsusb is actively querying the devices on the USB bus as far as I am aware.

You can also used the dmesg command to see the history of the devices insertion, and sure that is not interactive.

You can also use lsinput

sudo apt-get install input-utils
sudo lsinput

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .