From 3c09448daf5473effb28a70da3e8ec1c43243368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Mi=C5=A1i=C4=87?= Date: Fri, 18 Feb 2022 18:37:23 +0100 Subject: [PATCH] dataman: add silence flag for _file_initialize --- src/modules/dataman/dataman.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/modules/dataman/dataman.cpp b/src/modules/dataman/dataman.cpp index a9266d76d7..220471db01 100644 --- a/src/modules/dataman/dataman.cpp +++ b/src/modules/dataman/dataman.cpp @@ -113,6 +113,7 @@ static struct { } ram; }; bool running; + bool silence = false; } dm_operations_data; /** Types of function calls supported by the worker task */ @@ -565,12 +566,12 @@ _file_read(dm_item_t item, unsigned index, void *buf, size_t count) for (int i = 0; i < 2; i++) { int ret_seek = lseek(dm_operations_data.file.fd, offset, SEEK_SET); - if (ret_seek < 0) { + if ((ret_seek < 0) && !dm_operations_data.silence) { PX4_ERR("file read lseek failed %d", errno); continue; } - if (ret_seek != offset) { + if ((ret_seek != offset) && !dm_operations_data.silence) { PX4_ERR("file read lseek failed, incorrect offset %d vs %d", ret_seek, offset); continue; } @@ -584,7 +585,9 @@ _file_read(dm_item_t item, unsigned index, void *buf, size_t count) break; } else { - PX4_ERR("file read failed %d", errno); + if (!dm_operations_data.silence) { + PX4_ERR("file read failed %d", errno); + } } } @@ -700,7 +703,9 @@ _file_initialize(unsigned max_offset) if (dm_operations_data.file.fd >= 0) { // Read the mission state and check the hash struct dataman_compat_s compat_state; + dm_operations_data.silence = true; int ret = g_dm_ops->read(DM_KEY_COMPAT, 0, &compat_state, sizeof(compat_state)); + dm_operations_data.silence = false; bool incompat = true;