icyphy / lf-buckler

Programming an nRF embedded board with a Berkeley Buckler daughter card using Lingua Franca.
BSD 2-Clause "Simplified" License
7 stars 0 forks source link

After compiling on Arch Linux, flashed binary runs as fast as possible, ignoring physical time constraints #7

Closed lhstrh closed 2 years ago

lhstrh commented 2 years ago

The exact same program and hardware yield expected behavior when compiled on macOS. My guess is that there is a data representation issue that causes this... The behavior can be observed via printed output via make rtt or through the LEDs (they blink so fast when Blink.lf is deployed that it appears as if they don't blink at all).

edwardalee commented 2 years ago

Ugh. This could happen if lf_clock_gettime() returns an unexpectedly large time, leading the system to believe that physical time is way ahead of logical time. Perhaps call this function when the LEDs are toggled? It should give the number of microseconds since start of execution.

On line 158 of lf_nrf52_support.c is the only place I can see where physical time may be getting a big jump:

        _lf_time_epoch_offset += (1LL << 32) * 1000;

Perhaps appending a printf to this line (or setting a gdb breakpoint) would reveal something? This line should not execute until 71 minutes into execution of the program. If it executes early, this could explain the problem.

lhstrh commented 2 years ago

This was solved in 78acdd20960b54299bcc18bd82a8579c416b7f06, but the implementation that had this flaw is subsumed by #11 which hasn't been tested on Linux yet. @tessxd: would you mind testing with an updated main branch on Linux?