I posted a question about missing sensor MQTT events last night. It occurred to me that if I could trace the execution flow (as it happens, rather than in my head) it might help either fix the problem and patch it or at least provide more info to the devs.
I was just poking around to see what the best way to allow a remote debugger connection would be (either GDB stubs compiled in or with gdbserver).
Any tips from the devs here?
Everything looks nicely daemonized, if there is a simple executable equivalent someone could share, that would be great! Or is there a debug flag setting somewhere?
(I’m using CLion on a mac, so a network GDB connection would hopefully get me up-and-running).
You can turn on debug prints. To do so, open defines.h, at the top, uncomment the line that says ‘#define ENABLE_DEBUG’. Save, and recompile the firmware.
To see the prints, you need to run the firmware manually. First, stop the background task by:
sudo /etc/init.d/OpenSprinkler.sh stop
then in the folder where you installed OpenSprinkler firmware, do:
sudo ./OpenSprinkler
That was helpful in two ways:
1. I can see the debug prints
2. Was also able to launch that executable via “sudo gdbserver localhost:8899 ./OpenSprinkler” and attach via a network GDB connection.
Note for anyone else doing this you have to add a “-g” flag to the g++ command in ./build.sh (or run it manually) to generate the symbol stubs.
Obviously a maneuver for debugging.
I did figure out why flow-sensor related sensor1 changes weren’t getting logged to MQTT. I’ll follow up to my comment in the 2.1.9(4) release thread.