Closed avbentem closed 6 years ago
Thanks very much @avbentem !
There's an update coming up, I'll check whether we can incorporate this as well.
Hi @avbentem,
Thank for your PR. Great that you managed to stop the reboots. We are working on the issue to solve the root cause of the communication failures (more on it later today on the forum). Your PR is clean and does not harm. We will merge it and generate a beta firmware, while solving the root cause.
Thanks again
This adds flushing the LoRa UART RX buffer each time a command is about to be sent, and will also log the flushed bytes if debugging is enabled.
In the original code, flushing of the RX buffer is only done for the first command in
configLora
. That would still make a subsequent step in the configuration fail when encountering, e.g., just a single newline rather than a proper reply (that starts withLORA_FRAME_START
,0x23
, followed by a byte that confirms the command that was just sent).For me, this fix solves issue #1, the endless reboot loop when activating the gateway.
Notes
For me, RX flushing is mostly only effective once: when invoking
configureRXChain(0, ...)
I consistently still see a single\r
or0x0D
CR in the receive buffer. However, when enabling logging, one can see another CR was already printed (and hence consumed) for therecv_rpl
reply of the previous command, beinggetVersion()
. So where does this excessive CR originate from?LORA_COMMAND_VERSION
output two CRs for some revisions of the LoRa module?I sometimes also see RX flushing being effective before the very first command, then showing a few (random?) bytes; maybe the buffer is not clean after a reboot? I did not investigate.
The code uses
status *= configure...
which forcesstatus = false
if one of the steps fails, but still executes all steps even if one has already failed. That makes debugging hard, so I added some additional logging. (I feel one should consider something likestatus &= configure...
orstatus = status && configure...
instead.)I've not encountered the new logging for
LORA: UART TIMEOUT
.Tested with EU-868, and a LoRa module that shows at its bottom side:
Some logging is included below to show where
LORA: flushing
is printed for me.Logging
The following log shows the one occurrence of
LORA: flushing: 0d
.For me (and I've seen it in other people's logs as well) a lot of serial debug output gets lost at 115,200 baud. Even at 921,600 baud the output can be very confusing, as lines (partially) go missing or are merged into something that might look feasible but is rubbish. It seems the firmware would benefit greatly from logging functions that await for their output buffer to clear before continuing.
This log has been created by:
In
system_init.c
, usingSYS_ERROR_DEBUG
:In
system_config.h
, using:Enabling some more logging that is commented out in the code.
Replacing
SYS_CONSOLE_PRINT
withSYS_PRINT
as otherwise I would not see the output.Using
"%02x"
rather than"%#x"
to print hexadecimal values with leading zeroes.