Is there a recommended way to pass AllJoyn messages to the Arduino side of an Arduino Yun?

asked 2014-06-13 10:53:54 -0700

zachrattner gravatar image

updated 2014-06-13 10:55:14 -0700

I just set up a VM for cross-compiling AllJoyn apps on OpenWrt. I can compile C/C++ apps and run them on the Atheros CPU of the Yun. Now I'd like to enable bidirectional communication between AllJoyn on the Atheros CPU and Arduino on the Atmel CPU on the Yun:

  • GPIO events should cause the Atheros CPU to send out a sessionless signal
  • Certain incoming AllJoyn messages should be sent to the Atmel CPU to toggle GPIOs

It is my understanding that the Arduino Yun only supports the Bridge library to communicate between the Atheros and Atmel CPUs. But the Bridge library is written in Python and as far as I know, there's no AllJoyn binding for Python.

I feel like there should be a way to interrupt the Atmel CPU from my C++ app on the Atheros CPU without going through the Python bridge. Has anyone done this before, or is there a better way of going about doing this?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2014-06-16 10:01:21 -0700

stevek gravatar image

There are 2 serial communications channels between the Arduino side and the Linino (OpenWrt) side:

  • UART: Serial0 on the Arduino and /dev/ttyATH0 on Linux
  • SPI: StreamSPI0 on the Arduino and /dev/ttySPI0 on Linux

Unfortunately, both of these have their problems. The UART is used by the Linux kernel for kernel messages to the console and is configured by default to also provide a login shell. My own experimentation with the SPI has shown that it can drop characters and in some cases duplicate characters. That was with a pretty harsh stress test though, so more typical usage like a few bytes on occasion should be no problem. The Bridge Library uses the SPI channel.

The thing to be aware of on the Arduino side is that like most microcontrollers, there is no FIFO to buffer data coming in and going out of the serial port. This is particularly important for reading bytes in. If you block interrupts or service another interrupt for longer than it takes to clock a byte in, you risk losing data. Slower data rates can reduce the chance of dropped data.

The extras/hackfest git repository includes code for both the Arduino and Linino sides using the UART. Look for the "smsg" code. The Arduino side includes checks for Linux kernel messages and the Linux kernel rebooting. Those checks are not 100% accurate though. It also depends on adding the following to /etc/rc.local

echo "BOOT DONE"

Another note, the Arduino GPIO pin 7 is tied to the AR9331 (Atheros) chip. Apparently it is used as part of the SPI communications and will cause an interrupt to happen on the AR9331 when toggled. You can disable this with the following command:

echo 0 > /sys/class/gpio/gpio22/value

If you decide to use StreamSPI0, then you probably can't use GPIO pin7 and disable it's connection on the AR9331.

edit flag offensive delete publish link more


Thanks Steve! I'll try this out.

zachrattner ( 2014-06-23 14:53:22 -0700 )edit

answered 2014-12-01 22:41:06 -0700

Check out LininoIO which allows you to access most Atmel IO's via fs calls from the AR9331 side on Yun. No need to use Bridge or write any sketches on the Arduino side.

edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2014-06-13 10:53:54 -0700

Seen: 952 times

Last updated: Dec 01 '14