AltSoftSerial icon indicating copy to clipboard operation
AltSoftSerial copied to clipboard

RX Buffer max size is 500byte?

Open dirkclemens opened this issue 6 years ago • 5 comments

I have to read a stream with nearly 700 byte from my smart meter (data from an IR diode at 9600 baud). When using the library with a Mega2560 board (rx pin 48) I always get a "serial buffer overload" error when 500 bytes were received.

if (mySerial.available()) {
    buffer[idx] = mySerial.read();
    ...
    idx += 1;
}

if (mySerial.overflow()) {
    Serial.print("SERIAL_OVERFLOW at: ");
    Serial.println(idx);
}

I already changed the size to #define RX_BUFFER_SIZE 1024 but it still ends at 500 bytes read.

dirkclemens avatar Nov 21 '18 18:11 dirkclemens

The head & tail variables are only 8 bits, so anything over 255 bytes could be expected to fail.

PaulStoffregen avatar Nov 21 '18 19:11 PaulStoffregen

ok, thanks, but just setting them to uint16_t doesn't solve the problem, isn't it? (including all method internal variables)

dirkclemens avatar Nov 22 '18 18:11 dirkclemens

ok, thanks, but just setting them to uint16_t doesn't solve the problem, isn't it? (including all method internal variables)

Dirk hast du eine Lösung gefunden? ich stehe vor dem selben Problem. mein Stromzähler erzeugt natürlich auch einen overflow.

Rothammel avatar Feb 15 '19 18:02 Rothammel

@Rothammel unfortunately not, I stopped and went back to my Raspberry Pi / Python solution, which is running fine, but is somehow oversized ;-) Anyway, but it works.

dirkclemens avatar Feb 15 '19 20:02 dirkclemens

dann probiere einmal NeoSWSerial

Rothammel avatar Feb 15 '19 20:02 Rothammel