6

I have a rf-reader with ftdio usb to serial chip. I was able to write a program to control it using ftdi d2xx library. So far so good.

The issue is that when the reader is reconnected to the PC I have to remove ftdi_sio and usbserial mods using this command:

sudo rmmod ftdi_sio
sudo rmmod usbserial

I can't use ftdi d2xx library to connect to the reader if I don't run the code.

I want to be able to add a udev rule so whenever the reader is connected kernel unload the ftdi_sio and usbserial (or not load them in first place)

I've added a new udev rul to /etc/udev/rules.d with name 99-ftdi-sio.rule

ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001",  RUN+="/bin/sh -c 'rmmod ftdi_sio && rmmod usbserial'"

but it's not working. Anyone has any ideas how to solve this issue?

Amin Y
  • 701
  • 1
  • 9
  • 15

3 Answers3

4

is idVendor and idProduct correct ?

Then try:

ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE="0666",  RUN+="/bin/sh -c 'rmmod ftdi_sio && rmmod usbserial'"

If you know the device number you can try this script instead:

RUN+="/bin/sh -c 'echo -n 1-1:1.0 > /sys/bus/usb/drivers/ftdi_sio/unbind'"
GLampros
  • 121
  • 1
  • 8
  • No luck. I've added that to `99-ftdi-sio.rule`, then tried reloading rules with `sudo udevadm control --reload-rules` then connected the device again, `lsmod | grep ftdi` still shows ftdi_sio and usbserial mods loaded. – Amin Y Dec 03 '15 at 05:50
  • Also, I got the vendor and product from lsusb: `Bus 002 Device 006: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC ` 0403 for vendor, 6001 for product. – Amin Y Dec 03 '15 at 05:52
  • 2
    File should be called _somename.rules_ not _.rule_ Try to unload only ftdi_sio at first. It worked for me. Also is **rmmod** visible or should be **/sbin/rmmod** ? – GLampros Dec 03 '15 at 12:19
0

I was able to fix the problem by using a different library. Instead of d2xx library, I started using pylibftdi which is based on libftdi and it's not sensitive to ftdi_sio.

Amin Y
  • 701
  • 1
  • 9
  • 15
-1

Insted of adding a new file .rules, i added that new rule line in the 70-persistent-ipoib.rules already existent and worked for me. :)