Hi,
I am interfacing an UART sensor with Boron LTE with target OS 1.1.0 using the Serial1 Port but am getting issues. So, I decided to check whether Serial1 is functioning as I want it to with UART settings:
1200 Baud and 7E1 frame format.
I hooked up a logic analyzer with the Serial1 Tx pins to verify my Boron is writing what I expect it to write. And to my surprise, Boron isn’t writing anything at all. So I tweaked the baud rate and frame settings (8N1, 8E1 etc.) and it seemed to be working perfectly fine.
Attached are the screenshots of logic analyzer output and below is my simple serial1 test code. Does Boron LTE have specific issues for 7E1 format? Has anyone encountered this strange behavior before?
Thank you,
Vish Powers
byte writeArray[] = {0x01,0x02,0x03,0x04,0x00,0x00,0x05,0x00};
int byteaval, byteswritten;
/* PRINT FUNCTION TO PRINT HEX BYTES WRITTEN TO SERIAL PORT*/
void printFrameHeSerial(unsigned char modbusFrame[], int frameLength, Stream *stream)
{
stream->print("{");
for (int i = 0; i < frameLength; i++)
{
stream->print("0x");
if (modbusFrame[i] < 16) stream->print("0");
stream->print(modbusFrame[i], HEX);
if (i < frameLength - 1) stream->print(", ");
}
stream->println("}");
}
void setup() {
Serial.begin();
Serial1.begin(1200, SERIAL_7E1);
//Serial1.setTimeout(10);
delay(10);
Serial1.flush();
}
void loop() {
byteaval = Serial1.availableForWrite();
Serial.print("Bytes available for Writing to Serial1 Port:");
Serial.println(byteaval);
Serial.print("Testing Serial1 Print command.... Bytes Written :");
Serial.println(Serial1.println(0x55));
Serial1.flush();
delay(10);
if (Serial1){
byteswritten = Serial1.write(writeArray,sizeof(writeArray)/sizeof(writeArray[0]));
Serial.print("Bytes written to Serial1 (");
Serial.print(byteswritten);
Serial.print(") = ");
if (byteswritten > 0) printFrameHeSerial(writeArray,sizeof(writeArray)/sizeof(writeArray[0]), &Serial);
else Serial.println();
Serial1.flush();
delay(10);
}
else Serial.println("Serial not available");
delay(2000);
}