MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / _flash_write_data

Method _flash_write_data

libraries/AP_HAL_SITL/Storage.cpp:333–349  ·  view source on GitHub ↗

callback to write data to flash */

Source from the content-addressed store, hash-verified

331 callback to write data to flash
332 */
333bool Storage::_flash_write_data(uint8_t sector, uint32_t offset, const uint8_t *data, uint16_t length)
334{
335 size_t base_address = sitl_flash_getpageaddr(sector);
336 bool ret = sitl_flash_write(base_address+offset, data, length);
337 if (!ret && _flash_erase_ok()) {
338 // we are getting flash write errors while disarmed. Try
339 // re-writing all of flash
340 uint32_t now = AP_HAL::millis();
341 if (now - _last_re_init_ms > 5000) {
342 _last_re_init_ms = now;
343 bool ok = _flash.re_initialise();
344 hal.console->printf("Storage: failed at %u:%u for %u - re-init %u\n",
345 (unsigned)sector, (unsigned)offset, (unsigned)length, (unsigned)ok);
346 }
347 }
348 return ret;
349}
350
351/*
352 callback to read data from flash

Callers

nothing calls this directly

Calls 5

sitl_flash_getpageaddrFunction · 0.85
sitl_flash_writeFunction · 0.85
re_initialiseMethod · 0.80
millisFunction · 0.70
printfMethod · 0.45

Tested by

no test coverage detected