Ask Your Question
0

FT232H - python_GPIO ftdi_usb_open failed

asked 2016-01-30 04:21:10 -0500

Pengatom gravatar image

updated 2016-02-01 16:17:26 -0500

Hi,

I have a FT232H connected to a 16 ch servo controller over I2C. Both boards are from Adafruit I've installed python 2.7 and all other necessary drivers and library according to this guide. I ran the Servo_Example.py (as sudo python Servo_Example.py) and the servo moves as expected.

The thing is, this library expects to be run as sudo, and I want to control this as a part of ROS, which is not supposed to be run as sudo (as far as I can see from documentation and forums).

The "Adafruit-part" works when running "sudo python script1.py" and the "ROS-part" works when running "python script2.py" The problem is when I try to combine these two into "script3.py". Running it with sudo gives library import from all ROS libraries (that was working fine earlier) and without sudo it seems that it doesn't have the rights to access the usb port.

With sudo the error message is:

ImportError: No module named xxx

(where xxx is the topmost non-commented line, and changes accordingly if I try to run the script with one of the libraries commented out)

Without sudo the error message is

RuntimeError: ftdi_usb_open failed with error -4: usb_open() failed

(after I edited the driver to not include "check_running_as_root()" cause it failed with that anyway as I'm trying to avoid running as root)

running ls -l /dev/ttyUSB0 gives

crw-rw---- 1 root dialout 188, 0 Jan 30 10:59 /dev/ttyUSB0

Running udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB0) gives a ton of information, sorting through it, I made a udev.rules file in /etc/udev/rules.d/

#FT2232 Adapter 
SUBSYSTEM=="tty", ACTION=="add", DRIVERS=="?*", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6014", OWNER:="second_user", GROUP:="my_group", MODE:="0770"

after unplugging and running sudo udevadm control --reload-rules and plugging back in, this is updated to

crwxrwx--- 1 second_user my_group 188, 0 Feb 1 22:16 /dev/ttyUSB0

So, something is happening here at least, but it doesn't do much good. Running my python scripts still gives me ftdi_usb_open error. Any thoughts on how to move forward from here?

Regards Pengatom

edit retag flag offensive close merge delete

Comments

The guide link is wrong

duck-development gravatar image duck-development  ( 2016-01-31 08:12:08 -0500 )edit

Fixed. Thanx for pointing it out!

Pengatom gravatar image Pengatom  ( 2016-01-31 11:50:27 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-01-31 05:26:01 -0500

duck-development gravatar image

updated 2016-01-31 16:34:52 -0500

Try to run the Programm as root (sudo your programming)

Add a udev rule to map the device to yours second_user.

I think the problem is that ftdi_usb_open opens the /dev/bus/usb device and not the ttyUSB0 device

If you like to ise the raw interface maybe there is then an conflict with the Linux tty Module driver.

It is an permission error see the solution here

http://developer.intra2net.com/mailar...

edit flag offensive delete link more

Comments

Did it help

duck-development gravatar image duck-development  ( 2016-02-01 14:45:49 -0500 )edit

Thanks for helping me along here! - Sorry for not getting back before, haven't had time to do anything before now. I'm waay out of my comfort zone here, which is a good thing - but it means I'll need some more inputs. I've updated the question with some more info...

Pengatom gravatar image Pengatom  ( 2016-02-01 16:19:30 -0500 )edit

Please close the answer

duck-development gravatar image duck-development  ( 2016-02-02 12:37:05 -0500 )edit
1

answered 2016-02-02 04:52:56 -0500

Pengatom gravatar image

Well, I can only say The devil is in the detail! Last night I ended up with this:

SUBSYSTEM=="tty", ATTR{idProduct}=="6014", ATTRS{idVendor}=="0403", MODE="0660", GROUP="dialout"

and here is the solution:

SUBSYSTEM=="usb", ATTR{idProduct}=="6014", ATTRS{idVendor}=="0403", MODE="0660", GROUP="dialout"

Changing tty to usb, three small letters did the trick!

Thanks to duck-development for the input!

edit flag offensive delete link more

Comments

Thanks, helped me solving same issue.A small remark: there are two calls of modprobe after the root check, they both fail, but who cares :D, the device disconnects as soon as the new driver writes to it. Unfortunately, they removed the "ignore_device" option from udev, that would be a clean solution

kubelvla gravatar image kubelvla  ( 2016-06-21 07:56:18 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-01-30 04:20:03 -0500

Seen: 1,295 times

Last updated: Feb 02 '16