my arduino mega shows output ( see below ) as one (1) line .
there are no new lines or CR in the line.
Can you girls/guys help me out where i put the newline or CR
somehow there is some kind of separator ⸮⸮⸮And it would help to figure out what it is exactly.
void loop() {
while(Serial1.available()) { // If anything comes in Serial 1 (pin 19)
byte rd = Serial1.read();
Serial.print(rd, HEX); // or DEC
Serial.print(", ");
}
}
This should show you also what the 'non-printable' characters are. Then you can filter for those and replace them with '\n' & '\r'
drmpf:
Serialxx.read() returns -1 (0xFF) when there is nothing to be read.
So this looks like some code somewhere may not be checking Serialxx.available()
While that is true, it is probably a communication with a Nextion that uses three 0xFF as a message delimiter.
OP: I have a library that handles serial communication and is capable of handling the Nextion format.
#include <WhandallSerial.h> // https://github.com/whandall/WhandallSerial
// simple handler just prints some infos about the received line
void processLine(const char* buf) {
Serial.print(F("len = "));
Serial.print((uint8_t)buf[-1]);
Serial.print(F(", strlen = "));
Serial.println(strlen(buf));
Serial.println(buf);
}
SSerial nextionSerial(Serial1, processLine); // used serial and handler
void setup() {
Serial.begin(250000);
Serial1.begin(9600);
nextionSerial.begin(64, optTripleFF); // buffer size and options, maybe +optKeepDlm
}
void loop() {
nextionSerial.loop(); // collect chars and call handler for each line
}