diff --git a/flight/OpenPilot/Modules/Example/examplemodevent.c b/flight/OpenPilot/Modules/Example/examplemodevent.c index d27a0d691..3b74ab223 100644 --- a/flight/OpenPilot/Modules/Example/examplemodevent.c +++ b/flight/OpenPilot/Modules/Example/examplemodevent.c @@ -97,12 +97,6 @@ static void ObjectUpdatedCb(UAVObjEvent* ev) // Update settings with latest value ExampleSettingsGet(&settings); - // TODO: Remove, this is temporary for testing (force settings) - // will remove when default setting values are implemented - settings.StepDirection = EXAMPLESETTINGS_STEPDIRECTION_UP; - settings.StepSize = 1; - settings.UpdatePeriod = 100; - // Get the input object ExampleObject1Get(&data1); diff --git a/flight/OpenPilot/Modules/Example/examplemodperiodic.c b/flight/OpenPilot/Modules/Example/examplemodperiodic.c index ac25c60f3..74e365283 100644 --- a/flight/OpenPilot/Modules/Example/examplemodperiodic.c +++ b/flight/OpenPilot/Modules/Example/examplemodperiodic.c @@ -90,12 +90,6 @@ static void exampleTask(void* parameters) // Update settings with latest value ExampleSettingsGet(&settings); - // TODO: Remove, this is temporary for testing (force settings) - // will remove when default setting values are implemented - settings.StepDirection = EXAMPLESETTINGS_STEPDIRECTION_UP; - settings.StepSize = 1; - settings.UpdatePeriod = 100; - // Get the object data ExampleObject2Get(&data); diff --git a/flight/OpenPilot/Modules/Example/examplemodthread.c b/flight/OpenPilot/Modules/Example/examplemodthread.c index fb2c0973a..91980c3b8 100644 --- a/flight/OpenPilot/Modules/Example/examplemodthread.c +++ b/flight/OpenPilot/Modules/Example/examplemodthread.c @@ -112,12 +112,6 @@ static void exampleTask(void* parameters) // Update settings with latest value ExampleSettingsGet(&settings); - // TODO: Remove, this is temporary for testing (force settings) - // will remove when default setting values are implemented - settings.StepDirection = EXAMPLESETTINGS_STEPDIRECTION_UP; - settings.StepSize = 1; - settings.UpdatePeriod = 100; - // Get the input object ExampleObject1Get(&data1); diff --git a/flight/OpenPilot/Modules/System/systemmod.c b/flight/OpenPilot/Modules/System/systemmod.c index 7d2ac699d..b5c88c2e3 100644 --- a/flight/OpenPilot/Modules/System/systemmod.c +++ b/flight/OpenPilot/Modules/System/systemmod.c @@ -96,13 +96,13 @@ static void systemTask(void* parameters) // Update the system alarms updateSystemAlarms(); - // Flash system alive the LED + // Flash the heartbeat LED PIOS_LED_Toggle(LED1); - // Flash the error LED if an alarm is set + // Turn on the error LED if an alarm is set if ( AlarmsHasWarnings() ) { - PIOS_LED_Toggle(LED2); + PIOS_LED_On(LED2); } else { diff --git a/flight/OpenPilot/System/alarms.c b/flight/OpenPilot/System/alarms.c index 116a165e5..3207662d3 100644 --- a/flight/OpenPilot/System/alarms.c +++ b/flight/OpenPilot/System/alarms.c @@ -55,7 +55,6 @@ int32_t AlarmsInitialize(void) int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity) { SystemAlarmsData alarms; - uint8_t changed; // Check that this is a valid alarm if (alarm >= SYSTEMALARMS_ALARM_NUMELEM) diff --git a/flight/OpenPilot/UAVObjects/exampleobject1.c b/flight/OpenPilot/UAVObjects/exampleobject1.c index 669e673a2..843cc8ea1 100644 --- a/flight/OpenPilot/UAVObjects/exampleobject1.c +++ b/flight/OpenPilot/UAVObjects/exampleobject1.c @@ -35,6 +35,9 @@ // Private variables static UAVObjHandle handle; +// Private functions +static void setDefaultFieldValues(); + /** * Initialize object. * \return 0 Success @@ -59,10 +62,27 @@ int32_t ExampleObject1Initialize() metadata.loggingUpdatePeriod = 0; UAVObjSetMetadata(handle, &metadata); + // Initialize field values + setDefaultFieldValues(); + // Done return 0; } +/** + * Initialize object fields with the default values. + * If a default value is not specified the object fields + * will be initialized to zero. + */ +static void setDefaultFieldValues() +{ + ExampleObject1Data data; + ExampleObject1Get(&data); + memset(&data, 0, sizeof(ExampleObject1Data)); + + ExampleObject1Set(&data); +} + /** * Get object handle */ @@ -72,3 +92,4 @@ UAVObjHandle ExampleObject1Handle() } + diff --git a/flight/OpenPilot/UAVObjects/exampleobject2.c b/flight/OpenPilot/UAVObjects/exampleobject2.c index 5971febff..e68000fbf 100644 --- a/flight/OpenPilot/UAVObjects/exampleobject2.c +++ b/flight/OpenPilot/UAVObjects/exampleobject2.c @@ -35,6 +35,9 @@ // Private variables static UAVObjHandle handle; +// Private functions +static void setDefaultFieldValues(); + /** * Initialize object. * \return 0 Success @@ -59,10 +62,27 @@ int32_t ExampleObject2Initialize() metadata.loggingUpdatePeriod = 0; UAVObjSetMetadata(handle, &metadata); + // Initialize field values + setDefaultFieldValues(); + // Done return 0; } +/** + * Initialize object fields with the default values. + * If a default value is not specified the object fields + * will be initialized to zero. + */ +static void setDefaultFieldValues() +{ + ExampleObject2Data data; + ExampleObject2Get(&data); + memset(&data, 0, sizeof(ExampleObject2Data)); + + ExampleObject2Set(&data); +} + /** * Get object handle */ @@ -72,3 +92,4 @@ UAVObjHandle ExampleObject2Handle() } + diff --git a/flight/OpenPilot/UAVObjects/examplesettings.c b/flight/OpenPilot/UAVObjects/examplesettings.c index a6c03370e..2363ae01f 100644 --- a/flight/OpenPilot/UAVObjects/examplesettings.c +++ b/flight/OpenPilot/UAVObjects/examplesettings.c @@ -35,6 +35,9 @@ // Private variables static UAVObjHandle handle; +// Private functions +static void setDefaultFieldValues(); + /** * Initialize object. * \return 0 Success @@ -59,10 +62,30 @@ int32_t ExampleSettingsInitialize() metadata.loggingUpdatePeriod = 0; UAVObjSetMetadata(handle, &metadata); + // Initialize field values + setDefaultFieldValues(); + // Done return 0; } +/** + * Initialize object fields with the default values. + * If a default value is not specified the object fields + * will be initialized to zero. + */ +static void setDefaultFieldValues() +{ + ExampleSettingsData data; + ExampleSettingsGet(&data); + memset(&data, 0, sizeof(ExampleSettingsData)); + data.UpdatePeriod = 10; + data.StepSize = 1; + data.StepDirection = 0; + + ExampleSettingsSet(&data); +} + /** * Get object handle */ @@ -72,3 +95,4 @@ UAVObjHandle ExampleSettingsHandle() } + diff --git a/flight/OpenPilot/UAVObjects/flighttelemetrystats.c b/flight/OpenPilot/UAVObjects/flighttelemetrystats.c index 697cd8e82..11737109b 100644 --- a/flight/OpenPilot/UAVObjects/flighttelemetrystats.c +++ b/flight/OpenPilot/UAVObjects/flighttelemetrystats.c @@ -35,6 +35,9 @@ // Private variables static UAVObjHandle handle; +// Private functions +static void setDefaultFieldValues(); + /** * Initialize object. * \return 0 Success @@ -59,10 +62,27 @@ int32_t FlightTelemetryStatsInitialize() metadata.loggingUpdatePeriod = 5000; UAVObjSetMetadata(handle, &metadata); + // Initialize field values + setDefaultFieldValues(); + // Done return 0; } +/** + * Initialize object fields with the default values. + * If a default value is not specified the object fields + * will be initialized to zero. + */ +static void setDefaultFieldValues() +{ + FlightTelemetryStatsData data; + FlightTelemetryStatsGet(&data); + memset(&data, 0, sizeof(FlightTelemetryStatsData)); + + FlightTelemetryStatsSet(&data); +} + /** * Get object handle */ @@ -72,3 +92,4 @@ UAVObjHandle FlightTelemetryStatsHandle() } + diff --git a/flight/OpenPilot/UAVObjects/gcstelemetrystats.c b/flight/OpenPilot/UAVObjects/gcstelemetrystats.c index 4f57559fd..920baba5e 100644 --- a/flight/OpenPilot/UAVObjects/gcstelemetrystats.c +++ b/flight/OpenPilot/UAVObjects/gcstelemetrystats.c @@ -35,6 +35,9 @@ // Private variables static UAVObjHandle handle; +// Private functions +static void setDefaultFieldValues(); + /** * Initialize object. * \return 0 Success @@ -59,10 +62,27 @@ int32_t GCSTelemetryStatsInitialize() metadata.loggingUpdatePeriod = 0; UAVObjSetMetadata(handle, &metadata); + // Initialize field values + setDefaultFieldValues(); + // Done return 0; } +/** + * Initialize object fields with the default values. + * If a default value is not specified the object fields + * will be initialized to zero. + */ +static void setDefaultFieldValues() +{ + GCSTelemetryStatsData data; + GCSTelemetryStatsGet(&data); + memset(&data, 0, sizeof(GCSTelemetryStatsData)); + + GCSTelemetryStatsSet(&data); +} + /** * Get object handle */ @@ -72,3 +92,4 @@ UAVObjHandle GCSTelemetryStatsHandle() } + diff --git a/flight/OpenPilot/UAVObjects/gpsobject.c b/flight/OpenPilot/UAVObjects/gpsobject.c index 9cf437218..3a7adfd40 100644 --- a/flight/OpenPilot/UAVObjects/gpsobject.c +++ b/flight/OpenPilot/UAVObjects/gpsobject.c @@ -35,6 +35,9 @@ // Private variables static UAVObjHandle handle; +// Private functions +static void setDefaultFieldValues(); + /** * Initialize object. * \return 0 Success @@ -59,10 +62,27 @@ int32_t GpsObjectInitialize() metadata.loggingUpdatePeriod = 1000; UAVObjSetMetadata(handle, &metadata); + // Initialize field values + setDefaultFieldValues(); + // Done return 0; } +/** + * Initialize object fields with the default values. + * If a default value is not specified the object fields + * will be initialized to zero. + */ +static void setDefaultFieldValues() +{ + GpsObjectData data; + GpsObjectGet(&data); + memset(&data, 0, sizeof(GpsObjectData)); + + GpsObjectSet(&data); +} + /** * Get object handle */ @@ -72,3 +92,4 @@ UAVObjHandle GpsObjectHandle() } + diff --git a/flight/OpenPilot/UAVObjects/inc/exampleobject1.h b/flight/OpenPilot/UAVObjects/inc/exampleobject1.h index e91b5c045..9b01a403a 100644 --- a/flight/OpenPilot/UAVObjects/inc/exampleobject1.h +++ b/flight/OpenPilot/UAVObjects/inc/exampleobject1.h @@ -35,6 +35,7 @@ // Object constants #define EXAMPLEOBJECT1_OBJID 3852936276U #define EXAMPLEOBJECT1_NAME "ExampleObject1" +#define EXAMPLEOBJECT1_METANAME "ExampleObject1Meta" #define EXAMPLEOBJECT1_ISSINGLEINST 0 #define EXAMPLEOBJECT1_ISSETTINGS 0 #define EXAMPLEOBJECT1_NUMBYTES sizeof(ExampleObject1Data) diff --git a/flight/OpenPilot/UAVObjects/inc/exampleobject2.h b/flight/OpenPilot/UAVObjects/inc/exampleobject2.h index bea64b8f3..c44e08567 100644 --- a/flight/OpenPilot/UAVObjects/inc/exampleobject2.h +++ b/flight/OpenPilot/UAVObjects/inc/exampleobject2.h @@ -35,6 +35,7 @@ // Object constants #define EXAMPLEOBJECT2_OBJID 2743296914U #define EXAMPLEOBJECT2_NAME "ExampleObject2" +#define EXAMPLEOBJECT2_METANAME "ExampleObject2Meta" #define EXAMPLEOBJECT2_ISSINGLEINST 0 #define EXAMPLEOBJECT2_ISSETTINGS 0 #define EXAMPLEOBJECT2_NUMBYTES sizeof(ExampleObject2Data) diff --git a/flight/OpenPilot/UAVObjects/inc/examplesettings.h b/flight/OpenPilot/UAVObjects/inc/examplesettings.h index 466c65948..ff9c97aae 100644 --- a/flight/OpenPilot/UAVObjects/inc/examplesettings.h +++ b/flight/OpenPilot/UAVObjects/inc/examplesettings.h @@ -35,6 +35,7 @@ // Object constants #define EXAMPLESETTINGS_OBJID 1640607828U #define EXAMPLESETTINGS_NAME "ExampleSettings" +#define EXAMPLESETTINGS_METANAME "ExampleSettingsMeta" #define EXAMPLESETTINGS_ISSINGLEINST 1 #define EXAMPLESETTINGS_ISSETTINGS 1 #define EXAMPLESETTINGS_NUMBYTES sizeof(ExampleSettingsData) diff --git a/flight/OpenPilot/UAVObjects/inc/flighttelemetrystats.h b/flight/OpenPilot/UAVObjects/inc/flighttelemetrystats.h index 66e716db8..2f1be54b3 100644 --- a/flight/OpenPilot/UAVObjects/inc/flighttelemetrystats.h +++ b/flight/OpenPilot/UAVObjects/inc/flighttelemetrystats.h @@ -35,6 +35,7 @@ // Object constants #define FLIGHTTELEMETRYSTATS_OBJID 766280320U #define FLIGHTTELEMETRYSTATS_NAME "FlightTelemetryStats" +#define FLIGHTTELEMETRYSTATS_METANAME "FlightTelemetryStatsMeta" #define FLIGHTTELEMETRYSTATS_ISSINGLEINST 1 #define FLIGHTTELEMETRYSTATS_ISSETTINGS 0 #define FLIGHTTELEMETRYSTATS_NUMBYTES sizeof(FlightTelemetryStatsData) diff --git a/flight/OpenPilot/UAVObjects/inc/gcstelemetrystats.h b/flight/OpenPilot/UAVObjects/inc/gcstelemetrystats.h index 5e3595fb7..b2f586678 100644 --- a/flight/OpenPilot/UAVObjects/inc/gcstelemetrystats.h +++ b/flight/OpenPilot/UAVObjects/inc/gcstelemetrystats.h @@ -35,6 +35,7 @@ // Object constants #define GCSTELEMETRYSTATS_OBJID 607270704U #define GCSTELEMETRYSTATS_NAME "GCSTelemetryStats" +#define GCSTELEMETRYSTATS_METANAME "GCSTelemetryStatsMeta" #define GCSTELEMETRYSTATS_ISSINGLEINST 1 #define GCSTELEMETRYSTATS_ISSETTINGS 0 #define GCSTELEMETRYSTATS_NUMBYTES sizeof(GCSTelemetryStatsData) diff --git a/flight/OpenPilot/UAVObjects/inc/gpsobject.h b/flight/OpenPilot/UAVObjects/inc/gpsobject.h index 4a89436a7..31a3707cd 100644 --- a/flight/OpenPilot/UAVObjects/inc/gpsobject.h +++ b/flight/OpenPilot/UAVObjects/inc/gpsobject.h @@ -35,6 +35,7 @@ // Object constants #define GPSOBJECT_OBJID 4217926642U #define GPSOBJECT_NAME "GpsObject" +#define GPSOBJECT_METANAME "GpsObjectMeta" #define GPSOBJECT_ISSINGLEINST 1 #define GPSOBJECT_ISSETTINGS 0 #define GPSOBJECT_NUMBYTES sizeof(GpsObjectData) diff --git a/flight/OpenPilot/UAVObjects/inc/settingspersistence.h b/flight/OpenPilot/UAVObjects/inc/settingspersistence.h index bc9da2194..2b6b67e4a 100644 --- a/flight/OpenPilot/UAVObjects/inc/settingspersistence.h +++ b/flight/OpenPilot/UAVObjects/inc/settingspersistence.h @@ -35,6 +35,7 @@ // Object constants #define SETTINGSPERSISTENCE_OBJID 3652432370U #define SETTINGSPERSISTENCE_NAME "SettingsPersistence" +#define SETTINGSPERSISTENCE_METANAME "SettingsPersistenceMeta" #define SETTINGSPERSISTENCE_ISSINGLEINST 1 #define SETTINGSPERSISTENCE_ISSETTINGS 0 #define SETTINGSPERSISTENCE_NUMBYTES sizeof(SettingsPersistenceData) diff --git a/flight/OpenPilot/UAVObjects/inc/systemalarms.h b/flight/OpenPilot/UAVObjects/inc/systemalarms.h index 286b465ef..fd415fcd4 100644 --- a/flight/OpenPilot/UAVObjects/inc/systemalarms.h +++ b/flight/OpenPilot/UAVObjects/inc/systemalarms.h @@ -35,6 +35,7 @@ // Object constants #define SYSTEMALARMS_OBJID 2311311458U #define SYSTEMALARMS_NAME "SystemAlarms" +#define SYSTEMALARMS_METANAME "SystemAlarmsMeta" #define SYSTEMALARMS_ISSINGLEINST 1 #define SYSTEMALARMS_ISSETTINGS 0 #define SYSTEMALARMS_NUMBYTES sizeof(SystemAlarmsData) diff --git a/flight/OpenPilot/UAVObjects/inc/systemstats.h b/flight/OpenPilot/UAVObjects/inc/systemstats.h index 59bed9c2f..127df6361 100644 --- a/flight/OpenPilot/UAVObjects/inc/systemstats.h +++ b/flight/OpenPilot/UAVObjects/inc/systemstats.h @@ -35,6 +35,7 @@ // Object constants #define SYSTEMSTATS_OBJID 680908530U #define SYSTEMSTATS_NAME "SystemStats" +#define SYSTEMSTATS_METANAME "SystemStatsMeta" #define SYSTEMSTATS_ISSINGLEINST 1 #define SYSTEMSTATS_ISSETTINGS 0 #define SYSTEMSTATS_NUMBYTES sizeof(SystemStatsData) diff --git a/flight/OpenPilot/UAVObjects/inc/uavobjecttemplate.h b/flight/OpenPilot/UAVObjects/inc/uavobjecttemplate.h index ca62faf99..595fc686c 100644 --- a/flight/OpenPilot/UAVObjects/inc/uavobjecttemplate.h +++ b/flight/OpenPilot/UAVObjects/inc/uavobjecttemplate.h @@ -35,6 +35,7 @@ // Object constants #define $(NAMEUC)_OBJID $(OBJID)U #define $(NAMEUC)_NAME "$(NAME)" +#define $(NAMEUC)_METANAME "$(NAME)Meta" #define $(NAMEUC)_ISSINGLEINST $(ISSINGLEINST) #define $(NAMEUC)_ISSETTINGS $(ISSETTINGS) #define $(NAMEUC)_NUMBYTES sizeof($(NAME)Data) diff --git a/flight/OpenPilot/UAVObjects/settingspersistence.c b/flight/OpenPilot/UAVObjects/settingspersistence.c index 3ae140721..6141d0f86 100644 --- a/flight/OpenPilot/UAVObjects/settingspersistence.c +++ b/flight/OpenPilot/UAVObjects/settingspersistence.c @@ -35,6 +35,9 @@ // Private variables static UAVObjHandle handle; +// Private functions +static void setDefaultFieldValues(); + /** * Initialize object. * \return 0 Success @@ -59,10 +62,27 @@ int32_t SettingsPersistenceInitialize() metadata.loggingUpdatePeriod = 0; UAVObjSetMetadata(handle, &metadata); + // Initialize field values + setDefaultFieldValues(); + // Done return 0; } +/** + * Initialize object fields with the default values. + * If a default value is not specified the object fields + * will be initialized to zero. + */ +static void setDefaultFieldValues() +{ + SettingsPersistenceData data; + SettingsPersistenceGet(&data); + memset(&data, 0, sizeof(SettingsPersistenceData)); + + SettingsPersistenceSet(&data); +} + /** * Get object handle */ @@ -72,3 +92,4 @@ UAVObjHandle SettingsPersistenceHandle() } + diff --git a/flight/OpenPilot/UAVObjects/systemalarms.c b/flight/OpenPilot/UAVObjects/systemalarms.c index 8cd09b3a4..9a9dd4b9a 100644 --- a/flight/OpenPilot/UAVObjects/systemalarms.c +++ b/flight/OpenPilot/UAVObjects/systemalarms.c @@ -35,6 +35,9 @@ // Private variables static UAVObjHandle handle; +// Private functions +static void setDefaultFieldValues(); + /** * Initialize object. * \return 0 Success @@ -59,10 +62,27 @@ int32_t SystemAlarmsInitialize() metadata.loggingUpdatePeriod = 1000; UAVObjSetMetadata(handle, &metadata); + // Initialize field values + setDefaultFieldValues(); + // Done return 0; } +/** + * Initialize object fields with the default values. + * If a default value is not specified the object fields + * will be initialized to zero. + */ +static void setDefaultFieldValues() +{ + SystemAlarmsData data; + SystemAlarmsGet(&data); + memset(&data, 0, sizeof(SystemAlarmsData)); + + SystemAlarmsSet(&data); +} + /** * Get object handle */ @@ -72,3 +92,4 @@ UAVObjHandle SystemAlarmsHandle() } + diff --git a/flight/OpenPilot/UAVObjects/systemstats.c b/flight/OpenPilot/UAVObjects/systemstats.c index 66b33e89c..158b194a6 100644 --- a/flight/OpenPilot/UAVObjects/systemstats.c +++ b/flight/OpenPilot/UAVObjects/systemstats.c @@ -35,6 +35,9 @@ // Private variables static UAVObjHandle handle; +// Private functions +static void setDefaultFieldValues(); + /** * Initialize object. * \return 0 Success @@ -59,10 +62,27 @@ int32_t SystemStatsInitialize() metadata.loggingUpdatePeriod = 1000; UAVObjSetMetadata(handle, &metadata); + // Initialize field values + setDefaultFieldValues(); + // Done return 0; } +/** + * Initialize object fields with the default values. + * If a default value is not specified the object fields + * will be initialized to zero. + */ +static void setDefaultFieldValues() +{ + SystemStatsData data; + SystemStatsGet(&data); + memset(&data, 0, sizeof(SystemStatsData)); + + SystemStatsSet(&data); +} + /** * Get object handle */ @@ -72,3 +92,4 @@ UAVObjHandle SystemStatsHandle() } + diff --git a/flight/OpenPilot/UAVObjects/uavobjecttemplate.c b/flight/OpenPilot/UAVObjects/uavobjecttemplate.c index 620e63113..81d91b814 100644 --- a/flight/OpenPilot/UAVObjects/uavobjecttemplate.c +++ b/flight/OpenPilot/UAVObjects/uavobjecttemplate.c @@ -35,6 +35,9 @@ // Private variables static UAVObjHandle handle; +// Private functions +static void setDefaultFieldValues(); + /** * Initialize object. * \return 0 Success @@ -59,10 +62,27 @@ int32_t $(NAME)Initialize() metadata.loggingUpdatePeriod = $(LOGGING_UPDATEPERIOD); UAVObjSetMetadata(handle, &metadata); + // Initialize field values + setDefaultFieldValues(); + // Done return 0; } +/** + * Initialize object fields with the default values. + * If a default value is not specified the object fields + * will be initialized to zero. + */ +static void setDefaultFieldValues() +{ + $(NAME)Data data; + $(NAME)Get(&data); + memset(&data, 0, sizeof($(NAME)Data)); +$(INITFIELDS) + $(NAME)Set(&data); +} + /** * Get object handle */ @@ -72,3 +92,4 @@ UAVObjHandle $(NAME)Handle() } +