1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Updates on UAVObjects required by the object generator

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@396 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
vassilis 2010-03-27 03:19:56 +00:00 committed by vassilis
parent 7c860c19c1
commit a64cdc64ea
9 changed files with 214 additions and 28 deletions

View File

@ -170,7 +170,7 @@ static void telemetryTask(void* parameters)
retries = 0; retries = 0;
while(retries < MAX_RETRIES && success == -1) 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; ++retries;
} }
} }

View File

@ -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;
}

View File

@ -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

View File

@ -46,9 +46,10 @@ typedef enum {
* properties for each object and can be used by multiple modules (e.g. telemetry and logger) * properties for each object and can be used by multiple modules (e.g. telemetry and logger)
*/ */
typedef struct { 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) */ 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) */ 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) */ 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) */ 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) */ int8_t loggingUpdateMode; /** Update mode used by the logging module (UAVObjUpdateMode) */

View File

@ -1,13 +1,14 @@
/** /**
****************************************************************************** ******************************************************************************
* *
* @file uavobjecttemplate.h * @file $(NAMELC).h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @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 * @brief Implementation of the $(NAME) object. This file has been
* by the parser as a template to generate all other objects. All $(x) fields * automatically generated by the UAVObjectGenerator.
* will be replaced by the parser with the actual object information. *
* Each object has an meta object associated with it. The meta object * @note Object definition file: $(XMLFILE).
* contains information such as the telemetry and logging properties. * This is an automatically generated file.
* DO NOT modify manually.
* *
* @see The GNU Public License (GPL) Version 3 * @see The GNU Public License (GPL) Version 3
* *
@ -31,8 +32,10 @@
#ifndef $(NAMEUC)_H #ifndef $(NAMEUC)_H
#define $(NAMEUC)_H #define $(NAMEUC)_H
#include "openpilot.h"
// Object constants // Object constants
#define $(NAMEUC)_OBJID $(OBJID) #define $(NAMEUC)_OBJID $(OBJID)U
#define $(NAMEUC)_NAME "$(NAME)" #define $(NAMEUC)_NAME "$(NAME)"
#define $(NAMEUC)_SINGLEINST $(SINGLEINST) #define $(NAMEUC)_SINGLEINST $(SINGLEINST)
#define $(NAMEUC)_NUMBYTES sizeof($(NAME)Data) #define $(NAMEUC)_NUMBYTES sizeof($(NAME)Data)
@ -43,11 +46,11 @@
// Object data // Object data
typedef struct { typedef struct {
$(DATAFIELDS) $(DATAFIELDS)
} __attribute__((packed)) $(NAME)Data; } __attribute__((packed)) $(NAME)Data;
// Generic interface functions // Generic interface functions
int32_t $(NAME)Initialize(); int32_t $(NAME)Initialize();
UAVObjHandle $(NAME)GetHandle(); UAVObjHandle $(NAME)GetHandle();
#endif // $(NAME)_H #endif // $(NAMEUC)_H

View File

@ -102,9 +102,10 @@ int32_t UAVObjInitialize()
return -1; return -1;
// Initialize default metadata structure (metadata of metaobjects) // Initialize default metadata structure (metadata of metaobjects)
defMetadata.ackRequired = 1; defMetadata.telemetryAcked = 1;
defMetadata.telemetryUpdateMode = UPDATEMODE_ONCHANGE; defMetadata.telemetryUpdateMode = UPDATEMODE_ONCHANGE;
defMetadata.telemetryUpdatePeriod = 0; defMetadata.telemetryUpdatePeriod = 0;
defMetadata.gcsTelemetryAcked = 1;
defMetadata.gcsTelemetryUpdateMode = UPDATEMODE_ONCHANGE; defMetadata.gcsTelemetryUpdateMode = UPDATEMODE_ONCHANGE;
defMetadata.gcsTelemetryUpdatePeriod = 0; defMetadata.gcsTelemetryUpdatePeriod = 0;
defMetadata.loggingUpdateMode = UPDATEMODE_ONCHANGE; defMetadata.loggingUpdateMode = UPDATEMODE_ONCHANGE;

View File

@ -4,7 +4,10 @@
* @file uavobjectsinit.c * @file uavobjectsinit.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Initialize all objects. * @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 * @see The GNU Public License (GPL) Version 3
* *
*****************************************************************************/ *****************************************************************************/
@ -25,12 +28,15 @@
*/ */
#include "openpilot.h" #include "openpilot.h"
#include "exampleobject.h"
/** /**
* Initialize all objects. * Function used to initialize the first instance of each object.
* This function is updated by the parser each time a new object is created. * This file is automatically updated by the UAVObjectGenerator.
*/ */
void UAVObjectsInitializeAll() void UAVObjectsInitializeAll()
{ {
ExampleObjectInitialize();
} }

