2010-02-22 03:18:23 +01:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
2010-08-27 02:15:42 +02:00
|
|
|
* @addtogroup UAVObjects OpenPilot UAVObjects
|
|
|
|
* @{
|
|
|
|
* @addtogroup UAV Object Manager
|
|
|
|
* @brief The core UAV Objects functions, most of which are wrappered by
|
|
|
|
* autogenerated defines
|
|
|
|
* @{
|
2010-02-22 03:18:23 +01:00
|
|
|
*
|
2010-03-04 04:04:39 +01:00
|
|
|
* @file uavobjectmanager.h
|
2010-02-22 03:18:23 +01:00
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
2010-02-27 20:57:45 +01:00
|
|
|
* @brief Include files of the uavobjectlist library
|
2010-02-22 03:18:23 +01:00
|
|
|
* @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
|
|
|
|
*/
|
|
|
|
|
2010-02-27 20:57:45 +01:00
|
|
|
#ifndef UAVOBJECTMANAGER_H
|
|
|
|
#define UAVOBJECTMANAGER_H
|
2010-02-22 03:18:23 +01:00
|
|
|
|
2010-02-27 20:57:45 +01:00
|
|
|
#define UAVOBJ_ALL_INSTANCES 0xFFFF
|
2010-03-15 02:54:25 +01:00
|
|
|
#define UAVOBJ_MAX_INSTANCES 1000
|
2010-02-27 20:57:45 +01:00
|
|
|
|
2011-01-14 02:38:27 +01:00
|
|
|
|
|
|
|
// FIXME: All this typedef for SDCARD needs to be abstracted away
|
|
|
|
#if !defined(PIOS_INCLUDE_SDCARD)
|
|
|
|
typedef struct {} FILEINFO;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2010-07-13 18:23:41 +02:00
|
|
|
typedef void* UAVObjHandle;
|
2010-02-27 20:57:45 +01:00
|
|
|
|
2010-02-22 03:18:23 +01:00
|
|
|
/**
|
2010-02-27 20:57:45 +01:00
|
|
|
* Object update mode, used by multiple modules (e.g. telemetry and logger)
|
2010-02-22 03:18:23 +01:00
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
UPDATEMODE_PERIODIC = 0, /** Automatically update object at periodic intervals */
|
2010-03-15 02:54:25 +01:00
|
|
|
UPDATEMODE_ONCHANGE = 1, /** Only update object when its data changes */
|
|
|
|
UPDATEMODE_MANUAL = 2, /** Manually update object, by calling the updated() function */
|
|
|
|
UPDATEMODE_NEVER = 3 /** Object is never updated */
|
2010-02-27 20:57:45 +01:00
|
|
|
} UAVObjUpdateMode;
|
2010-02-22 03:18:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Object metadata, each object has a meta object that holds its metadata. The metadata define
|
2010-02-27 20:57:45 +01:00
|
|
|
* properties for each object and can be used by multiple modules (e.g. telemetry and logger)
|
2010-02-22 03:18:23 +01:00
|
|
|
*/
|
|
|
|
typedef struct {
|
2011-08-04 14:17:36 +02:00
|
|
|
uint8_t access; /** Defines the access level for the local transactions (readonly and readwrite) */
|
|
|
|
uint8_t gcsAccess; /** Defines the access level for the local GCS transactions (readonly and readwrite), not used in the flight s/w */
|
|
|
|
uint8_t telemetryAcked; /** Defines if an ack is required for the transactions of this object (1:acked, 0:not acked) */
|
|
|
|
uint8_t telemetryUpdateMode; /** Update mode used by the telemetry module (UAVObjUpdateMode) */
|
|
|
|
uint32_t telemetryUpdatePeriod; /** Update period used by the telemetry module (only if telemetry mode is PERIODIC) */
|
|
|
|
uint8_t gcsTelemetryAcked; /** Defines if an ack is required for the transactions of this object (1:acked, 0:not acked) */
|
|
|
|
uint8_t gcsTelemetryUpdateMode; /** Update mode used by the GCS (UAVObjUpdateMode) */
|
|
|
|
uint32_t gcsTelemetryUpdatePeriod; /** Update period used by the GCS (only if telemetry mode is PERIODIC) */
|
|
|
|
uint8_t loggingUpdateMode; /** Update mode used by the logging module (UAVObjUpdateMode) */
|
|
|
|
uint32_t loggingUpdatePeriod; /** Update period used by the logging module (only if logging mode is PERIODIC) */
|
2010-03-07 22:46:18 +01:00
|
|
|
} __attribute__((packed)) UAVObjMetadata;
|
2010-02-22 03:18:23 +01:00
|
|
|
|
|
|
|
/**
|
2010-02-27 20:57:45 +01:00
|
|
|
* Event types generated by the objects.
|
2010-02-22 03:18:23 +01:00
|
|
|
*/
|
|
|
|
typedef enum {
|
2010-03-04 04:04:39 +01:00
|
|
|
EV_UNPACKED = 0x01, /** Object data updated by unpacking */
|
|
|
|
EV_UPDATED = 0x02, /** Object data updated by changing the data structure */
|
|
|
|
EV_UPDATED_MANUAL = 0x04, /** Object update event manually generated */
|
|
|
|
EV_UPDATE_REQ = 0x08 /** Request to update object data */
|
|
|
|
} UAVObjEventType;
|
2010-02-22 03:18:23 +01:00
|
|
|
|
|
|
|
/**
|
2010-03-04 04:04:39 +01:00
|
|
|
* Helper macros for event masks
|
|
|
|
*/
|
|
|
|
#define EV_MASK_ALL 0
|
|
|
|
#define EV_MASK_ALL_UPDATES (EV_UNPACKED | EV_UPDATED | EV_UPDATED_MANUAL)
|
|
|
|
|
2010-05-20 02:58:40 +02:00
|
|
|
/**
|
2010-07-13 18:23:41 +02:00
|
|
|
* Access types
|
2010-05-20 02:58:40 +02:00
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
ACCESS_READWRITE = 0,
|
|
|
|
ACCESS_READONLY = 1
|
|
|
|
} UAVObjAccessType;
|
|
|
|
|
2010-03-04 04:04:39 +01:00
|
|
|
/**
|
|
|
|
* Event message, this structure is sent in the event queue each time an event is generated
|
2010-02-22 03:18:23 +01:00
|
|
|
*/
|
|
|
|
typedef struct {
|
2010-02-27 20:57:45 +01:00
|
|
|
UAVObjHandle obj;
|
2010-03-04 04:04:39 +01:00
|
|
|
uint16_t instId;
|
|
|
|
UAVObjEventType event;
|
|
|
|
} UAVObjEvent;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Event callback, this function is called when an event is invoked. The function
|
|
|
|
* will be executed in the event task. The ev parameter should be copied if needed
|
|
|
|
* after the function returns.
|
|
|
|
*/
|
|
|
|
typedef void (*UAVObjEventCallback)(UAVObjEvent* ev);
|
2010-02-27 20:57:45 +01:00
|
|
|
|
2010-04-30 04:28:16 +02:00
|
|
|
/**
|
2010-07-13 18:23:41 +02:00
|
|
|
* Callback used to initialize the object fields to their default values.
|
2010-04-30 04:28:16 +02:00
|
|
|
*/
|
|
|
|
typedef void (*UAVObjInitializeCallback)(UAVObjHandle obj, uint16_t instId);
|
|
|
|
|
2010-04-27 03:55:28 +02:00
|
|
|
/**
|
2010-07-13 18:23:41 +02:00
|
|
|
* Event manager statistics
|
2010-04-27 03:55:28 +02:00
|
|
|
*/
|
|
|
|
typedef struct {
|
2012-03-11 00:02:38 +01:00
|
|
|
uint32_t eventQueueErrors;
|
|
|
|
uint32_t eventCallbackErrors;
|
|
|
|
uint32_t lastCallbackErrorID;
|
|
|
|
uint32_t lastQueueErrorID;
|
2010-04-27 03:55:28 +02:00
|
|
|
} UAVObjStats;
|
|
|
|
|
2010-02-27 20:57:45 +01:00
|
|
|
int32_t UAVObjInitialize();
|
2010-04-27 03:55:28 +02:00
|
|
|
void UAVObjGetStats(UAVObjStats* statsOut);
|
|
|
|
void UAVObjClearStats();
|
2010-04-30 04:28:16 +02:00
|
|
|
UAVObjHandle UAVObjRegister(uint32_t id, const char* name, const char* metaName, int32_t isMetaobject,
|
|
|
|
int32_t isSingleInstance, int32_t isSettings, uint32_t numBytes, UAVObjInitializeCallback initCb);
|
2010-02-27 20:57:45 +01:00
|
|
|
UAVObjHandle UAVObjGetByID(uint32_t id);
|
|
|
|
UAVObjHandle UAVObjGetByName(char* name);
|
|
|
|
uint32_t UAVObjGetID(UAVObjHandle obj);
|
|
|
|
const char* UAVObjGetName(UAVObjHandle obj);
|
|
|
|
uint32_t UAVObjGetNumBytes(UAVObjHandle obj);
|
2010-04-04 04:11:51 +02:00
|
|
|
uint16_t UAVObjGetNumInstances(UAVObjHandle obj);
|
2010-02-27 20:57:45 +01:00
|
|
|
UAVObjHandle UAVObjGetLinkedObj(UAVObjHandle obj);
|
2011-01-24 08:51:17 +01:00
|
|
|
uint16_t UAVObjCreateInstance(UAVObjHandle obj, UAVObjInitializeCallback initCb);
|
2010-02-27 20:57:45 +01:00
|
|
|
int32_t UAVObjIsSingleInstance(UAVObjHandle obj);
|
|
|
|
int32_t UAVObjIsMetaobject(UAVObjHandle obj);
|
2010-03-28 22:39:47 +02:00
|
|
|
int32_t UAVObjIsSettings(UAVObjHandle obj);
|
2010-03-04 04:04:39 +01:00
|
|
|
int32_t UAVObjUnpack(UAVObjHandle obj, uint16_t instId, const uint8_t* dataIn);
|
|
|
|
int32_t UAVObjPack(UAVObjHandle obj, uint16_t instId, uint8_t* dataOut);
|
2010-03-28 22:39:47 +02:00
|
|
|
int32_t UAVObjSave(UAVObjHandle obj, uint16_t instId);
|
|
|
|
int32_t UAVObjLoad(UAVObjHandle obj, uint16_t instId);
|
2010-05-04 03:29:04 +02:00
|
|
|
int32_t UAVObjDelete(UAVObjHandle obj, uint16_t instId);
|
2010-03-28 22:39:47 +02:00
|
|
|
int32_t UAVObjSaveToFile(UAVObjHandle obj, uint16_t instId, FILEINFO* file);
|
|
|
|
UAVObjHandle UAVObjLoadFromFile(FILEINFO* file);
|
2010-04-10 07:06:19 +02:00
|
|
|
int32_t UAVObjSaveSettings();
|
|
|
|
int32_t UAVObjLoadSettings();
|
2010-05-04 03:29:04 +02:00
|
|
|
int32_t UAVObjDeleteSettings();
|
2010-04-30 04:28:16 +02:00
|
|
|
int32_t UAVObjSaveMetaobjects();
|
|
|
|
int32_t UAVObjLoadMetaobjects();
|
2010-05-04 03:29:04 +02:00
|
|
|
int32_t UAVObjDeleteMetaobjects();
|
2010-02-27 20:57:45 +01:00
|
|
|
int32_t UAVObjSetData(UAVObjHandle obj, const void* dataIn);
|
2011-06-03 06:18:34 +02:00
|
|
|
int32_t UAVObjSetDataField(UAVObjHandle obj, const void* dataIn, uint32_t offset, uint32_t size);
|
2010-02-27 20:57:45 +01:00
|
|
|
int32_t UAVObjGetData(UAVObjHandle obj, void* dataOut);
|
2011-06-03 06:18:34 +02:00
|
|
|
int32_t UAVObjGetDataField(UAVObjHandle obj, void* dataOut, uint32_t offset, uint32_t size);
|
2010-03-04 04:04:39 +01:00
|
|
|
int32_t UAVObjSetInstanceData(UAVObjHandle obj, uint16_t instId, const void* dataIn);
|
2011-06-03 06:18:34 +02:00
|
|
|
int32_t UAVObjSetInstanceDataField(UAVObjHandle obj, uint16_t instId, const void* dataIn, uint32_t offset, uint32_t size);
|
2010-03-04 04:04:39 +01:00
|
|
|
int32_t UAVObjGetInstanceData(UAVObjHandle obj, uint16_t instId, void* dataOut);
|
2011-06-03 06:18:34 +02:00
|
|
|
int32_t UAVObjGetInstanceDataField(UAVObjHandle obj, uint16_t instId, void* dataOut, uint32_t offset, uint32_t size);
|
2010-02-27 20:57:45 +01:00
|
|
|
int32_t UAVObjSetMetadata(UAVObjHandle obj, const UAVObjMetadata* dataIn);
|
|
|
|
int32_t UAVObjGetMetadata(UAVObjHandle obj, UAVObjMetadata* dataOut);
|
2010-08-27 02:15:42 +02:00
|
|
|
int8_t UAVObjReadOnly(UAVObjHandle obj);
|
2010-03-04 04:04:39 +01:00
|
|
|
int32_t UAVObjConnectQueue(UAVObjHandle obj, xQueueHandle queue, int32_t eventMask);
|
|
|
|
int32_t UAVObjDisconnectQueue(UAVObjHandle obj, xQueueHandle queue);
|
|
|
|
int32_t UAVObjConnectCallback(UAVObjHandle obj, UAVObjEventCallback cb, int32_t eventMask);
|
|
|
|
int32_t UAVObjDisconnectCallback(UAVObjHandle obj, UAVObjEventCallback cb);
|
2010-02-27 20:57:45 +01:00
|
|
|
void UAVObjRequestUpdate(UAVObjHandle obj);
|
2010-03-04 04:04:39 +01:00
|
|
|
void UAVObjRequestInstanceUpdate(UAVObjHandle obj, uint16_t instId);
|
2010-02-27 20:57:45 +01:00
|
|
|
void UAVObjUpdated(UAVObjHandle obj);
|
2010-03-04 04:04:39 +01:00
|
|
|
void UAVObjInstanceUpdated(UAVObjHandle obj, uint16_t instId);
|
2010-02-27 20:57:45 +01:00
|
|
|
void UAVObjIterate(void (*iterator)(UAVObjHandle obj));
|
2010-02-22 03:18:23 +01:00
|
|
|
|
2010-02-27 20:57:45 +01:00
|
|
|
#endif // UAVOBJECTMANAGER_H
|
2010-08-27 02:15:42 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
* @}
|
|
|
|
*/
|