mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-20 15:48:29 -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) {
|
if (_writebuf != NULL) {
|
||||||
free(_writebuf);
|
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);
|
_writebuf = (uint8_t *)malloc(_writebuf_size);
|
||||||
if (_writebuf == NULL) {
|
if (_writebuf == NULL) {
|
||||||
|
_writebuf_size /= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_writebuf == NULL) {
|
||||||
|
hal.console->printf("Out of memory for logging\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_writebuf_head = _writebuf_tail = 0;
|
_writebuf_head = _writebuf_tail = 0;
|
||||||
|
@ -67,7 +67,7 @@ private:
|
|||||||
|
|
||||||
// write buffer
|
// write buffer
|
||||||
uint8_t *_writebuf;
|
uint8_t *_writebuf;
|
||||||
const uint16_t _writebuf_size;
|
uint16_t _writebuf_size;
|
||||||
const uint16_t _writebuf_chunk;
|
const uint16_t _writebuf_chunk;
|
||||||
volatile uint16_t _writebuf_head;
|
volatile uint16_t _writebuf_head;
|
||||||
volatile uint16_t _writebuf_tail;
|
volatile uint16_t _writebuf_tail;
|
||||||
|
Loading…
Reference in New Issue
Block a user