Skip to content

Abnormal echo on Serial #168

@bilboquet

Description

@bilboquet

Hello,
This sketch is causing me some troubles.

#include <Arduino.h>

void setup() {
    Serial.begin(115200);
    Serial.println("Starting !");
}

void loop() {
    int byte, count;
    while (count = Serial.available()) {
        digitalWrite(13, HIGH);
        delay(900);
        digitalWrite(13, LOW);
        delay(100);
        Serial.print("print to Serial : ");
        Serial.println(count);
        byte = Serial.read();
        Serial.print((char) byte);
    }
}

The board is connected to the PC (running Ubuntu 16.04) through the programming port. In a terminal I do a cat /dev/ttyACM0 and nothing more.
For me the sketch should print:

Starting!

Then silently loop forever…
But it prints (blank lines have been removed):

Starting !
print to Serial : 3
Sprint to Serial : 25
tprint to Serial : 48
aprint to Serial : 63
rprint to Serial : 62
tprint to Serial : 63
iprint to Serial : 62
nprint to Serial : 63
gprint to Serial : 63

What is really strange is that the read characters are the printed characters… (see beginning of each line).
Somewhere there is a loop which I don't understand.
Any help will be much appreciated as this "echo" is blocking me.

Regards,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions