New param interface for microSD and EEPROM

This commit is contained in:
Lorenz Meier
2012-10-31 16:31:21 +01:00
parent 8dcde7f8cd
commit 0ddfd7c75c
5 changed files with 141 additions and 108 deletions
+6 -33
View File
@@ -268,33 +268,6 @@ void tune_confirm() {
ioctl(buzzer, TONE_SET_ALARM, 3);
}
static const char *parameter_file = "/eeprom/parameters";
static int pm_save_eeprom(bool only_unsaved)
{
/* delete the file in case it exists */
unlink(parameter_file);
/* create the file */
int fd = open(parameter_file, O_WRONLY | O_CREAT | O_EXCL);
if (fd < 0) {
warn("opening '%s' for writing failed", parameter_file);
return -1;
}
int result = param_export(fd, only_unsaved);
close(fd);
if (result != 0) {
unlink(parameter_file);
warn("error exporting parameters to '%s'", parameter_file);
return -2;
}
return 0;
}
void do_mag_calibration(int status_pub, struct vehicle_status_s *status)
{
/* set to mag calibration mode */
@@ -496,9 +469,9 @@ void do_mag_calibration(int status_pub, struct vehicle_status_s *status)
}
/* auto-save to EEPROM */
int save_ret = pm_save_eeprom(false);
int save_ret = param_save_default();
if(save_ret != 0) {
warn("WARNING: auto-save of params to EEPROM failed");
warn("WARNING: auto-save of params to storage failed");
}
printf("[mag cal]\tscale: %.6f %.6f %.6f\n \toffset: %.6f %.6f %.6f\nradius: %.6f GA\n",
@@ -616,9 +589,9 @@ void do_gyro_calibration(int status_pub, struct vehicle_status_s *status)
close(fd);
/* auto-save to EEPROM */
int save_ret = pm_save_eeprom(false);
int save_ret = param_save_default();
if(save_ret != 0) {
warn("WARNING: auto-save of params to EEPROM failed");
warn("WARNING: auto-save of params to storage failed");
}
// char buf[50];
@@ -736,9 +709,9 @@ void do_accel_calibration(int status_pub, struct vehicle_status_s *status)
close(fd);
/* auto-save to EEPROM */
int save_ret = pm_save_eeprom(false);
int save_ret = param_save_default();
if(save_ret != 0) {
warn("WARNING: auto-save of params to EEPROM failed");
warn("WARNING: auto-save of params to storage failed");
}
//char buf[50];