[settings] test prog and minor updates for persistent settings

This commit is contained in:
Felix Ruess
2014-07-27 14:25:38 +02:00
parent 4e394ee9a7
commit e382617c0f
15 changed files with 199 additions and 146 deletions
+2
View File
@@ -1,3 +1,5 @@
<!DOCTYPE airframe SYSTEM "../airframe.dtd">
<!-- this is a quadrotor frame equiped with Lisa/M and MKK motor controllers -->
<airframe name="setup_lisam2">
+11
View File
@@ -0,0 +1,11 @@
<!DOCTYPE airframe SYSTEM "airframe.dtd">
<!-- simple airframe file to test persistent settings, use with settings/test_settings.xml -->
<airframe name="test_settings">
<firmware name="test_progs">
<target name="test_settings" board="lisa_m_1.0"/>
</firmware>
</airframe>
+10
View File
@@ -329,6 +329,16 @@
settings=" settings/setup_actuators.xml"
gui_color="blue"
/>
<aircraft
name="test_settings"
ac_id="29"
airframe="airframes/test_settings.xml"
radio="radios/cockpitSX.xml"
telemetry="telemetry/dummy.xml"
flight_plan="flight_plans/dummy.xml"
settings=" settings/test_settings.xml"
gui_color="blue"
/>
<aircraft
name="yapa_chimu_spi"
ac_id="27"
+18
View File
@@ -344,3 +344,21 @@ test_radio_control.srcs += $(COMMON_TEST_SRCS)
test_radio_control.CFLAGS += $(COMMON_TELEMETRY_CFLAGS)
test_radio_control.srcs += $(COMMON_TELEMETRY_SRCS)
test_radio_control.srcs += test/subsystems/test_radio_control.c
#
# test_settings :
#
# configuration
# MODEM_PORT :
# MODEM_BAUD :
#
test_settings.ARCHDIR = $(ARCH)
test_settings.CFLAGS += $(COMMON_TEST_CFLAGS)
test_settings.srcs += $(COMMON_TEST_SRCS)
test_settings.CFLAGS += $(COMMON_TELEMETRY_CFLAGS)
test_settings.srcs += $(COMMON_TELEMETRY_SRCS)
test_settings.srcs += subsystems/settings.c
test_settings.srcs += $(SRC_ARCH)/subsystems/settings_arch.c
test_settings.srcs += test/subsystems/test_settings.c
test_settings.CFLAGS += -DUSE_PERSISTENT_SETTINGS
+1 -1
View File
@@ -8,7 +8,7 @@
<dl_setting var="setting_b" min="0" step="1" max="42" shortname ="b" persistent="true"/>
<dl_setting var="setting_c" min="0" step="1" max="42" shortname ="c" persistent="true"/>
<dl_setting var="setting_d" min="0" step="1" max="42" shortname ="d" persistent="true" />
<dl_setting var="settings_store_now" min="0" step="1" max="1" shortname ="store" handler="StoreSettings" module="subsystems/settings"/>
<dl_setting var="settings_store_flag" min="0" step="1" max="1" shortname="store" handler="StoreSettings" module="subsystems/settings"/>
</dl_settings>
</dl_settings>
@@ -1,6 +1,4 @@
/*
* Paparazzi persistent settings low level flash routines lpc21
*
* Copyright (C) 2011 Martin Mueller <martinmm@pfump.org>
*
* This file is part of Paparazzi.
@@ -22,21 +20,24 @@
*
*/
/*
LPC2148 flash data is located in the last available page
0x00000000: Paparazzi bootloader (16k)
0x00004000: Paparazzi code (480k)
0x0007C000: persistent settings (4k)
0x0007D000: Philips/NXP bootloader (12k)
data flash_addr
data_size flash_end - FSIZ
checksum flash_end - FCHK
LPC21: minimum write size 256 bytes, endurance 100k cycles,
max sector erase time 400ms, max prog time 1ms per 256 bytes
*/
/**
* @file arch/lpc21/subsystems/settings_arch.c
* Persistent settings low level flash routines lpc21.
*
* LPC2148 flash data is located in the last available page
*
* 0x00000000: Paparazzi bootloader (16k)
* 0x00004000: Paparazzi code (480k)
* 0x0007C000: persistent settings (4k)
* 0x0007D000: Philips/NXP bootloader (12k)
*
* data flash_addr
* data_size flash_end - FSIZ
* checksum flash_end - FCHK
*
* LPC21: minimum write size 256 bytes, endurance 100k cycles,
* max sector erase time 400ms, max prog time 1ms per 256 bytes
*/
#include "subsystems/settings.h"
@@ -1,31 +0,0 @@
/*
* Paparazzi persistent settings low level flash routines lpc21
*
* Copyright (C) 2011 Martin Mueller <martinmm@pfump.org>
*
* This file is part of Paparazzi.
*
* Paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#ifndef LPC21_SUBSYSTEMS_SETTINGS_H
#define LPC21_SUBSYSTEMS_SETTINGS_H
#endif /* LPC21_SUBSYSTEMS_SETTINGS_H */
@@ -1,5 +1,4 @@
/*
*
* Copyright (C) 2009-2013 The Paparazzi Team
*
* This file is part of paparazzi.
@@ -27,3 +26,16 @@
* Unimplemented.
*/
#include "subsystems/settings.h"
int32_t persistent_write(uint32_t ptr, uint32_t size) {
ptr=ptr;
size=size;
return -1;
}
int32_t persistent_read(uint32_t ptr, uint32_t size) {
ptr=ptr;
size=size;
return -1;
}
@@ -1,35 +0,0 @@
/*
*
* Copyright (C) 2009-2013 The Paparazzi Team
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* @file arch/omap/subsystems/settings_arch.h
* OMAP arch Persistent settings.
*
* Unimplemented.
*/
#ifndef OMAP_SUBSYSTEMS_SETTINGS_H
#define OMAP_SUBSYSTEMS_SETTINGS_H
#endif /* OMAP_SUBSYSTEMS_SETTINGS_H */
@@ -1,14 +1,41 @@
#include "subsystems/settings.h"
/*
* Copyright (C) 2009-2013 The Paparazzi Team
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* @file arch/sim/subsystems/settings_arch.c
* Sim arch Persistent settings.
*
* Unimplemented.
*/
#include "subsystems/settings.h"
int32_t persistent_write(uint32_t ptr, uint32_t size) {
ptr=ptr;
size=size;
return 0;
return -1;
}
int32_t persistent_read(uint32_t ptr, uint32_t size) {
ptr=ptr;
size=size;
return 0;
return -1;
}
@@ -1,6 +1,4 @@
/*
* Paparazzi persistent settings low level flash routines stm32
*
* Copyright (C) 2011 Martin Mueller <martinmm@pfump.org>
*
* This file is part of Paparazzi.
@@ -22,16 +20,17 @@
*
*/
/*
flash data is located in the last page/sector of flash
data flash_addr
data_size flash_end - FSIZ
checksum flash_end - FCHK
STM32: minimum write size 2 bytes, endurance 10k cycles,
max sector erase time 40ms, max prog time 70us per 2 bytes
*/
/**
* @file arch/lpc21/subsystems/settings_arch.c
* Persistent settings low level flash routines stm32.
*
* data flash_addr
* data_size flash_end - FSIZ
* checksum flash_end - FCHK
*
* STM32: minimum write size 2 bytes, endurance 10k cycles,
* max sector erase time 40ms, max prog time 70us per 2 bytes
*/
#include "subsystems/settings.h"
@@ -243,7 +242,7 @@ static int32_t pflash_program_bytes(struct FlashInfo* flash __attribute__((unuse
uint32_t src __attribute__((unused)),
uint32_t size __attribute__((unused)),
uint32_t chksum __attribute__((unused))) {
return 0;
return -1;
}
#endif
@@ -1,31 +0,0 @@
/*
* Paparazzi persistent settings low level flash routines stm32
*
* Copyright (C) 2011 Martin Mueller <martinmm@pfump.org>
*
* This file is part of Paparazzi.
*
* Paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#ifndef STM32_SUBSYSTEMS_SETTINGS_H
#define STM32_SUBSYSTEMS_SETTINGS_H
#endif /* STM32_SUBSYSTEMS_SETTINGS_H */
+50 -5
View File
@@ -1,22 +1,67 @@
/*
* Copyright (C) 2009-2014 The Paparazzi Team
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* @file subsystems/settings.c
* Persistent settings interface.
*
*/
#include "subsystems/settings.h"
struct PersistentSettings pers_settings;
bool_t settings_store_now;
/** flag for setting feedback.
* if TRUE, was stored sucessfully.
* Also settings still need a variable,
* pure function call not possible yet.
*/
bool_t settings_store_flag;
void settings_init(void) {
#if USE_PERSISTENT_SETTINGS
if (persistent_read((uint32_t)&pers_settings, sizeof(struct PersistentSettings)))
return; // return -1 ?
/* from generated/settings.h */
persistent_settings_load();
#endif
}
void settings_store(void) {
/** store settings marked as persistent to flash
* @return 0 on success
*/
int32_t settings_store(void) {
#if USE_PERSISTENT_SETTINGS
persistent_settings_store();
persistent_write((uint32_t)&pers_settings, sizeof(struct PersistentSettings));
if (settings_store_flag) {
/* from generated/settings.h */
persistent_settings_store();
if (!persistent_write((uint32_t)&pers_settings, sizeof(struct PersistentSettings))) {
/* persistent write was successful */
settings_store_flag = TRUE;
return 0;
}
}
#endif
settings_store_flag = FALSE;
return -1;
}
+30 -3
View File
@@ -1,14 +1,41 @@
/*
* Copyright (C) 2009-2014 The Paparazzi Team
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* @file subsystems/settings.h
* Persistent settings interface.
*
*/
#ifndef SUBSYSTEMS_SETTINGS_H
#define SUBSYSTEMS_SETTINGS_H
#include "std.h"
extern void settings_init(void);
extern void settings_store(void);
extern int32_t settings_store(void);
extern bool_t settings_store_now;
extern bool_t settings_store_flag;
#define settings_StoreSettings(_v) { settings_store_now = _v; settings_store(); }
#define settings_StoreSettings(_v) { settings_store_flag = _v; settings_store(); }
#include "generated/settings.h"
+4 -6
View File
@@ -32,8 +32,6 @@
#include "mcu_periph/uart.h"
#include "messages.h"
#include "my_debug_servo.h"
static inline void main_init( void );
static inline void main_periodic( void );
static inline void main_event( void );
@@ -68,8 +66,8 @@ static inline void main_init( void ) {
static inline void main_periodic( void ) {
RunOnceEvery(100, {
DOWNLINK_SEND_ALIVE(DefaultChannel, DefaultDevice, 16, MD5SUM);
PeriodicSendDlValue(DefaultChannel);
DOWNLINK_SEND_ALIVE(DefaultChannel, DefaultDevice, 16, MD5SUM);
PeriodicSendDlValue(DefaultChannel, DefaultDevice);
});
}
@@ -86,11 +84,11 @@ void dl_parse_msg(void) {
switch (msg_id) {
case DL_PING: {
DOWNLINK_SEND_PONG(DefaultChannel);
DOWNLINK_SEND_PONG(DefaultChannel, DefaultDevice);
}
break;
case DL_SETTING:
if(DL_SETTING_ac_id(dl_buffer) == AC_ID) {
if (DL_SETTING_ac_id(dl_buffer) == AC_ID) {
uint8_t i = DL_SETTING_index(dl_buffer);
float val = DL_SETTING_value(dl_buffer);
DlSetting(i, val);