Serial read more than 64 bytes

Hi,

I know it's an old thread but I've encountered exactly same issue with Serial.read() stopping after 64 characters had been read. The board is Arduino Uno and in my code I have a SIM module connected to it. In the setup section of my code I have to send couple of commands to initiate communication with the server. One of the AT commands is longer than 64 characters and when it's echoed back Serial.read() captures only initial 64 characters of that command. I've checked examples you posted in the thread and my code is pretty much functionally the same as yours, yet, read() never reads the whole command.
I managed to overcome this issue by increasing _SS_MAX_RX_BUFF in SoftwareSerial.h but I'm not sure if this won't cause issues down the line.
Any clues as to what may be causing Serial.read() to stop?
I've omitted parseATText() function here but there are on delays there, it's simple pattern matching function. It works ok with responses shorter than 64 characters.

void setup()
{
    GSM.begin(9600);
    Serial.begin(9600);

    AT_CMQTTCONNECT();  //returns 'mqttConnEstablished'
}


void sendGSM(const char msg[200], int waitMs = 500) {
    GSM.println(msg);
    delay(waitMs);

    while (GSM.available() > 0) {
        parseATText(GSM.read());
    }

    resetBuffer();
    parseState = PS_DETECT_MSG_TYPE;

}


void AT_CMQTTCONNECT() {
    char at_command[100] = "AT+CMQTTCONNECT=0, \"tcp://111.222.333.444:1883\",20,0,\"mosquitto\",\"password12345678\"";

    sendGSM(at_command, 1000);
    if (buffer_perm == "0,0") {
        Serial.println("Connected to the MQTT server");
        mqttConnEstablished = true;
        i = 6;
    }
    else {
        Serial.println("Unable to connect the MQTT server");
    }

    buffer_perm = "";
    resultState = AT_UNDEFINED;
}

You have asked a new question in a very old Thread that does not seem to have much to contribute so I am suggesting to the Moderator to move you to your own Thread.

You need to post the complete program - for example you say "Serial.read() captures only initial 64 characters of that command" but there is no Serial.read() in the code you posted.

In the meantime have a look at the examples in Serial Input Basics - simple reliable non-blocking ways to receive data. The Tutorial code expects no more than 32 chars but you can change the value of numChars to a bigger value.

Note that if you want to receive more than 64 chars (assuming the standard buffer size) your code needs to empty the input buffer before it overflows.

...R

Split from an old topic

Listen to Robin’s wisdom, that’s the key to your issue

Robin2:
Note that if you want to receive more than 64 chars (assuming the standard buffer size) your code needs to empty the input buffer before it overflows.

Been there, have the solution I used..

#include "textBuff.h"
#include "timeObj.h"


textBuff*   replyBuff;


void setup(void) {

   Serial.begin(57600);              // Or whatever speed you want.
   replyBuff = new textBuff(80);    // Set the size of your text buffer.
                                    // Watch out UNO users, you don't have a lot of RAM to play with.

}


// Send the text buffer out the serial port to see.
void echoTheText(void) {

   while(!replyBuff->empty()) {
      Serial.print(replyBuff->readChar());
   }
}


void loop(void) {

  timeObj timer(10);

  if (Serial.available()) {                        // If we have an incoming char..
    timer.start();                                 // Start our timer.
    while (!replyBuff->full()&&!timer.ding()) {    // While our buffer is NOT full and the timer has not expired..   
      while (Serial.available()) {                 // While we have something to grab from the serial port..
        replyBuff->addChar(Serial.read());         // Grab a char and stuff it into our buffer.
        timer.start();                             // We got one, reset the timer.
      }
    }
  }
  echoTheText();                                   // If there's something in the buffer, lets see it!
}

You will have to go to the library manager and instal LC_baseTools for the stuff to do this.

-jim lee