mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 14:38:30 -04:00
DataFlash: allow use of a smaller writebuf for PX4v1
this fixes logging on PX4v1
This commit is contained in:
parent
8fcc96bb79
commit
9d846d5f2a
@ -105,8 +105,19 @@ void DataFlash_File::Init(const struct LogStructure *structure, uint8_t num_type
|
||||
if (_writebuf != NULL) {
|
||||
free(_writebuf);
|
||||
}
|
||||
|
||||
/*
|
||||
if we can't allocate the full writebuf then try reducing it
|
||||
until we can allocate it
|
||||
*/
|
||||
while (_writebuf == NULL && _writebuf_size >= _writebuf_chunk) {
|
||||
_writebuf = (uint8_t *)malloc(_writebuf_size);
|
||||
if (_writebuf == NULL) {
|
||||
_writebuf_size /= 2;
|
||||
}
|
||||
}
|
||||
if (_writebuf == NULL) {
|
||||
hal.console->printf("Out of memory for logging\n");
|
||||
return;
|
||||
}
|
||||
_writebuf_head = _writebuf_tail = 0;
|
||||
|
@ -67,7 +67,7 @@ private:
|
||||
|
||||
// write buffer
|
||||
uint8_t *_writebuf;
|
||||
const uint16_t _writebuf_size;
|
||||
uint16_t _writebuf_size;
|
||||
const uint16_t _writebuf_chunk;
|
||||
volatile uint16_t _writebuf_head;
|
||||
volatile uint16_t _writebuf_tail;
|
||||
|
Loading…
Reference in New Issue
Block a user