Closed yuchangyuan closed 4 years ago
Weird, I thought I tested this. I may have introduced a bug in 9d137b4f5f8d88131f2c0b4dd2e638cf73cfec5a. Or in another commit when I was making changes to make the console shared between the dev board and the simulator. I'll look into this when I get a chance.
I had to revert even further, to commit fbf2187da4e0e6828c11929be720f3ab243bdd40, to avoid this problem.
Hmm, maybe it's more likely that this commit https://github.com/sudomesh/disaster-radio/commit/43075131149f1456c2364c3cf8fbb5121cefae65 which updated LoRaLayer2 caused this bug? Or maybe try updating to the latest commit of LoRaLayer2 (https://github.com/sudomesh/LoRaLayer2/commit/b071e53ceb6d2530fa2de28019165fd7534a378f), not sure where I left off there, but it's possible I neglected to update the commit in platformio.ini.
I've managed to compile the platform myself, having to remove tinygps to make it work for whatever reason, but i'm now facing this issue. The only reason i was unable to use the precompiled bin which didn't do this, is that the frequency was set wrong for my boards, which are cheaper 433mhz models Solved it, the issue seems to have been introduced between v1.0.0 and master, so compiling v1.0.0 without tinygps worked perfectly
I found the cause of this bug. The culprit is the following line in src/middleware/Console.cpp,
memset(response.message, 0, DATAGRAM_MESSAGE);
Looks like I forgot to update the DATAGRAM_MESSAGE
constant to match with the updates to LoRaLayer2. This was causing a buffer overflow during this memset and triggering a stack smashing failure. The quick solution is to update DATAGRAM_MESSAGE
to be the correct number (i.e. 238). The right solution is to move this constant in to LoRaLayer2.h
and use that instead, since that is where all routing protocol related changes are made.
Sorry about this problem, I've previously struggled with how to architecture this project. That DATAGRAM_MESSAGE
constant is a leftover from when I defined the datagram struct in the Disaster Radio code and not in LoRaLayer2.
I'll push a commit shortly that will make the quick fix. I still need to test the right solution of moving DATAGRAM_MESSAGE to LoRaLayer2.h to make sure it doesn't have any unintended side effects.
I should also point out that I was only memsetting the message
portion of the response
datagram, which is wrong and would cause a buffer overflow, because the DATAGRAM_MESSAGE
constant represents the total length of the datagram (i.e. header+message). Anyway, I'll fix that also, by memsetting the whole datagram.
Device will restart after input any command.
firmware revision: 44cf2dfc75a68d6309bbc8a20345a3e2ef2dee47 hardware: TTGOv2
below is log for
platformio device monitor
with/help
command: