This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

I want to log time stamp in units of one second using app_timer

The problem is shown in the picture below.

It is normal for 10 seconds after activating the timer.

As you can see in the picture, the value of the time stamp changes abnormally.

This is the timer handler source code.

There is nothing special.

After 10 seconds, lorawan_send function is excuted, there is a problem here.

Using sprintf is a problem.

I have omitted sprintf and it works noramlly.

It is the process of converting a buffer to a byte string and should not be omitted.

I uploaded the main source code for reference.

How can i solve that problem?

Parents
  • Hi 

    If I understand you correctly the time_stamp_timer_handler(..) function appears to run at 1 second intervals as expected, but the value of the time_stamp variable is corrupted?

    Then the most obvious problem would be that the time_stamp variable is located after the confirmed_send_packet buffer in memory, and somehow the sprintf function is writing too far into the confirmed_send_packet buffer and overwriting the time_stamp variable instead. 

    808466482 corresponds to 0x30303832, or "0082" in Ascii, which strengthens this theory. 

    What is the size of the confirmed_send_packet array?

    Best regards
    Torbjørn

Reply
  • Hi 

    If I understand you correctly the time_stamp_timer_handler(..) function appears to run at 1 second intervals as expected, but the value of the time_stamp variable is corrupted?

    Then the most obvious problem would be that the time_stamp variable is located after the confirmed_send_packet buffer in memory, and somehow the sprintf function is writing too far into the confirmed_send_packet buffer and overwriting the time_stamp variable instead. 

    808466482 corresponds to 0x30303832, or "0082" in Ascii, which strengthens this theory. 

    What is the size of the confirmed_send_packet array?

    Best regards
    Torbjørn

Children
Related