LowPowerLab Forum

Hardware support => Moteino M0 => Topic started by: MVCutter on September 05, 2019, 10:43:57 AM

Title: Hangs after first Radio receive when using RTCZero to sleep
Post by: MVCutter on September 05, 2019, 10:43:57 AM
Please see the attached sketch. I think I have the hang narrowed down to the Receive method code around the radio (lines 230 to 248). After the first time the node receives something from my gateway the device responds and freezes. I put in some debugging code (line 227) to hard code a received request and this does not cause the hang when I comment out lines 230 to 248.

If I just toss in a delay(5000); and not use the RTCZero functionality the application doesn't hang.

The goal is to sleep the node, wake when a request comes in (or after x amount of seconds to do work), return to sleep.

I'm sure I'm doing something silly, but I'm just not seeing it.

Thanks in advance for your help.
Title: Re: Hangs after first Radio receive when using RTCZero to sleep
Post by: MVCutter on September 05, 2019, 08:38:20 PM
Seems like it was something to do with my char buffer I was storing the gateway request in. I merged the receive method into the loop and made the buffer a local variable and its no longer locking.
Title: Re: Hangs after first Radio receive when using RTCZero to sleep
Post by: Felix on September 10, 2019, 10:22:36 AM
Thanks for the follow up, good to know its not something in the lib.
Interesting to see how many threads reveal char arrays (C strings), buffer overflows, memory leaks, and other variable mishaps as the root cause of some locking behavior. Extra care is needed with these data types, especially when manipulating them and using reference/dereference operators on them.