diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2014-04-22 09:57:28 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-04-22 09:57:28 +0200 |
commit | af56e65a37bf32cf3c6f1c0eb90626d61127c559 (patch) | |
tree | 05d2e19cfc7f395da0666bbd1becf51a0ab00442 | |
parent | 5b7209639d42290dc5b1e3fc53fc81a455d75b51 (diff) | |
parent | f0e28a60ca216ec147b359eef5500f190f192c82 (diff) | |
download | px4-firmware-af56e65a37bf32cf3c6f1c0eb90626d61127c559.tar.gz px4-firmware-af56e65a37bf32cf3c6f1c0eb90626d61127c559.tar.bz2 px4-firmware-af56e65a37bf32cf3c6f1c0eb90626d61127c559.zip |
Merge branch 'master' into ekf_params
-rw-r--r-- | src/modules/dataman/dataman.c | 19 | ||||
-rw-r--r-- | src/modules/dataman/dataman.h | 2 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/modules/dataman/dataman.c b/src/modules/dataman/dataman.c index 34d20e485..c132b0040 100644 --- a/src/modules/dataman/dataman.c +++ b/src/modules/dataman/dataman.c @@ -44,7 +44,9 @@ #include <stdlib.h> #include <fcntl.h> #include <systemlib/systemlib.h> +#include <systemlib/err.h> #include <queue.h> +#include <string.h> #include "dataman.h" @@ -594,6 +596,20 @@ task_main(int argc, char *argv[]) sem_init(&g_work_queued_sema, 1, 0); + /* See if the data manage file exists and is a multiple of the sector size */ + g_task_fd = open(k_data_manager_device_path, O_RDONLY | O_BINARY); + if (g_task_fd >= 0) { + /* File exists, check its size */ + int file_size = lseek(g_task_fd, 0, SEEK_END); + if ((file_size % k_sector_size) != 0) { + warnx("Incompatible data manager file %s, resetting it", k_data_manager_device_path); + close(g_task_fd); + unlink(k_data_manager_device_path); + } + else + close(g_task_fd); + } + /* Open or create the data manager file */ g_task_fd = open(k_data_manager_device_path, O_RDWR | O_CREAT | O_BINARY); @@ -603,7 +619,7 @@ task_main(int argc, char *argv[]) return -1; } - if (lseek(g_task_fd, max_offset, SEEK_SET) != max_offset) { + if ((unsigned)lseek(g_task_fd, max_offset, SEEK_SET) != max_offset) { close(g_task_fd); warnx("Could not seek data manager file %s", k_data_manager_device_path); sem_post(&g_init_sema); /* Don't want to hang startup */ @@ -776,4 +792,3 @@ dataman_main(int argc, char *argv[]) exit(1); } - diff --git a/src/modules/dataman/dataman.h b/src/modules/dataman/dataman.h index a70638ccc..33c9fcd15 100644 --- a/src/modules/dataman/dataman.h +++ b/src/modules/dataman/dataman.h @@ -79,7 +79,7 @@ extern "C" { } dm_reset_reason; /* Maximum size in bytes of a single item instance */ - #define DM_MAX_DATA_SIZE 126 + #define DM_MAX_DATA_SIZE 124 /* Retrieve from the data manager store */ __EXPORT ssize_t |