mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-19 19:04:33 +08:00
parameters: avoid printing errors for erased flash devices
Errors: ERROR [parameters] param import failed (-1) attempt 1, retrying ERROR [parameters] param import failed (-1) attempt 2, retrying ERROR [parameters] param import failed (-1) attempt 3, retrying ERROR [parameters] param import failed (-1) attempt 4, retrying ERROR [param] importing from '/fs/mtd_caldata' failed (-1)
This commit is contained in:
@@ -1426,6 +1426,10 @@ param_import_internal(int fd, bool mark_saved)
|
||||
decoder.total_decoded_size);
|
||||
return 0;
|
||||
|
||||
} else if (result == -ENODATA) {
|
||||
PX4_DEBUG("BSON: no data");
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
PX4_ERR("param import failed (%d) attempt %d, retrying", result, attempt);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ bson_decoder_init_file(bson_decoder_t decoder, int fd, bson_decoder_callback cal
|
||||
CODER_KILL(decoder, "failed reading length");
|
||||
}
|
||||
|
||||
debug("total document size = %d", decoder->total_document_size);
|
||||
debug("total document size = %" PRIi32, decoder->total_document_size);
|
||||
|
||||
/* ready for decoding */
|
||||
return 0;
|
||||
@@ -176,7 +176,7 @@ bson_decoder_init_buf(bson_decoder_t decoder, void *buf, unsigned bufsize, bson_
|
||||
CODER_KILL(decoder, "failed reading length");
|
||||
}
|
||||
|
||||
debug("total document size = %d", decoder->total_document_size);
|
||||
debug("total document size = %" PRIi32, decoder->total_document_size);
|
||||
|
||||
if ((decoder->total_document_size > 0) && (decoder->total_document_size > (int)decoder->bufsize)) {
|
||||
CODER_KILL(decoder, "document length larger than buffer");
|
||||
@@ -235,6 +235,10 @@ bson_decoder_next(bson_decoder_t decoder)
|
||||
if (decoder->node.type == BSON_EOO) {
|
||||
decoder->node.name[0] = '\0';
|
||||
|
||||
} else if ((int)decoder->node.type == 0xff) { // indicates erased FLASH
|
||||
decoder->dead = true;
|
||||
return -ENODATA;
|
||||
|
||||
} else {
|
||||
|
||||
/* get the node name */
|
||||
@@ -526,7 +530,7 @@ bson_encoder_fini(bson_encoder_t encoder)
|
||||
// record document size
|
||||
if (encoder->fd > -1) {
|
||||
if (lseek(encoder->fd, 0, SEEK_SET) == 0) {
|
||||
debug("writing document size %d to beginning of file", encoder->total_document_size);
|
||||
debug("writing document size %" PRIi32 " to beginning of file", encoder->total_document_size);
|
||||
|
||||
if (::write(encoder->fd, &encoder->total_document_size,
|
||||
sizeof(encoder->total_document_size)) != sizeof(encoder->total_document_size)) {
|
||||
|
||||
Reference in New Issue
Block a user