1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-12 02:54:15 +01:00
vassilis b1b8fe4b37 Creation of UAVObject ,UAVTalk and Telemetry modules (compiles but untested!)
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@196 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-02-22 02:18:23 +00:00

98 lines
4.8 KiB
C

/**
******************************************************************************
*
* @file uavobject.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Interface implemented by all UAVObjects.
* @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 UAVOBJECT_H
#define UAVOBJECT_H
#include <stdint.h>
#include "FreeRTOS.h"
#include "queue.h"
/**
* Object update mode, used by multiple modules (e.g. telemetry and logger)
*/
typedef enum {
UPDATEMODE_PERIODIC = 0, /** Automatically update object at periodic intervals */
UPDATEMODE_ONCHANGE, /** Only update object when its data changes */
UPDATEMODE_MANUAL, /** Manually update object, by calling the updated() function */
UPDATEMODE_NEVER /** Object is never updated */
} UAVObjectUpdateMode;
/**
* Object metadata, each object has a meta object that holds its metadata. The metadata define
* 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) */
UAVObjectUpdateMode telemetryUpdateMode; /** Update mode used by the telemetry module */
int32_t telemetryUpdatePeriod; /** Update period used by the telemetry module (only if telemetry mode is PERIODIC) */
UAVObjectUpdateMode gcsTelemetryUpdateMode; /** Update mode used by the GCS */
int32_t gcsTelemetryUpdatePeriod; /** Update period used by the GCS (only if telemetry mode is PERIODIC) */
UAVObjectUpdateMode loggingUpdateMode; /** Update mode used by the logging module */
int32_t loggingUpdatePeriod; /** Update period used by the logging module (only if logging mode is PERIODIC) */
} UAVObjectMetadata;
/**
* Interface implemented by all UAVObjects.
*/
struct UAVObjectStruct {
uint32_t objectID; /** Unique object ID */
uint32_t metadataID; /** ID of the metadata object */
int32_t isMetadata; /** Defines if this object is a meta object (1:meta, 0:regular object) */
int32_t numBytes; /** Number of bytes of object's data */
const char* name; /** Object name */
struct UAVObjectStruct* linkedObj; /** Link between regular objects and metaobject, for regular objects this is the metaobject, for metadata objects this is the parent object */
int32_t (*pack)(uint32_t objId, uint8_t* data, int32_t maxLength); /** Pack object data in a byte buffer */
int32_t (*unpack)(uint32_t objId, uint8_t* data, int32_t length); /** Unpack object data from a byte buffer */
int32_t (*initializeData)(const char* init); /** Initialize object data from a string, this is used by settings objects, the settings string is parsed and fields initialized */
void (*getMetadata)(UAVObjectMetadata* dataOut); /** Get the object's metadata */
void (*setMetadata)(const UAVObjectMetadata* dataIn); /** Set the object's metadata */
void (*requestUpdate)(); /** Request that this object is updated with the latest value from the GCS */
void (*updated)(); /** Trigger an update event, used when the update mode is set to UPDATEMODE_MANUAL */
int32_t (*connect)(xQueueHandle queue, int32_t eventMask); /** Connect an event queue (from a module) to this object, the eventMask defines which events are enabled (or'ed UAVObjectQMsgEvent or 0 for all events) */
int32_t (*disconnect)(xQueueHandle queue); /** Disconnect an event queue from this object */
};
typedef struct UAVObjectStruct UAVObject;
/**
* Event types generated by the objects.
*/
typedef enum {
QMSG_UNPACKED = 1, /** Object data updated by unpacking */
QMSG_UPDATED = 2, /** Object data updated by changing the data structure */
QMSG_UPDATED_MANUAL = 4, /** Object update event manually generated */
QMSG_UPDATE_REQ = 8 /** Request to update object data */
} UAVObjectQMsgEvent;
/**
* Event message, this structure is send in the event queue each time an event is generated
*/
typedef struct {
UAVObject* obj;
UAVObjectQMsgEvent event;
} UAVObjectQMsg;
#endif // UAVOBJECT_H