Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
934 views
in Technique[技术] by (71.8m points)

udev - ftdi d2xx conflict with ftdi_sio on linux - How to remove ftdi_sio automatically

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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'"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...