hi everyone
i am having problem in reading a large amount of data from the serial monitor.
my input will be
6E 245 IDR 12:30 SCH TRJ 102 HYD 12:30 SCH G8 141 BOM 12:35 SCH 6E 179 BOM 12:40 SCH 9W 475 BOM 12:40 SCH CD 561 PNQ 12:50 SCH SG 488 BOM 13:00 SCH AI 156 DEL 13:15 SCH SG 3105 MAA 13:15 SCH SG 516 PNQ 13:30 SCH G8 286 DEL 13:35 SCH 6E 329 DEL 13:40 SCH UK* 847 DEL 13:45 SCH SG 171 DEL 14:05 SCH 6E 5924 BOM 14:05 SCH 9W 472 BOM 14:05 SCH 6E 345 BLR 14:10 SCH 6E 905 HYD 14:15 SCH 6E 634 CCU 14:30 SCH
AI 663 BOM 14:45 SCH I5* 775 DEL 14:50 SCH 6E 161 AMD 14:55 SCH
if i assign this data in the sketch then m able to display it on serial monitor, but when i need to read this amount of data from serial monitor it gives me problem
can anyone help me with this?
const byte numChars = 255;
char receivedChars[numChars]; // an array to store the received data
boolean newData = false;
void setup() {
Serial.begin(9600);
Serial.println("<Arduino is ready>");
}
void loop() {
recvWithEndMarker();
showNewData();
}
void recvWithEndMarker() {
static byte ndx = 0;
char endMarker = '\n';
char rc;
while (Serial.available() > 0 && newData == false) {
rc = Serial.read();
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = '\0'; // terminate the string
ndx = 0;
newData = true;
}
}
}
void showNewData() {
if (newData == true) {
Serial.print("This just in ... ");
Serial.println(receivedChars);
newData = false;
}
}