Robotics StackExchange | Archived questions

wiringPi to transmit over UART in subscriber callback without sudo

Hi,

I am trying to create a ROS node in which I have a subscriber to a /cmd_vel topic, and a callback function in which I transmit the cmd_vel data to a slave MCU over UART.

I am unable to use wiringPi serialPutchar(), or run any other C executable without directly invoking sudo. I have seen the other posts on this board, and have tried all of their suggestions to no avail.

Every time I get the warning "wiringPiSetup: Must be root. (Did you forget sudo?)".

Steps I have taken: - I have edited /etc/inittab and /boot/cmdline.txt - I have executed sudo usermod -a -G dialout pi - I have executed gpio export 15 out and gpio export 16 in - I have executed sudo chmod 777 /dev/ttyAMA0 - I call wiringPiSetup() in the first line of my code

Is it impossible to control any hardware on the PI without acting as sudo? How else can you write a ROS node to send something over the Pi's hardware UART?

Also, is transmitting over UART in a subscriber's callback function a bad practice?

Best,

Brett

Asked by bigbrett on 2016-02-18 14:50:21 UTC

Comments

Answers

This is slightly off-topic for this site, as it's really not ROS specific.

Is it impossible to control any hardware on the PI without acting as sudo?

No, it's certainly possible.

How else can you write a ROS node to send something over the Pi's hardware UART?

For your UARTs: it should really come down to giving your normal user permission to access the appropriate device file. Either by making your user member of the appropriate group (the group that owns the device file), or by making the device file read/writable for your current user (or for anyone not the owner or a member of the owning group). How that is best done on your Pi I don't know.

For GPIO: see Anyone know how to access RasPi GPIO without sudo? on element14.com for a rather complete thread that describes your problem, as well as a number of work-arounds and solutions.

Asked by gvdhoorn on 2016-02-18 15:13:37 UTC

Comments