diff options
author | px4dev <px4@purgatory.org> | 2012-08-20 09:55:53 -0700 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2012-08-20 09:55:53 -0700 |
commit | 4ddf93bd065ef5fb0f78ce2ff6b7654841946eaa (patch) | |
tree | 1b67bbb5e68b0e34d835f4e63c438721e78ae8a2 /apps/mavlink/mavlink_parameters.c | |
parent | d17bbc7a0bdc30302df0001ddad91733064d3d11 (diff) | |
download | px4-firmware-4ddf93bd065ef5fb0f78ce2ff6b7654841946eaa.tar.gz px4-firmware-4ddf93bd065ef5fb0f78ce2ff6b7654841946eaa.tar.bz2 px4-firmware-4ddf93bd065ef5fb0f78ce2ff6b7654841946eaa.zip |
Tweak the MAVlink parameter load/save path to deal with NXFFS.
Diffstat (limited to 'apps/mavlink/mavlink_parameters.c')
-rw-r--r-- | apps/mavlink/mavlink_parameters.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/apps/mavlink/mavlink_parameters.c b/apps/mavlink/mavlink_parameters.c index ab788c461..bc13f0540 100644 --- a/apps/mavlink/mavlink_parameters.c +++ b/apps/mavlink/mavlink_parameters.c @@ -43,6 +43,7 @@ #include <assert.h> #include <stdio.h> #include <fcntl.h> +#include <unistd.h> #include <stdbool.h> #include <string.h> #include <systemlib/param/param.h> @@ -145,20 +146,27 @@ int mavlink_pm_send_param(param_t param) return mavlink_missionlib_send_message(&tx_msg); } +static const char *mavlink_parameter_file = "/eeprom/parameters"; + static int mavlink_pm_save_eeprom() { - const char* name = "/eeprom"; - int fd = open("/eeprom", O_WRONLY | O_CREAT | O_EXCL); + unlink(mavlink_parameter_file); + + int fd = open(mavlink_parameter_file, O_WRONLY | O_CREAT | O_EXCL); - if (fd < 0) - warn(1, "opening '%s' failed", name); + if (fd < 0) { + warn(1, "opening '%s' failed", mavlink_parameter_file); + return -1; + } int result = param_export(fd, false); close(fd); if (result < 0) { - warn(1, "error exporting to '%s'", name); + unlink(mavlink_parameter_file); + warn(1, "error exporting to '%s'", mavlink_parameter_file); + return -1; } return 0; @@ -167,17 +175,20 @@ mavlink_pm_save_eeprom() static int mavlink_pm_load_eeprom() { - const char* name = "/eeprom"; - int fd = open(name, O_RDONLY); + int fd = open(mavlink_parameter_file, O_RDONLY); - if (fd < 0) - warn(1, "open '%s' failed", name); + if (fd < 0) { + warn(1, "open '%s' failed", mavlink_parameter_file); + return -1; + } int result = param_import(fd); close(fd); - if (result < 0) - warn(1, "error importing from '%s'", name); + if (result < 0) { + warn(1, "error importing from '%s'", mavlink_parameter_file); + return -1; + } return 0; } |