From 73bc088ad5aa6f3e1ccd8a953e8076cf4f560587 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Tue, 8 Apr 2014 16:26:27 +0200 Subject: [PATCH] OP-1298 fix for metadata being overwritten on multiinstance object initialization --- flight/uavobjects/uavobject.c.template | 28 ++++++++++++++------------ 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/flight/uavobjects/uavobject.c.template b/flight/uavobjects/uavobject.c.template index 395279bd1..c25cb4abf 100644 --- a/flight/uavobjects/uavobject.c.template +++ b/flight/uavobjects/uavobject.c.template @@ -79,7 +79,6 @@ int32_t $(NAME)Initialize(void) void $(NAME)SetDefaults(UAVObjHandle obj, uint16_t instId) { $(NAME)Data data; - UAVObjMetadata metadata; // Initialize object fields to their default values UAVObjGetInstanceData(obj, instId, &data); @@ -88,18 +87,21 @@ $(INITFIELDS) UAVObjSetInstanceData(obj, instId, &data); // Initialize object metadata to their default values - metadata.flags = - $(FLIGHTACCESS) << UAVOBJ_ACCESS_SHIFT | - $(GCSACCESS) << UAVOBJ_GCS_ACCESS_SHIFT | - $(FLIGHTTELEM_ACKED) << UAVOBJ_TELEMETRY_ACKED_SHIFT | - $(GCSTELEM_ACKED) << UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT | - $(FLIGHTTELEM_UPDATEMODE) << UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT | - $(GCSTELEM_UPDATEMODE) << UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT | - $(LOGGING_UPDATEMODE) << UAVOBJ_LOGGING_UPDATE_MODE_SHIFT; - metadata.telemetryUpdatePeriod = $(FLIGHTTELEM_UPDATEPERIOD); - metadata.gcsTelemetryUpdatePeriod = $(GCSTELEM_UPDATEPERIOD); - metadata.loggingUpdatePeriod = $(LOGGING_UPDATEPERIOD); - UAVObjSetMetadata(obj, &metadata); + if ( instId == 0 ) { + UAVObjMetadata metadata; + metadata.flags = + $(FLIGHTACCESS) << UAVOBJ_ACCESS_SHIFT | + $(GCSACCESS) << UAVOBJ_GCS_ACCESS_SHIFT | + $(FLIGHTTELEM_ACKED) << UAVOBJ_TELEMETRY_ACKED_SHIFT | + $(GCSTELEM_ACKED) << UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT | + $(FLIGHTTELEM_UPDATEMODE) << UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT | + $(GCSTELEM_UPDATEMODE) << UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT | + $(LOGGING_UPDATEMODE) << UAVOBJ_LOGGING_UPDATE_MODE_SHIFT; + metadata.telemetryUpdatePeriod = $(FLIGHTTELEM_UPDATEPERIOD); + metadata.gcsTelemetryUpdatePeriod = $(GCSTELEM_UPDATEPERIOD); + metadata.loggingUpdatePeriod = $(LOGGING_UPDATEPERIOD); + UAVObjSetMetadata(obj, &metadata); + } } /**