This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UDEV RULES FOR HOT PLUGIN

Hi,

 I am working on udev rules modification for ttyusb/ HID_USB devices I am getting notification properly.

I am getting notification for connection and disconnect for both class of devices. But I am not able to distinguish on which Port number Device is connected.

So right now I am checking for both ports.

I want to know Is, there any way to pass "Port number" to my program which I am running on notification???

Rules are like:

ACTION=="add",ENV{ID_TYPE}=="hid",RUN+="/root/FILE/sourcecode/Firmware/USB/Output/BIN/USBplugin",
ACTION=="remove",ENV{ID_TYPE}=="hid",RUN+="/root/FILE/sourcecode/Firmware/USB/Output/BIN/unplug"

 

THANKS IN ADVANCE

Regards,

Vishal Rana 

  • Dear Vishal,
    I think, we can find out by vendor ID & product ID (FTDI etc.,)
    If you connect some known USB IDs (vendor and product) then you can run the script or send the notification.
    Ex:
    ACTION=="add", ATTR{idVendor}=="0d8c", ATTR{idProduct}=="000c", RUN= < script or commands >
  • Dear Titus ,

    Vendor ID and Product ID's are differ for Manufacturer to manufacturer. So I feel validating my rule on the bases of Vendor and product ID is not good for me because I am using Bar code reader on my device so any one can connect any Reader as per his wish.

    Any way to pass variables to program using rules.

    Thanks,
    Vishal Rana