CPP -> bridge -> Arduino How to ?

Hi guys I just got my Arduino Yun I am running a c++ program on the linux side of the yun and I would like to send some data from it to the arduino side of it. Any idea how to do it ?

for now the cpp part is writing some datas to a txt file and the arduino part retrieves them threw the bridge, but I would like to stream the datas.

thanks a lot !

Arduino YUN custom openwrt C program communication with arduino


Arduino code:


Since UART's speed is only 0.5Mb/s and will be bottleneck, compiled programming languages assembly/c/c++ has no advantage than script languages php/python/lua. UART is interface between Yun and Arduino.

Thanks a lot

I would like to communicate the other way so I added the line :
to send “yo” to the arduino


in the C file :

#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <termios.h>

/* Yun is on /dev/ttyATH0 */
char *portname = "/dev/ttyATH0";
char buf[256];

int main(int argc, char *argv[])
   int fd;
   /* Open the file descriptor in non-blocking mode */
   fd = open(portname, O_RDWR | O_NOCTTY);
   /* Set up the control structure */
   struct termios toptions;
   /* Get currently set options for the tty */
   tcgetattr(fd, &toptions);
   /* Set custom options */
   /* 9600 baud */
   cfsetispeed(&toptions, B9600);
   cfsetospeed(&toptions, B9600);
   /* 8 bits, no parity, no stop bits */
   toptions.c_cflag &= ~PARENB;
   toptions.c_cflag &= ~CSTOPB;
   toptions.c_cflag &= ~CSIZE;
   toptions.c_cflag |= CS8;
   /* no hardware flow control */
   toptions.c_cflag &= ~CRTSCTS;
   /* enable receiver, ignore status lines */
   toptions.c_cflag |= CREAD | CLOCAL;
   /* disable input/output flow control, disable restart chars */
   toptions.c_iflag &= ~(IXON | IXOFF | IXANY);
   /* disable canonical input, disable echo,
    disable visually erase chars,
    disable terminal-generated signals */
   toptions.c_iflag &= ~(ICANON | ECHO | ECHOE | ISIG);
   /* disable output processing */
   toptions.c_oflag &= ~OPOST;
   /* wait for 24 characters to come in before read returns */
   toptions.c_cc[VMIN] = 12;
   /* no minimum time to wait before read returns */
   toptions.c_cc[VTIME] = 0;
   /* commit the options */
   tcsetattr(fd, TCSANOW, &toptions);
   while (1) {
       /* Wait for the Arduino to reset */
       /* Flush anything already in the serial buffer */
       tcflush(fd, TCIFLUSH);
       /* read up to 128 bytes from the fd */
       int n = read(fd, buf, 128);
       /* print how many bytes read */
       printf("%i bytes got read...\n", n);
       /* print what's in the buffer */
       printf("Buffer contains...\n%s\n", buf);
   return 0;

with the arduino Code :

String lineTxt = "";
void setup()
void loop()
    char incomingByte=Serial1.read();
    lineTxt ="";

on the Arduino the Serial.println gives me a really weird output

/bin/ash: Hello: not found

any idea how to write ?

yoppydy: on the Arduino the Serial.println gives me a really weird output

/bin/ash: Hello: not found

Your Arduino code is sending the string "Hello" and waiting a response. That response looks like the "Hello" is being processed by the command line interpreter, which of course it doesn't understand: Hello is not the name of an internal command, and it can't find an external executable of that name. Hence the error message.

Are you actually starting your C program somehow? It doesn't appear to be running.

Have a look at the Bridge Process class.

If you start your C program running from the AVR side using Bridge, then stdin and stdout will be connected through Bridge automatically.

The benefits are: You're not fighting the shell that's running on that serial port. the process starts up as the AVR needs it Use printf/scanf to send/rec data You're not hogging the serial port, so other bridge functions still work