EDIT: after reading up on some stuff and with the help of the comments people left, I'm certain that it's an overflow issue, but I'm not sure how to solve that...

So I just got an Arduino Yun today and have been figuring out how to use it. I seem to have run into a problem though and haven't been able to solve it...

I stripped down the YunSerialTerminal sketch that allows accessing the yun linux terminal over a usb com port:

void setup() {
  Serial.begin(9600);      // open serial connection via USB-Serial
  Serial1.begin(250000);   // open serial connection to Linux

void loop() {
  if (Serial.available()) {             // got anything from USB-Serial?
    int c = Serial.read();              // read from USB-serial
    Serial1.write(c);                   // write to Linux
  if (Serial1.available()) {            // got anything from Linux?        
    int c = Serial1.read();             // read from Linux  
    Serial.write(c);                    // write to USB-serial

It works for the most part, but has some odd differences from connecting via ssh over wifi.

It seems to be dropping random characters from the screen (due to buffer overflow):

enter image description here

As you can see, it's messed up some of the text such as md5um which should be md5sum and the formatting is all off.

It gets even worse when launching elinks terminal web browser (which works beautifully when connecting via ssh over wifi):

enter image description here

I've also tried different programs (other than putty), including the arduino ide serial monitor, and they all produce the exact same result (and yes I'm setting them to the correct port speed as well).

Does anyone have any idea what I'm doing wrong? I've tried many different port speed combinations and they all produce the same result. It seems that the atheros-atmel link is set to 250000 baud (Which is why I have to use that speed on Serial1 in my sketch), but can that be changed? I've read some things about how 250000 is way too fast when the atmel is involved, but is there a way to change that speed without losing the Bridge library functionality?

Also, could someone else with a yun try this sketch and verify that it works? Load it, and connect with putty via serial (using whatever com port arduino bound to) and double tap tab key to see if the command listing is missing letters.

  • Are you sure you only have one application reading serial data? – Ignacio Vazquez-Abrams Jul 22 '14 at 4:35
  • Nearly positive, all I have open is putty. Also, it only drops characters when something large is printed out, when I'm typing or holding down enter to get blank prompts, it appears fine. – cnsumner Jul 22 '14 at 4:37
  • 1
    Looks like your serial buffer is overflowing. Does the original code work as intended? Did you remove software handshaking (XON/XOFF) by any chance? – jippie Jul 22 '14 at 5:13
  • The original code has the same issue (I stripped it down in an attempt to fix it. I noticed the software handshake settings in putty and left it set to xon/xoff, is there something in the code I need for it to work? – cnsumner Jul 22 '14 at 12:23
  • 1
    I'd agree with Jippie on overflow, specially the atheros-to-atmel channel is fast enough that linux can easily overwhelm any possible buffer in the atmel before the data can drain at the drastically slower USB-serial baud rate. You could try increasing the external baud rate. XON/XOFF might work, but it would need to be applied to the atheros-to-atmel link. – Chris Stratton Jul 22 '14 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.