command line wrapper for pyserial
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



A wrapper for pyserial on the Arduino Yun, which enables users to send messages from Linino to ATmega. It is modified from the Python code sample posted by user wayoda on the Arduino forums.


Copy linino-to-serial to a directory in your PATH. Use it like this:

linino-to-serial PORT BAUDRATE MSG

For reference, the port /dev/ttyATH0 will connect you to the ATmega side.

If you don't have pyserial, install it using pip install pyserial. (If you don't have pip, follow these instructions.)


On the ATmega (Arduino sketch) side of the Yun, listen for messages like this:

char lininoChars[4] = "000";

void setup() {

void loop() {
    while (Serial1.available() > 0) {
        char c = (char);
    if (hasLininoSaid("SAM")) {
        // shift the buffer so this doesn't get called over and over
        // now do something
    } else if (hasLininoSaid("BEN")) {
        // do something else

void bufferLininoCommunication(char nextChar) {
  // store the last three chars we've received over serial from linino
  lininoChars[0] = lininoChars[1];
  lininoChars[1] = lininoChars[2];
  lininoChars[2] = nextChar;

short hasLininoSaid(char sequence[]) {
  int i;
  for(i = 0; i < strlen(lininoChars); i++) {
    if(lininoChars[i] != sequence[i]) {
      return 0;
  return 1;

This assumes a "message" is a three-character string that is known in advance to both sides of the Yun. Now you can use linino-to-serial for almost anything! For example:

Knowing when the Yun has booted up

On Linino, add the following line to /usr/bin/boot-complete-notify:

linino-to-serial /dev/ttyATH0 230400 "%%%"

In the loop() method you can now check hasLininoSaid("%%%"). Pair this with a boolean contactWithLinino = false; that gets updated to true when contact is made.

Cron Jobs

Follow the instructions here to get cron running on your Yun. Use 0 * * * * linino-to-serial /dev/ttyATH0 230400 "ABC" to send the message "ABC" to your ATmega on the hour, every hour. Adjust to taste!

Known Issues

For reasons I don't entirely understand, the only way I've been able to translate clean messages (without garbling) is by listening on Serial1 with a baud rate of 250000, but sending messages from Linino with a baud rate of 230400. It works just fine like this so it's not really an "issue," but unexpected behaviour nonetheless. Leave a comment if you know what's going on!

More Reading