diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2012-08-25 19:16:12 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2012-08-25 19:16:12 +0200 |
commit | 8eeba595eee091f671bc3ed60ed2aa118a9ab4ea (patch) | |
tree | d15aefde7a6254d5ddce5b174d382ff67c849a38 /apps/systemcmds/eeprom | |
parent | f901a35bd4393523c48a73a805b0f5d451cec35d (diff) | |
download | px4-firmware-8eeba595eee091f671bc3ed60ed2aa118a9ab4ea.tar.gz px4-firmware-8eeba595eee091f671bc3ed60ed2aa118a9ab4ea.tar.bz2 px4-firmware-8eeba595eee091f671bc3ed60ed2aa118a9ab4ea.zip |
Improved param load / store text feedback, ported sensors app to new driver model, ready for merge and test
Diffstat (limited to 'apps/systemcmds/eeprom')
-rw-r--r-- | apps/systemcmds/eeprom/eeprom.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/apps/systemcmds/eeprom/eeprom.c b/apps/systemcmds/eeprom/eeprom.c index 20727e764..ed727cd33 100644 --- a/apps/systemcmds/eeprom/eeprom.c +++ b/apps/systemcmds/eeprom/eeprom.c @@ -48,6 +48,7 @@ #include <fcntl.h> #include <sys/mount.h> #include <sys/ioctl.h> +#include <sys/stat.h> #include <nuttx/i2c.h> #include <nuttx/mtd.h> @@ -99,7 +100,7 @@ int eeprom_main(int argc, char *argv[]) } } - errx(1, "expected a command, try 'start'\n\t'save_param /eeprom/params'\n\t'load_param /eeprom/params'\n\t'erase'\n"); + errx(1, "expected a command, try 'start'\n\t'save_param /eeprom/parameters'\n\t'load_param /eeprom/parameters'\n\t'erase'\n"); } @@ -174,9 +175,16 @@ eeprom_ioctl(unsigned operation) static void eeprom_save(const char *name) { + if (!started) + errx(1, "must be started first"); + if (!name) - err(1, "missing argument for device name, try '/eeprom'"); + err(1, "missing argument for device name, try '/eeprom/parameters'"); + + /* delete the file in case it exists */ + unlink(name); + /* create the file */ int fd = open(name, O_WRONLY | O_CREAT | O_EXCL); if (fd < 0) @@ -196,8 +204,11 @@ eeprom_save(const char *name) static void eeprom_load(const char *name) { + if (!started) + errx(1, "must be started first"); + if (!name) - err(1, "missing argument for device name, try '/eeprom'"); + err(1, "missing argument for device name, try '/eeprom/parameters'"); int fd = open(name, O_RDONLY); |