diff --git a/flight/OpenPilot/Modules/Telemetry/telemetry.c b/flight/OpenPilot/Modules/Telemetry/telemetry.c index 949429a80..1ffac86d6 100644 --- a/flight/OpenPilot/Modules/Telemetry/telemetry.c +++ b/flight/OpenPilot/Modules/Telemetry/telemetry.c @@ -170,7 +170,7 @@ static void telemetryTask(void* parameters) retries = 0; while(retries < MAX_RETRIES && success == -1) { - success = UAVTalkSendObject(ev.obj, ev.instId, metadata.ackRequired, REQ_TIMEOUT_MS); // call blocks until ack is received or timeout + success = UAVTalkSendObject(ev.obj, ev.instId, metadata.telemetryAcked, REQ_TIMEOUT_MS); // call blocks until ack is received or timeout ++retries; } } diff --git a/flight/OpenPilot/UAVObjects/exampleobject.c b/flight/OpenPilot/UAVObjects/exampleobject.c new file mode 100644 index 000000000..7b9fdb098 --- /dev/null +++ b/flight/OpenPilot/UAVObjects/exampleobject.c @@ -0,0 +1,73 @@ +/** + ****************************************************************************** + * + * @file exampleobject.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Implementation of the ExampleObject object. This file has been + * automatically generated by the UAVObjectGenerator. + * + * @note Object definition file: exampleobject.xml. + * This is an automatically generated file. + * DO NOT modify manually. + * + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program 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 3 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "exampleobject.h" + +// Private variables +UAVObjHandle handle; + +/** + * Initialize object. + * \return 0 Success + * \return -1 Failure + */ +int32_t ExampleObjectInitialize() +{ + UAVObjMetadata metadata; + + // Register object with the object manager + handle = UAVObjRegister(EXAMPLEOBJECT_OBJID, EXAMPLEOBJECT_NAME, 0, EXAMPLEOBJECT_SINGLEINST, EXAMPLEOBJECT_NUMBYTES); + if (handle == 0) return -1; + + // Initialize metadata + metadata.telemetryAcked = 1; + metadata.telemetryUpdateMode = UPDATEMODE_ONCHANGE; + metadata.telemetryUpdatePeriod = 0; + metadata.gcsTelemetryAcked = 1; + metadata.gcsTelemetryUpdateMode = UPDATEMODE_PERIODIC; + metadata.gcsTelemetryUpdatePeriod = 100; + metadata.loggingUpdateMode = UPDATEMODE_NEVER; + metadata.loggingUpdatePeriod = 0; + UAVObjSetMetadata(handle, &metadata); + + // Done + return 0; +} + +/** + * Get object handle + */ +UAVObjHandle ExampleObjectGetHandle() +{ + return handle; +} + + diff --git a/flight/OpenPilot/UAVObjects/inc/exampleobject.h b/flight/OpenPilot/UAVObjects/inc/exampleobject.h new file mode 100644 index 000000000..232ef3e89 --- /dev/null +++ b/flight/OpenPilot/UAVObjects/inc/exampleobject.h @@ -0,0 +1,60 @@ +/** + ****************************************************************************** + * + * @file exampleobject.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Implementation of the ExampleObject object. This file has been + * automatically generated by the UAVObjectGenerator. + * + * @note Object definition file: exampleobject.xml. + * This is an automatically generated file. + * DO NOT modify manually. + * + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program 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 3 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef EXAMPLEOBJECT_H +#define EXAMPLEOBJECT_H + +#include "openpilot.h" + +// Object constants +#define EXAMPLEOBJECT_OBJID 3048370380U +#define EXAMPLEOBJECT_NAME "ExampleObject" +#define EXAMPLEOBJECT_SINGLEINST 0 +#define EXAMPLEOBJECT_NUMBYTES sizeof(ExampleObjectData) + +// Data access macros +#define ExampleObjectGet(dataOut) UAVObjGetData(ExampleObjectGetHandle(), dataOut) +#define ExampleObjectSet(dataIn) UAVObjSetData(ExampleObjectGetHandle(), dataIn) + +// Object data +typedef struct { + int8_t field1; + int16_t field2; + float field3[4]; + int32_t field4; + +} __attribute__((packed)) ExampleObjectData; + +// Generic interface functions +int32_t ExampleObjectInitialize(); +UAVObjHandle ExampleObjectGetHandle(); + +#endif // EXAMPLEOBJECT_H diff --git a/flight/OpenPilot/UAVObjects/inc/uavobjectmanager.h b/flight/OpenPilot/UAVObjects/inc/uavobjectmanager.h index 8772f4ff6..a8e983163 100644 --- a/flight/OpenPilot/UAVObjects/inc/uavobjectmanager.h +++ b/flight/OpenPilot/UAVObjects/inc/uavobjectmanager.h @@ -46,9 +46,10 @@ typedef enum { * properties for each object and can be used by multiple modules (e.g. telemetry and logger) */ typedef struct { - int8_t ackRequired; /** Defines if an ack is required for the transactions of this object (1:acked, 0:not acked) */ + int8_t telemetryAcked; /** Defines if an ack is required for the transactions of this object (1:acked, 0:not acked) */ int8_t telemetryUpdateMode; /** Update mode used by the telemetry module (UAVObjUpdateMode) */ int32_t telemetryUpdatePeriod; /** Update period used by the telemetry module (only if telemetry mode is PERIODIC) */ + int8_t gcsTelemetryAcked; /** Defines if an ack is required for the transactions of this object (1:acked, 0:not acked) */ int8_t gcsTelemetryUpdateMode; /** Update mode used by the GCS (UAVObjUpdateMode) */ int32_t gcsTelemetryUpdatePeriod; /** Update period used by the GCS (only if telemetry mode is PERIODIC) */ int8_t loggingUpdateMode; /** Update mode used by the logging module (UAVObjUpdateMode) */ diff --git a/flight/OpenPilot/UAVObjects/inc/uavobjecttemplate.h b/flight/OpenPilot/UAVObjects/inc/uavobjecttemplate.h index f62a68a6a..49558b96b 100644 --- a/flight/OpenPilot/UAVObjects/inc/uavobjecttemplate.h +++ b/flight/OpenPilot/UAVObjects/inc/uavobjecttemplate.h @@ -1,13 +1,14 @@ /** ****************************************************************************** * - * @file uavobjecttemplate.h + * @file $(NAMELC).h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Template file for all objects. This file will not compile, it is used - * by the parser as a template to generate all other objects. All $(x) fields - * will be replaced by the parser with the actual object information. - * Each object has an meta object associated with it. The meta object - * contains information such as the telemetry and logging properties. + * @brief Implementation of the $(NAME) object. This file has been + * automatically generated by the UAVObjectGenerator. + * + * @note Object definition file: $(XMLFILE). + * This is an automatically generated file. + * DO NOT modify manually. * * @see The GNU Public License (GPL) Version 3 * @@ -31,8 +32,10 @@ #ifndef $(NAMEUC)_H #define $(NAMEUC)_H +#include "openpilot.h" + // Object constants -#define $(NAMEUC)_OBJID $(OBJID) +#define $(NAMEUC)_OBJID $(OBJID)U #define $(NAMEUC)_NAME "$(NAME)" #define $(NAMEUC)_SINGLEINST $(SINGLEINST) #define $(NAMEUC)_NUMBYTES sizeof($(NAME)Data) @@ -43,11 +46,11 @@ // Object data typedef struct { - $(DATAFIELDS) +$(DATAFIELDS) } __attribute__((packed)) $(NAME)Data; // Generic interface functions int32_t $(NAME)Initialize(); UAVObjHandle $(NAME)GetHandle(); -#endif // $(NAME)_H +#endif // $(NAMEUC)_H diff --git a/flight/OpenPilot/UAVObjects/uavobjectmanager.c b/flight/OpenPilot/UAVObjects/uavobjectmanager.c index b5f14d541..e25d19ca7 100644 --- a/flight/OpenPilot/UAVObjects/uavobjectmanager.c +++ b/flight/OpenPilot/UAVObjects/uavobjectmanager.c @@ -102,9 +102,10 @@ int32_t UAVObjInitialize() return -1; // Initialize default metadata structure (metadata of metaobjects) - defMetadata.ackRequired = 1; + defMetadata.telemetryAcked = 1; defMetadata.telemetryUpdateMode = UPDATEMODE_ONCHANGE; defMetadata.telemetryUpdatePeriod = 0; + defMetadata.gcsTelemetryAcked = 1; defMetadata.gcsTelemetryUpdateMode = UPDATEMODE_ONCHANGE; defMetadata.gcsTelemetryUpdatePeriod = 0; defMetadata.loggingUpdateMode = UPDATEMODE_ONCHANGE; diff --git a/flight/OpenPilot/UAVObjects/uavobjectsinit.c b/flight/OpenPilot/UAVObjects/uavobjectsinit.c index 7a0623df5..feba850d2 100644 --- a/flight/OpenPilot/UAVObjects/uavobjectsinit.c +++ b/flight/OpenPilot/UAVObjects/uavobjectsinit.c @@ -4,7 +4,10 @@ * @file uavobjectsinit.c * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @brief Initialize all objects. - * This file is automatically updated by the parser. + * Automatically generated by the UAVObjectGenerator. + * + * @note This is an automatically generated file. + * DO NOT modify manually. * @see The GNU Public License (GPL) Version 3 * *****************************************************************************/ @@ -25,12 +28,15 @@ */ #include "openpilot.h" +#include "exampleobject.h" + /** - * Initialize all objects. - * This function is updated by the parser each time a new object is created. + * Function used to initialize the first instance of each object. + * This file is automatically updated by the UAVObjectGenerator. */ void UAVObjectsInitializeAll() { + ExampleObjectInitialize(); } diff --git a/flight/OpenPilot/UAVObjects/uavobjectsinittemplate.c b/flight/OpenPilot/UAVObjects/uavobjectsinittemplate.c new file mode 100644 index 000000000..75a104d18 --- /dev/null +++ b/flight/OpenPilot/UAVObjects/uavobjectsinittemplate.c @@ -0,0 +1,40 @@ +/** + ****************************************************************************** + * + * @file uavobjectsinit.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Initialize all objects. + * Automatically generated by the UAVObjectGenerator. + * + * @note This is an automatically generated file. + * DO NOT modify manually. + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program 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 3 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "openpilot.h" +$(OBJINC) + +/** + * Function used to initialize the first instance of each object. + * This file is automatically updated by the UAVObjectGenerator. + */ +void UAVObjectsInitializeAll() +{ +$(OBJINIT) +} diff --git a/flight/OpenPilot/UAVObjects/uavobjecttemplate.c b/flight/OpenPilot/UAVObjects/uavobjecttemplate.c index 3d1af28d1..5d58abb23 100644 --- a/flight/OpenPilot/UAVObjects/uavobjecttemplate.c +++ b/flight/OpenPilot/UAVObjects/uavobjecttemplate.c @@ -1,13 +1,14 @@ /** ****************************************************************************** * - * @file uavobjecttemplate.c + * @file $(NAMELC).c * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Template file for all objects. This file will not compile, it is used - * by the parser as a template to generate all other objects. All $(x) fields - * will be replaced by the parser with the actual object information. - * Each object has a meta object associated with it. The meta object - * contains information such as the telemetry and logging properties. + * @brief Implementation of the $(NAME) object. This file has been + * automatically generated by the UAVObjectGenerator. + * + * @note Object definition file: $(XMLFILE). + * This is an automatically generated file. + * DO NOT modify manually. * * @see The GNU Public License (GPL) Version 3 * @@ -28,11 +29,8 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "openpilot.h" #include "$(NAMELC).h" - - // Private variables UAVObjHandle handle; @@ -49,12 +47,13 @@ int32_t $(NAME)Initialize() handle = UAVObjRegister($(NAMEUC)_OBJID, $(NAMEUC)_NAME, 0, $(NAMEUC)_SINGLEINST, $(NAMEUC)_NUMBYTES); if (handle == 0) return -1; - // Initialize meta data - metadata.ackRequired = $(ACK); - metadata.gcsTelemetryUpdateMode = $(GCSTELEM_UPDATEMODE); - metadata.gcsTelemetryUpdatePeriod = $(GCSTELEM_UPDATEPERIOD); + // Initialize metadata + metadata.telemetryAcked = $(FLIGHTTELEM_ACKED); metadata.telemetryUpdateMode = $(FLIGHTTELEM_UPDATEMODE); metadata.telemetryUpdatePeriod = $(FLIGHTTELEM_UPDATEPERIOD); + metadata.gcsTelemetryAcked = $(GCSTELEM_ACKED); + metadata.gcsTelemetryUpdateMode = $(GCSTELEM_UPDATEMODE); + metadata.gcsTelemetryUpdatePeriod = $(GCSTELEM_UPDATEPERIOD); metadata.loggingUpdateMode = $(LOGGING_UPDATEMODE); metadata.loggingUpdatePeriod = $(LOGGING_UPDATEPERIOD); UAVObjSetMetadata(handle, &metadata); @@ -63,6 +62,9 @@ int32_t $(NAME)Initialize() return 0; } +/** + * Get object handle + */ UAVObjHandle $(NAME)GetHandle() { return handle;