Here goes, based on today’s develop
branch: https://drive.google.com/open?id=15UMxp7voWhCAHY0_xvZDkWDPHf74pPuX
I will create a PR tomorrow have created a PR, so if you can wait a few days for TTP/TWTG to validate it: just wait
If you don’t want to wait:
This basically adds a bit more logging, plus:
// flushUart removes any pending bytes from the receive buffer.
void flushUart(DRV_HANDLE handle)
{
bool flushing = false;
uint8_t buffer[1];
while(DRV_USART_Read(handle, buffer, 1) > 0)
{
if(!flushing)
{
SYS_DEBUG(SYS_ERROR_DEBUG, "LORA: flushing: ");
flushing = true;
}
SYS_DEBUG(SYS_ERROR_DEBUG, "%02x ", buffer[0]);
}
if(flushing)
SYS_DEBUG(SYS_ERROR_DEBUG, "\r\n");
}
(Trying to adhere to the existing code style… Also, it would be nice to use, e.g., DRV_USART_ReceiverBufferIsEmpty
, but the tooling refuses to find that?)
The above is then invoked at the start of:
bool sendCommand(uint8_t command, uint8_t* payload, uint16_t len)
{
flushUart(appData.USARTHandle);
bool gotresponse = false;
...
SYS_DEBUG(SYS_ERROR_DEBUG, "LORA: sendCommand %s\r\n", gotresponse ? "OK" : "ERROR");
return gotresponse;
}
I only get LORA: flushing: 0d
(being an empty line) once now.
However, the mystery continues: I doubt getting two lines as a reply is normal, and I don’t understand how the code could ever print the following!? (See followup post for an explanation.)
RF: 1,1,868500000
LORA: send_cmd: 23 34 06 00 01 01 20 42 c4 33 b8 0d
LORA: recv_rpl: 23 34 07 00 00 01 01 80 e5 f9 ff be 0d
LORA: recv_rpl: 23 35 01 00 00 59 0d
LORA: sendCommand OK
Okay, the code in my firmware uses "%02x"
to print the hexadecimal values, which is different from the "%#x"
in the code on GitHub. But how could it ever (consistently!) print two subsequent lines for LORA: recv_rpl
for this very command…!?
My logging
This is complete; see next post for an explanation.
CNFG: Configuring LoRa module
LORA: Changing state from 2 to 4
LORA: Starting reconfiguration
LORA: send_cmd: 23 31 01 00 00 55 0d
LORA: recv_rpl: 23 31 01 00 00 55 0d
LORA: sendCommand OK
LORA: send_cmd: 23 3a 01 00 00 5e 0d
LORA: recv_rpl: 23 3a 10 00 01 01 4c 47 38 35 30 31 36 30 31 37 38 32 04 01 0d
LORA: sendCommand OK
LORA: version: 01
LORA: configureRXChain(0, ...)
RF: 0,1,867500000
LORA: flushing: 0d
LORA: send_cmd: 23 34 06 00 00 01 e0 ff b4 33 24 0d
LORA: recv_rpl: 23 34 01 00 00 58 0d
LORA: sendCommand OK
LORA: configureRXChain(1, ...)
RF: 1,1,868500000
LORA: send_cmd: 23 34 06 00 01 01 20 42 c4 33 b8 0d
LORA: recv_rpl: 23 34 07 00 00 01 01 80 e5 f9 ff be 0d
LORA: recv_rpl: 23 35 01 00 00 59 0d
LORA: sendCommand OK
LORA: configureIFChainX(1, ...)
IF: 1,1,1,-200000
LORA: send_cmd: 23 35 07 00 01 01 01 c0 f2 fc ff 0f 0d
LORA: recv_rpl: 23 35 01 00 00 59 0d
LORA: sendCommand OK
LORA: configureIFChainX(2, ...)
IF: 2,1,1,0
LORA: send_cmd: 23 35 07 00 02 01 01 00 00 00 00 63 0d
LORA: recv_rpl: 23 35 01 00 00 59 0d
LORA: sendCommand OK
LORA: configureIFChainX(3, ...)
IF: 3,1,0,-400000
LORA: send_cmd: 23 35 07 00 03 01 00 80 e5 f9 ff c0 0d
LORA: recv_rpl: 23 35 01 00 00 59 0d
LORA: sendCommand OK
LORA: configureIFChainX(4, ...)
IF: 4,1,0,-200000
LORA: send_cmd: 23 35 07 00 04 01 00 c0 f2 fc ff 11 0d
LORA: recv_rpl: 23 35 01 00 00 59 0d
LORA: sendCommand OK
LORA: configureIFChainX(5, ...)
IF: 5,1,0,0
LORA: send_cmd: 23 35 07 00 05 01 00 00 00 00 00 65 0d
LORA: recv_rpl: 23 35 01 00 00 59 0d
LORA: sendCommand OK
LORA: configureIFChainX(6, ...)
IF: 6,1,0,200000
LORA: send_cmd: 23 35 07 00 06 01 00 40 0d 03 00 b6 0d
LORA: recv_rpl: 23 35 01 00 00 59 0d
LORA: sendCommand OK
LORA: configureIFChainX(7, ...)
IF: 7,1,0,400000
LORA: send_cmd: 23 35 07 00 07 01 00 80 1a 06 00 07 0d
LORA: recv_rpl: 23 35 01 00 00 59 0d
LORA: sendCommand OK
LORA: configureIFChain8(...)
IF8: 1,1,-200000,250000,7
LORA: send_cmd: 23 36 08 00 01 01 c0 f2 fc ff 02 02 14 0d
LORA: recv_rpl: 23 36 01 00 00 5a 0d
LORA: sendCommand OK
LORA: configureIFChain9(...)
IF9: 1,1,300000,125000,50000
LORA: send_cmd: 23 37 0b 00 01 01 e0 93 04 00 03 50 c3 00 00 f4 0d
LORA: recv_rpl: 23 37 01 00 00 5b 0d
LORA: sendCommand OK
LORA: send_cmd: 23 40 01 00 34 98 0d
LORA: recv_rpl: 23 40 01 00 00 64 0d
LORA: sendCommand OK
LORA: send_cmd: 23 31 01 00 00 55 0d
LORA: recv_rpl: 23 31 01 00 00 55 0d
LORA: sendCommand OK
LORA: send_cmd: 23 30 01 00 00 54 0d
MON: SYS Stack size: 2870
MON: heap usage: 152KB (233KB), free: 187KB
LORA: recv_rpl: 23 30 01 00 00 54 0d
LORA: sendCommand OK
LORA: configLora OK
LORA: Configuration succeeded
LORA: Starting operation