I have a project where I use a software serial connection to read serial data from a barcode scanner.
All is good. However from time to time I have some problems with the data that I'm receiving.
You said : 123456789��?�: @���?���?���?���?���?
You said : 123456789
You said : 123456789123456
You said : 987654321789456123
My code is something similar to the one below
int count = 0;
void parseSerial() {
char ser[20];
while (Serial.available() > 0) {
char c = Serial.read();
if ( c != '\r' && count <= sizeof(ser)) {
ser[count] = c;
count++;
} else {
Serial.print("You said : ");
Serial.println(ser);
for(int i=0; i < sizeof(ser); i++) {
ser[i] = '\0';
}
count = 0;
}
}
}
Any idea on how I can get rid of "��?�: @���?���?���?���?���?"?
Thanks.