Hello,
I'm developing a complex program on the Leonardo, and seem to have come up against a bug in one of the libraries I'm using.
The problem stems from SoftwareSerial (I think), where repeated character input is not being read in correctly for my app.
I have made a small example program which seems to have the same problem. You enter in a line of text to a buffer into D8 (through a MAX232 or similar) and after pressing carriage return, it echoes this buffer to the normal Serial port viewable through the IDE. I'm using 2400 baud for both ports.
If I type more than two repeated characters, then the third and some subsequent repeats don't get decoded properly.
I'm using Arduino 1.0.4 on Windows, and the headerless version of the Leonardo board.
Can anyone else replicate this problem?
Yours,
Ross 7WED
#include <SoftwareSerial.h>
SoftwareSerial mySerial(8,9); // RX, TX
void setup() {
mySerial.begin(2400);
Serial.begin(2400);
}
char buffer[128];
byte pointer = 0;
byte index = 0;
void loop() {
if (mySerial.available()) {
buffer[pointer] = mySerial.read();
if (buffer[pointer] == char(0x0A)) { // we are ready to process the data after receiving a CR signal
for (index=0; index < pointer; index++) Serial.print(buffer[index]);
pointer = 0;
index = 0;
}
pointer++;
}
}