Beispiel #1
0
void AP_Stats::update()
{
    const uint32_t now_ms = AP_HAL::millis();
    if (now_ms -  last_flush_ms > flush_interval_ms) {
        update_flighttime();
        update_runtime();
        flush();
        last_flush_ms = now_ms;
    }
    const uint32_t params_reset = params.reset;
    if (params_reset != reset || params_reset == 0) {
        params.bootcount.set_and_save_ifchanged(params_reset == 0 ? 1 : 0);
        params.flttime.set_and_save_ifchanged(0);
        params.runtime.set_and_save_ifchanged(0);
        uint32_t system_clock = 0; // in seconds
        uint64_t rtc_clock_us;
        if (AP::rtc().get_utc_usec(rtc_clock_us)) {
            system_clock = rtc_clock_us / 1000000;
            // can't store Unix seconds in a 32-bit float.  Change the
            // time base to Jan 1st 2016:
            system_clock -= 1451606400;
        }
        params.reset.set_and_save_ifchanged(system_clock);
        copy_variables_from_parameters();
    }

}
Beispiel #2
0
int settings_save(void)
{
    update_runtime();
#ifdef HAVE_RTC_RAM
    /* this will be done in the storage_callback if
       target doesnt have rtc ram */
    write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
#endif
    register_storage_idle_func(flush_config_block_callback);
    return 0;
}
Beispiel #3
0
void status_save(void)
{
    update_runtime();
#ifdef HAVE_RTC_RAM
    /* this will be done in the storage_callback if
       target doesnt have rtc ram */
    write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
#else
    register_storage_idle_func(flush_global_status_callback);
#endif
}