View File

@ -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)
}

View File

@ -1,13 +1,14 @@
/** /**
****************************************************************************** ******************************************************************************
* *
* @file uavobjecttemplate.c * @file $(NAMELC).c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @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 * @brief Implementation of the $(NAME) object. This file has been
* by the parser as a template to generate all other objects. All $(x) fields * automatically generated by the UAVObjectGenerator.
* will be replaced by the parser with the actual object information. *
* Each object has a meta object associated with it. The meta object * @note Object definition file: $(XMLFILE).
* contains information such as the telemetry and logging properties. * This is an automatically generated file.
* DO NOT modify manually.
* *
* @see The GNU Public License (GPL) Version 3 * @see The GNU Public License (GPL) Version 3
* *
@ -28,11 +29,8 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "openpilot.h"
#include "$(NAMELC).h" #include "$(NAMELC).h"
// Private variables // Private variables
UAVObjHandle handle; UAVObjHandle handle;
@ -49,12 +47,13 @@ int32_t $(NAME)Initialize()
handle = UAVObjRegister($(NAMEUC)_OBJID, $(NAMEUC)_NAME, 0, $(NAMEUC)_SINGLEINST, $(NAMEUC)_NUMBYTES); handle = UAVObjRegister($(NAMEUC)_OBJID, $(NAMEUC)_NAME, 0, $(NAMEUC)_SINGLEINST, $(NAMEUC)_NUMBYTES);
if (handle == 0) return -1; if (handle == 0) return -1;
// Initialize meta data // Initialize metadata
metadata.ackRequired = $(ACK); metadata.telemetryAcked = $(FLIGHTTELEM_ACKED);
metadata.gcsTelemetryUpdateMode = $(GCSTELEM_UPDATEMODE);
metadata.gcsTelemetryUpdatePeriod = $(GCSTELEM_UPDATEPERIOD);
metadata.telemetryUpdateMode = $(FLIGHTTELEM_UPDATEMODE); metadata.telemetryUpdateMode = $(FLIGHTTELEM_UPDATEMODE);
metadata.telemetryUpdatePeriod = $(FLIGHTTELEM_UPDATEPERIOD); metadata.telemetryUpdatePeriod = $(FLIGHTTELEM_UPDATEPERIOD);
metadata.gcsTelemetryAcked = $(GCSTELEM_ACKED);
metadata.gcsTelemetryUpdateMode = $(GCSTELEM_UPDATEMODE);
metadata.gcsTelemetryUpdatePeriod = $(GCSTELEM_UPDATEPERIOD);
metadata.loggingUpdateMode = $(LOGGING_UPDATEMODE); metadata.loggingUpdateMode = $(LOGGING_UPDATEMODE);
metadata.loggingUpdatePeriod = $(LOGGING_UPDATEPERIOD); metadata.loggingUpdatePeriod = $(LOGGING_UPDATEPERIOD);
UAVObjSetMetadata(handle, &metadata); UAVObjSetMetadata(handle, &metadata);
@ -63,6 +62,9 @@ int32_t $(NAME)Initialize()
return 0; return 0;
} }
/**
* Get object handle
*/
UAVObjHandle $(NAME)GetHandle() UAVObjHandle $(NAME)GetHandle()
{ {
return handle; return handle;