Hi,
have some strange problems with CubeCell GPS-6502 Serial1 interface. Want to use it with an external device, but it dosn’t work. Have to send an 21 Byte Command for reading out this external device, but in my normal code GPS-6502 just sends 20 Bytes, and manny 0x00, he misses 0x29:
byte ReadAll[21] = { 0x4E, 0x57, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x01, 0x29 };
Then tested it with modified Uart2_TX example code on itself:
byte ReadAll[21] = { 0x4E, 0x57, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x01, 0x29 }; // read all
void setup() {
// put your setup code here, to run once:
Serial1.begin(115200);//open the second UART
}void loop() {
// put your main code here, to run repeatedly:
Serial1.write(ReadAll, sizeof(ReadAll));
delay(5000);
}
and it works:
My normal code with this error is modified LoraWanMinimal with only this Serial1 request and answer reading. Have no Idea why this happens. Any suggestions?
Edit:
Ok just figured out, that Serial1.flush();
emediatly after Serial1.write
issued this Problem. maybe TX Buffer ist erased before 21. Byte is send. So inserted an delay(1);
and it fixed this…