Re: [beagleboard] serial port programming in c++

1,099 views
Skip to first unread message
Message has been deleted

Nuno Sucena Almeida

unread,
Feb 19, 2014, 5:30:29 PM2/19/14
to beagl...@googlegroups.com
On 02/19/2014 11:17 AM, ss sefat wrote:
> i connected the arduino usb with bbb. bbb recognize arduino as /dev/ttyACM0
> . now i want to communicate with arduino using serial communication in c++
> . i tried several times using fopen() .bt bt bbb cannot open "/dev/ttyACM0"
> for writing. can any one give me a simple demo code which completely works
> without any error .plz help me. thanks in advance .

http://tldp.org/HOWTO/Serial-Programming-HOWTO/

Alternatively, you could use python:

http://pyserial.sourceforge.net/

if using debian/ubuntu on the BBB, install the python-serial or
python3-serial package.

regards,
Nuno

--
http://aeminium.org/nuno/

Dave Hylands

unread,
Feb 19, 2014, 7:48:23 PM2/19/14
to beagl...@googlegroups.com
On Wed, Feb 19, 2014 at 8:17 AM, ss sefat <syadus...@gmail.com> wrote:
i connected the arduino usb with bbb. bbb recognize arduino as /dev/ttyACM0 . now i want to communicate with arduino using serial communication in c++ . i tried several times using fopen() .bt bt bbb cannot open "/dev/ttyACM0" for writing. can any one give me a simple demo code which completely works without any error .plz help me. thanks in advance .


You should check the permissions on /dev/ttyACM0.

On normal desktop ubuntu, you need to belong to the dialout group, be root, or setup some udev rules to give world write permissions to you /dev/ttyACM0 node.

I expect it will be similar on the BBB.

I also don't recommend using fopen with the serial port. You should probably use regular open/close. I have some sample code here:
https://github.com/dhylands/projects/tree/master/host/sertest (uses multiple threads)
https://github.com/dhylands/projects/tree/master/host/sertest-select (uses a single thread)

It's also very worthwhile to read-thru and understand the Serial Programming HOWTO that somebody else linked to.

--
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com

Alexander Holler

unread,
Feb 20, 2014, 6:14:18 AM2/20/14
to beagl...@googlegroups.com
Am 19.02.2014 17:17, schrieb ss sefat:
> i connected the arduino usb with bbb. bbb recognize arduino as /dev/ttyACM0
> . now i want to communicate with arduino using serial communication in c++
> . i tried several times using fopen() .bt bt bbb cannot open "/dev/ttyACM0"
> for writing. can any one give me a simple demo code which completely works
> without any error .plz help me. thanks in advance .
>

You might try boost asio.

Regards,

Alexander Holler

arunbarn...@gmail.com

unread,
Feb 21, 2014, 12:37:35 AM2/21/14
to beagl...@googlegroups.com


On Wednesday, February 19, 2014 9:47:46 PM UTC+5:30, ss sefat wrote:
i connected the arduino usb with bbb. bbb recognize arduino as /dev/ttyACM0 . now i want to communicate with arduino using serial communication in c++ . i tried several times using fopen() .bt bt bbb cannot open "/dev/ttyACM0" for writing. can any one give me a simple demo code which completely works without any error .plz help me. thanks in advance .

The usual method of serial port communication used in linux may be used. If you search the internet for serial communication using c++ on linux you can get many code examples, its not difficult to implement serial communication in C++
Reply all
Reply to author
Forward
0 new messages