Ask Your Question
0

wiringPi to transmit over UART in subscriber callback without sudo [closed]

asked 2016-02-18 13:51:25 -0500

bigbrett gravatar image

updated 2016-02-18 14:15:11 -0500

gvdhoorn gravatar image

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

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant. Please see http://wiki.ros.org/Support for more details. by tfoote
close date 2017-04-20 14:39:17.115040

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-02-18 14:13:37 -0500

gvdhoorn gravatar image

updated 2016-02-18 14:17:25 -0500

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-02-18 13:50:21 -0500

Seen: 506 times

Last updated: Feb 18 '16