Trying to see the incoming data through the serial

To reflect the debug suggestion from above

char szReceive[64] = { '\0' };
int idx = 0;
uint32_t ms;
uint32_t msPublish;
bool frameStart = false;

void setup()
{
   Serial1.begin(19200);
   Serial.begin(115200);
}
void loop()
{
   ms = millis();

   while (Serial1.available() && millis() - ms < 1000 && idx < 38)
   {
     char c = Serial1.read();
     Serial.write(c);

     if (c == 'S')
     { 
       frameStart = TRUE;
       idx = 0;
       Serial.print("<");
     }
     if (frameStart)
     {
       szReceive[idx++] = c;
       szReceive[idx] = '\0';
     }
   } 
   Serial.println(">");
   Serial.println("Fallen out of while");
   Serial.print(frameStart);
   Serial.print('\t');
   Serial.println(idx);

   if (idx >= 38 && millis() - msPublish > 1000)
   {
     Serial.print("Publishing: ");
     Serial.println(szReceive);
     Spark.publish("Carpet1", szReceive, PRIVATE);
     msPublish = millis(); 
     idx = 0;
     frameStart = FALSE;
   }

   Serial.println("-----------------------------------");
}
1 Like