mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-26 15:54:15 +01:00
Merged in alessiomorale/librepilot/amorale/LP-207_callback_optimizations (pull request #149)
Amorale/lp 207_callback_optimizations
This commit is contained in:
commit
9b45435928
@ -1,20 +1,20 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup UAVObjects OpenPilot UAVObjects
|
||||
* @{
|
||||
* @addtogroup $(NAME) $(NAME)
|
||||
* @{
|
||||
* @addtogroup $(NAME) $(NAME)
|
||||
* @brief $(DESCRIPTION)
|
||||
*
|
||||
* Autogenerated files and functions for $(NAME) Object
|
||||
*
|
||||
* @{
|
||||
* @{
|
||||
*
|
||||
* @file $(NAMELC).h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2013.
|
||||
* @brief Implementation of the $(NAME) object. This file has been
|
||||
* @brief Implementation of the $(NAME) object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: $(XMLFILE).
|
||||
*
|
||||
* @note Object definition file: $(XMLFILE).
|
||||
* This is an automatically generated file.
|
||||
* DO NOT modify manually.
|
||||
*
|
||||
@ -39,7 +39,7 @@
|
||||
|
||||
#ifndef $(NAMEUC)_H
|
||||
#define $(NAMEUC)_H
|
||||
|
||||
#include <stdbool.h>
|
||||
/* Object constants */
|
||||
#define $(NAMEUC)_OBJID $(OBJIDHEX)
|
||||
#define $(NAMEUC)_ISSINGLEINST $(ISSINGLEINST)
|
||||
@ -61,7 +61,8 @@ $(DATASTRUCTURES)
|
||||
* (eg a single instance on the heap)
|
||||
*/
|
||||
typedef struct {
|
||||
$(DATAFIELDS)} __attribute__((packed)) $(NAME)DataPacked;
|
||||
$(DATAFIELDS)
|
||||
} __attribute__((packed)) $(NAME)DataPacked;
|
||||
|
||||
/*
|
||||
* Packed Object data.
|
||||
@ -69,24 +70,59 @@ $(DATAFIELDS)} __attribute__((packed)) $(NAME)DataPacked;
|
||||
* on Cortex M4F during load/store of float UAVO fields
|
||||
*/
|
||||
typedef $(NAME)DataPacked __attribute__((aligned(4))) $(NAME)Data;
|
||||
|
||||
|
||||
/* Typesafe Object access functions */
|
||||
static inline int32_t $(NAME)Get($(NAME)Data *dataOut) { return UAVObjGetData($(NAME)Handle(), dataOut); }
|
||||
static inline int32_t $(NAME)Set(const $(NAME)Data *dataIn) { return UAVObjSetData($(NAME)Handle(), dataIn); }
|
||||
static inline int32_t $(NAME)InstGet(uint16_t instId, $(NAME)Data *dataOut) { return UAVObjGetInstanceData($(NAME)Handle(), instId, dataOut); }
|
||||
static inline int32_t $(NAME)InstSet(uint16_t instId, const $(NAME)Data *dataIn) { return UAVObjSetInstanceData($(NAME)Handle(), instId, dataIn); }
|
||||
static inline int32_t $(NAME)ConnectQueue(xQueueHandle queue) { return UAVObjConnectQueue($(NAME)Handle(), queue, EV_MASK_ALL_UPDATES); }
|
||||
static inline int32_t $(NAME)ConnectCallback(UAVObjEventCallback cb) { return UAVObjConnectCallback($(NAME)Handle(), cb, EV_MASK_ALL_UPDATES); }
|
||||
static inline uint16_t $(NAME)CreateInstance() { return UAVObjCreateInstance($(NAME)Handle(), &$(NAME)SetDefaults); }
|
||||
static inline void $(NAME)RequestUpdate() { UAVObjRequestUpdate($(NAME)Handle()); }
|
||||
static inline void $(NAME)RequestInstUpdate(uint16_t instId) { UAVObjRequestInstanceUpdate($(NAME)Handle(), instId); }
|
||||
static inline void $(NAME)Updated() { UAVObjUpdated($(NAME)Handle()); }
|
||||
static inline void $(NAME)InstUpdated(uint16_t instId) { UAVObjInstanceUpdated($(NAME)Handle(), instId); }
|
||||
static inline void $(NAME)Logging() { UAVObjLogging($(NAME)Handle()); }
|
||||
static inline void $(NAME)InstLogging(uint16_t instId) { UAVObjInstanceLogging($(NAME)Handle(), instId); }
|
||||
static inline int32_t $(NAME)GetMetadata(UAVObjMetadata *dataOut) { return UAVObjGetMetadata($(NAME)Handle(), dataOut); }
|
||||
static inline int32_t $(NAME)SetMetadata(const UAVObjMetadata *dataIn) { return UAVObjSetMetadata($(NAME)Handle(), dataIn); }
|
||||
static inline int8_t $(NAME)ReadOnly() { return UAVObjReadOnly($(NAME)Handle()); }
|
||||
static inline int32_t $(NAME)Get($(NAME)Data * dataOut) {
|
||||
return UAVObjGetData($(NAME)Handle(), dataOut);
|
||||
}
|
||||
static inline int32_t $(NAME)Set(const $(NAME)Data * dataIn) {
|
||||
return UAVObjSetData($(NAME)Handle(), dataIn);
|
||||
}
|
||||
static inline int32_t $(NAME)InstGet(uint16_t instId, $(NAME)Data * dataOut) {
|
||||
return UAVObjGetInstanceData($(NAME)Handle(), instId, dataOut);
|
||||
}
|
||||
static inline int32_t $(NAME)InstSet(uint16_t instId, const $(NAME)Data * dataIn) {
|
||||
return UAVObjSetInstanceData($(NAME)Handle(), instId, dataIn);
|
||||
}
|
||||
static inline int32_t $(NAME)ConnectQueue(xQueueHandle queue) {
|
||||
return UAVObjConnectQueue($(NAME)Handle(), queue, EV_MASK_ALL_UPDATES);
|
||||
}
|
||||
static inline int32_t $(NAME)ConnectCallback(UAVObjEventCallback cb) {
|
||||
return UAVObjConnectCallback($(NAME)Handle(), cb, EV_MASK_ALL_UPDATES, false);
|
||||
}
|
||||
static inline int32_t $(NAME)ConnectFastCallback(UAVObjEventCallback cb) {
|
||||
return UAVObjConnectCallback($(NAME)Handle(), cb, EV_MASK_ALL_UPDATES, true);
|
||||
}
|
||||
static inline uint16_t $(NAME)CreateInstance() {
|
||||
return UAVObjCreateInstance($(NAME)Handle(), &$(NAME)SetDefaults);
|
||||
}
|
||||
static inline void $(NAME)RequestUpdate() {
|
||||
UAVObjRequestUpdate($(NAME)Handle());
|
||||
}
|
||||
static inline void $(NAME)RequestInstUpdate(uint16_t instId) {
|
||||
UAVObjRequestInstanceUpdate($(NAME)Handle(), instId);
|
||||
}
|
||||
static inline void $(NAME)Updated() {
|
||||
UAVObjUpdated($(NAME)Handle());
|
||||
}
|
||||
static inline void $(NAME)InstUpdated(uint16_t instId) {
|
||||
UAVObjInstanceUpdated($(NAME)Handle(), instId);
|
||||
}
|
||||
static inline void $(NAME)Logging() {
|
||||
UAVObjLogging($(NAME)Handle());
|
||||
}
|
||||
static inline void $(NAME)InstLogging(uint16_t instId) {
|
||||
UAVObjInstanceLogging($(NAME)Handle(), instId);
|
||||
}
|
||||
static inline int32_t $(NAME)GetMetadata(UAVObjMetadata * dataOut) {
|
||||
return UAVObjGetMetadata($(NAME)Handle(), dataOut);
|
||||
}
|
||||
static inline int32_t $(NAME)SetMetadata(const UAVObjMetadata * dataIn) {
|
||||
return UAVObjSetMetadata($(NAME)Handle(), dataIn);
|
||||
}
|
||||
static inline int8_t $(NAME)ReadOnly() {
|
||||
return UAVObjReadOnly($(NAME)Handle());
|
||||
}
|
||||
|
||||
/* Set/Get functions */
|
||||
$(SETGETFIELDSEXTERN)
|
||||
|
@ -236,7 +236,7 @@ void UAVObjSetLoggingUpdateMode(UAVObjMetadata *dataOut, UAVObjUpdateMode val);
|
||||
int8_t UAVObjReadOnly(UAVObjHandle obj);
|
||||
int32_t UAVObjConnectQueue(UAVObjHandle obj_handle, xQueueHandle queue, uint8_t eventMask);
|
||||
int32_t UAVObjDisconnectQueue(UAVObjHandle obj_handle, xQueueHandle queue);
|
||||
int32_t UAVObjConnectCallback(UAVObjHandle obj_handle, UAVObjEventCallback cb, uint8_t eventMask);
|
||||
int32_t UAVObjConnectCallback(UAVObjHandle obj_handle, UAVObjEventCallback cb, uint8_t eventMask, bool fast);
|
||||
int32_t UAVObjDisconnectCallback(UAVObjHandle obj_handle, UAVObjEventCallback cb);
|
||||
void UAVObjRequestUpdate(UAVObjHandle obj);
|
||||
void UAVObjRequestInstanceUpdate(UAVObjHandle obj_handle, uint16_t instId);
|
||||
|
@ -73,6 +73,7 @@ struct ObjectEventEntry {
|
||||
xQueueHandle queue;
|
||||
UAVObjEventCallback cb;
|
||||
uint8_t eventMask;
|
||||
bool fast;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -37,7 +37,7 @@
|
||||
|
||||
// Private functions
|
||||
static InstanceHandle createInstance(struct UAVOData *obj, uint16_t instId);
|
||||
static int32_t connectObj(UAVObjHandle obj_handle, xQueueHandle queue, UAVObjEventCallback cb, uint8_t eventMask);
|
||||
static int32_t connectObj(UAVObjHandle obj_handle, xQueueHandle queue, UAVObjEventCallback cb, uint8_t eventMask, bool fast);
|
||||
static int32_t disconnectObj(UAVObjHandle obj_handle, xQueueHandle queue, UAVObjEventCallback cb);
|
||||
static void instanceAutoUpdated(UAVObjHandle obj_handle, uint16_t instId);
|
||||
|
||||
@ -67,6 +67,84 @@ static const UAVObjMetadata defMetadata = {
|
||||
|
||||
static UAVObjStats stats;
|
||||
|
||||
|
||||
static inline bool IsMetaobject(UAVObjHandle obj_handle)
|
||||
{
|
||||
/* Recover the common object header */
|
||||
struct UAVOBase *uavo_base = (struct UAVOBase *)obj_handle;
|
||||
|
||||
return uavo_base->flags.isMeta;
|
||||
}
|
||||
|
||||
static inline bool IsSingleInstance(UAVObjHandle obj_handle)
|
||||
{
|
||||
/* Recover the common object header */
|
||||
struct UAVOBase *uavo_base = (struct UAVOBase *)obj_handle;
|
||||
|
||||
return uavo_base->flags.isSingle;
|
||||
}
|
||||
|
||||
static inline bool IsSettings(UAVObjHandle obj_handle)
|
||||
{
|
||||
/* Recover the common object header */
|
||||
struct UAVOBase *uavo_base = (struct UAVOBase *)obj_handle;
|
||||
|
||||
return uavo_base->flags.isSettings;
|
||||
}
|
||||
|
||||
static inline bool IsPriority(UAVObjHandle obj_handle)
|
||||
{
|
||||
/* Recover the common object header */
|
||||
struct UAVOBase *uavo_base = (struct UAVOBase *)obj_handle;
|
||||
|
||||
return uavo_base->flags.isPriority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a metaobject?
|
||||
* \param[in] obj The object handle
|
||||
* \return True (1) if this is metaobject
|
||||
*/
|
||||
bool UAVObjIsMetaobject(UAVObjHandle obj_handle)
|
||||
{
|
||||
PIOS_Assert(obj_handle);
|
||||
return IsMetaobject(obj_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this object contains a single instance or multiple instances?
|
||||
* \param[in] obj The object handle
|
||||
* \return True (1) if this is a single instance object
|
||||
*/
|
||||
bool UAVObjIsSingleInstance(UAVObjHandle obj_handle)
|
||||
{
|
||||
PIOS_Assert(obj_handle);
|
||||
return IsSingleInstance(obj_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a settings object?
|
||||
* \param[in] obj The object handle
|
||||
* \return True (1) if this is a settings object
|
||||
*/
|
||||
bool UAVObjIsSettings(UAVObjHandle obj_handle)
|
||||
{
|
||||
PIOS_Assert(obj_handle);
|
||||
return IsSettings(obj_handle);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is this a prioritized object?
|
||||
* \param[in] obj The object handle
|
||||
* \return True (1) if this is a prioritized object
|
||||
*/
|
||||
bool UAVObjIsPriority(UAVObjHandle obj_handle)
|
||||
{
|
||||
return IsPriority(obj_handle);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the object manager
|
||||
* \return 0 Success
|
||||
@ -309,7 +387,7 @@ uint32_t UAVObjGetID(UAVObjHandle obj_handle)
|
||||
/* Recover the common object header */
|
||||
struct UAVOBase *uavo_base = (struct UAVOBase *)obj_handle;
|
||||
|
||||
if (UAVObjIsMetaobject(obj_handle)) {
|
||||
if (IsMetaobject(obj_handle)) {
|
||||
/* We have a meta object, find our containing UAVO */
|
||||
struct UAVOData *uavo_data = container_of((struct UAVOMeta *)uavo_base, struct UAVOData, metaObj);
|
||||
|
||||
@ -362,7 +440,7 @@ UAVObjHandle UAVObjGetLinkedObj(UAVObjHandle obj_handle)
|
||||
/* Recover the common object header */
|
||||
struct UAVOBase *uavo_base = (struct UAVOBase *)obj_handle;
|
||||
|
||||
if (UAVObjIsMetaobject(obj_handle)) {
|
||||
if (IsMetaobject(obj_handle)) {
|
||||
/* We have a meta object, find our containing UAVO. */
|
||||
struct UAVOData *uavo_data = container_of((struct UAVOMeta *)uavo_base, struct UAVOData, metaObj);
|
||||
|
||||
@ -384,7 +462,7 @@ uint16_t UAVObjGetNumInstances(UAVObjHandle obj_handle)
|
||||
{
|
||||
PIOS_Assert(obj_handle);
|
||||
|
||||
if (UAVObjIsSingleInstance(obj_handle)) {
|
||||
if (IsSingleInstance(obj_handle)) {
|
||||
/* Only one instance is allowed */
|
||||
return 1;
|
||||
} else {
|
||||
@ -405,7 +483,7 @@ uint16_t UAVObjCreateInstance(UAVObjHandle obj_handle,
|
||||
{
|
||||
PIOS_Assert(obj_handle);
|
||||
|
||||
if (UAVObjIsMetaobject(obj_handle)) {
|
||||
if (IsMetaobject(obj_handle)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -433,67 +511,6 @@ unlock_exit:
|
||||
return instId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this object contains a single instance or multiple instances?
|
||||
* \param[in] obj The object handle
|
||||
* \return True (1) if this is a single instance object
|
||||
*/
|
||||
bool UAVObjIsSingleInstance(UAVObjHandle obj_handle)
|
||||
{
|
||||
PIOS_Assert(obj_handle);
|
||||
|
||||
/* Recover the common object header */
|
||||
struct UAVOBase *uavo_base = (struct UAVOBase *)obj_handle;
|
||||
|
||||
return uavo_base->flags.isSingle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a metaobject?
|
||||
* \param[in] obj The object handle
|
||||
* \return True (1) if this is metaobject
|
||||
*/
|
||||
bool UAVObjIsMetaobject(UAVObjHandle obj_handle)
|
||||
{
|
||||
PIOS_Assert(obj_handle);
|
||||
|
||||
/* Recover the common object header */
|
||||
struct UAVOBase *uavo_base = (struct UAVOBase *)obj_handle;
|
||||
|
||||
return uavo_base->flags.isMeta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a settings object?
|
||||
* \param[in] obj The object handle
|
||||
* \return True (1) if this is a settings object
|
||||
*/
|
||||
bool UAVObjIsSettings(UAVObjHandle obj_handle)
|
||||
{
|
||||
PIOS_Assert(obj_handle);
|
||||
|
||||
/* Recover the common object header */
|
||||
struct UAVOBase *uavo_base = (struct UAVOBase *)obj_handle;
|
||||
|
||||
return uavo_base->flags.isSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a prioritized object?
|
||||
* \param[in] obj The object handle
|
||||
* \return True (1) if this is a prioritized object
|
||||
*/
|
||||
bool UAVObjIsPriority(UAVObjHandle obj_handle)
|
||||
{
|
||||
PIOS_Assert(obj_handle);
|
||||
|
||||
/* Recover the common object header */
|
||||
struct UAVOBase *uavo_base = (struct UAVOBase *)obj_handle;
|
||||
|
||||
return uavo_base->flags.isPriority;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unpack an object from a byte array
|
||||
* \param[in] obj The object handle
|
||||
@ -510,7 +527,7 @@ int32_t UAVObjUnpack(UAVObjHandle obj_handle, uint16_t instId, const uint8_t *da
|
||||
|
||||
int32_t rc = -1;
|
||||
|
||||
if (UAVObjIsMetaobject(obj_handle)) {
|
||||
if (IsMetaobject(obj_handle)) {
|
||||
if (instId != 0) {
|
||||
goto unlock_exit;
|
||||
}
|
||||
@ -561,7 +578,7 @@ int32_t UAVObjPack(UAVObjHandle obj_handle, uint16_t instId, uint8_t *dataOut)
|
||||
|
||||
int32_t rc = -1;
|
||||
|
||||
if (UAVObjIsMetaobject(obj_handle)) {
|
||||
if (IsMetaobject(obj_handle)) {
|
||||
if (instId != 0) {
|
||||
goto unlock_exit;
|
||||
}
|
||||
@ -603,7 +620,7 @@ uint8_t UAVObjUpdateCRC(UAVObjHandle obj_handle, uint16_t instId, uint8_t crc)
|
||||
// Lock
|
||||
xSemaphoreTakeRecursive(mutex, portMAX_DELAY);
|
||||
|
||||
if (UAVObjIsMetaobject(obj_handle)) {
|
||||
if (IsMetaobject(obj_handle)) {
|
||||
if (instId != 0) {
|
||||
goto unlock_exit;
|
||||
}
|
||||
@ -642,7 +659,7 @@ void UAVObjInstanceWriteToLog(UAVObjHandle obj_handle, uint16_t instId)
|
||||
// Lock
|
||||
xSemaphoreTakeRecursive(mutex, portMAX_DELAY);
|
||||
|
||||
if (UAVObjIsMetaobject(obj_handle)) {
|
||||
if (IsMetaobject(obj_handle)) {
|
||||
if (instId != 0) {
|
||||
goto unlock_exit;
|
||||
}
|
||||
@ -683,7 +700,7 @@ int32_t UAVObjSaveSettings()
|
||||
// Save all settings objects
|
||||
UAVO_LIST_ITERATE(obj)
|
||||
// Check if this is a settings object
|
||||
if (UAVObjIsSettings(obj)) {
|
||||
if (IsSettings(obj)) {
|
||||
// Save object
|
||||
if (UAVObjSave((UAVObjHandle)obj, 0) ==
|
||||
-1) {
|
||||
@ -713,7 +730,7 @@ int32_t UAVObjLoadSettings()
|
||||
// Load all settings objects
|
||||
UAVO_LIST_ITERATE(obj)
|
||||
// Check if this is a settings object
|
||||
if (UAVObjIsSettings(obj)) {
|
||||
if (IsSettings(obj)) {
|
||||
// Load object
|
||||
if (UAVObjLoad((UAVObjHandle)obj, 0) ==
|
||||
-1) {
|
||||
@ -743,7 +760,7 @@ int32_t UAVObjDeleteSettings()
|
||||
// Save all settings objects
|
||||
UAVO_LIST_ITERATE(obj)
|
||||
// Check if this is a settings object
|
||||
if (UAVObjIsSettings(obj)) {
|
||||
if (IsSettings(obj)) {
|
||||
// Save object
|
||||
if (UAVObjDelete((UAVObjHandle)obj, 0)
|
||||
== -1) {
|
||||
@ -901,7 +918,7 @@ int32_t UAVObjSetInstanceData(UAVObjHandle obj_handle, uint16_t instId,
|
||||
|
||||
int32_t rc = -1;
|
||||
|
||||
if (UAVObjIsMetaobject(obj_handle)) {
|
||||
if (IsMetaobject(obj_handle)) {
|
||||
if (instId != 0) {
|
||||
goto unlock_exit;
|
||||
}
|
||||
@ -951,7 +968,7 @@ int32_t UAVObjSetInstanceDataField(UAVObjHandle obj_handle, uint16_t instId, con
|
||||
|
||||
int32_t rc = -1;
|
||||
|
||||
if (UAVObjIsMetaobject(obj_handle)) {
|
||||
if (IsMetaobject(obj_handle)) {
|
||||
// Get instance information
|
||||
if (instId != 0) {
|
||||
goto unlock_exit;
|
||||
@ -1018,7 +1035,7 @@ int32_t UAVObjGetInstanceData(UAVObjHandle obj_handle, uint16_t instId,
|
||||
|
||||
int32_t rc = -1;
|
||||
|
||||
if (UAVObjIsMetaobject(obj_handle)) {
|
||||
if (IsMetaobject(obj_handle)) {
|
||||
// Get instance information
|
||||
if (instId != 0) {
|
||||
goto unlock_exit;
|
||||
@ -1064,7 +1081,7 @@ int32_t UAVObjGetInstanceDataField(UAVObjHandle obj_handle, uint16_t instId, voi
|
||||
|
||||
int32_t rc = -1;
|
||||
|
||||
if (UAVObjIsMetaobject(obj_handle)) {
|
||||
if (IsMetaobject(obj_handle)) {
|
||||
// Get instance information
|
||||
if (instId != 0) {
|
||||
goto unlock_exit;
|
||||
@ -1117,7 +1134,7 @@ int32_t UAVObjSetMetadata(UAVObjHandle obj_handle, const UAVObjMetadata *dataIn)
|
||||
PIOS_Assert(obj_handle);
|
||||
|
||||
// Set metadata (metadata of metaobjects can not be modified)
|
||||
if (UAVObjIsMetaobject(obj_handle)) {
|
||||
if (IsMetaobject(obj_handle)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1143,7 +1160,7 @@ int32_t UAVObjGetMetadata(UAVObjHandle obj_handle, UAVObjMetadata *dataOut)
|
||||
xSemaphoreTakeRecursive(mutex, portMAX_DELAY);
|
||||
|
||||
// Get metadata
|
||||
if (UAVObjIsMetaobject(obj_handle)) {
|
||||
if (IsMetaobject(obj_handle)) {
|
||||
memcpy(dataOut, &defMetadata, sizeof(UAVObjMetadata));
|
||||
} else {
|
||||
UAVObjGetData((UAVObjHandle)MetaObjectPtr((struct UAVOData *)obj_handle),
|
||||
@ -1325,7 +1342,7 @@ void UAVObjSetLoggingUpdateMode(UAVObjMetadata *metadata, UAVObjUpdateMode val)
|
||||
int8_t UAVObjReadOnly(UAVObjHandle obj_handle)
|
||||
{
|
||||
PIOS_Assert(obj_handle);
|
||||
if (!UAVObjIsMetaobject(obj_handle)) {
|
||||
if (!IsMetaobject(obj_handle)) {
|
||||
return UAVObjGetAccess(LinkedMetaDataPtr((struct UAVOData *)obj_handle)) == ACCESS_READONLY;
|
||||
}
|
||||
return -1;
|
||||
@ -1346,7 +1363,7 @@ int32_t UAVObjConnectQueue(UAVObjHandle obj_handle, xQueueHandle queue,
|
||||
PIOS_Assert(queue);
|
||||
int32_t res;
|
||||
xSemaphoreTakeRecursive(mutex, portMAX_DELAY);
|
||||
res = connectObj(obj_handle, queue, 0, eventMask);
|
||||
res = connectObj(obj_handle, queue, 0, eventMask, false);
|
||||
xSemaphoreGiveRecursive(mutex);
|
||||
return res;
|
||||
}
|
||||
@ -1377,12 +1394,12 @@ int32_t UAVObjDisconnectQueue(UAVObjHandle obj_handle, xQueueHandle queue)
|
||||
* \return 0 if success or -1 if failure
|
||||
*/
|
||||
int32_t UAVObjConnectCallback(UAVObjHandle obj_handle, UAVObjEventCallback cb,
|
||||
uint8_t eventMask)
|
||||
uint8_t eventMask, bool fast)
|
||||
{
|
||||
PIOS_Assert(obj_handle);
|
||||
int32_t res;
|
||||
xSemaphoreTakeRecursive(mutex, portMAX_DELAY);
|
||||
res = connectObj(obj_handle, 0, cb, eventMask);
|
||||
res = connectObj(obj_handle, 0, cb, eventMask, fast);
|
||||
xSemaphoreGiveRecursive(mutex);
|
||||
return res;
|
||||
}
|
||||
@ -1535,8 +1552,10 @@ int32_t sendEvent(struct UAVOBase *obj, uint16_t instId, UAVObjEventType trigger
|
||||
|
||||
// Invoke callback (from event task) if a valid one is registered
|
||||
if (event->cb) {
|
||||
// invoke callback from the event task, will not block
|
||||
if (EventCallbackDispatch(&msg, event->cb) != pdTRUE) {
|
||||
if (event->fast) {
|
||||
event->cb(&msg);
|
||||
} else if (EventCallbackDispatch(&msg, event->cb) != pdTRUE) {
|
||||
// invoke callback from the event task, will not block
|
||||
++stats.eventCallbackErrors;
|
||||
stats.lastCallbackErrorID = UAVObjGetID(obj);
|
||||
}
|
||||
@ -1555,7 +1574,7 @@ static InstanceHandle createInstance(struct UAVOData *obj, uint16_t instId)
|
||||
struct UAVOMultiInst *instEntry;
|
||||
|
||||
/* Don't allow more than one instance for single instance objects */
|
||||
if (UAVObjIsSingleInstance(&(obj->base))) {
|
||||
if (IsSingleInstance(&(obj->base))) {
|
||||
PIOS_Assert(0);
|
||||
return NULL;
|
||||
}
|
||||
@ -1600,7 +1619,7 @@ static InstanceHandle createInstance(struct UAVOData *obj, uint16_t instId)
|
||||
*/
|
||||
InstanceHandle getInstance(struct UAVOData *obj, uint16_t instId)
|
||||
{
|
||||
if (UAVObjIsMetaobject(&obj->base)) {
|
||||
if (IsMetaobject(&obj->base)) {
|
||||
/* Metadata Instance */
|
||||
|
||||
if (instId != 0) {
|
||||
@ -1610,7 +1629,7 @@ InstanceHandle getInstance(struct UAVOData *obj, uint16_t instId)
|
||||
/* Augment our pointer to reflect the proper type */
|
||||
struct UAVOMeta *uavo_meta = (struct UAVOMeta *)obj;
|
||||
return &(uavo_meta->instance0);
|
||||
} else if (UAVObjIsSingleInstance(&(obj->base))) {
|
||||
} else if (IsSingleInstance(&(obj->base))) {
|
||||
/* Single Instance */
|
||||
|
||||
if (instId != 0) {
|
||||
@ -1651,7 +1670,7 @@ InstanceHandle getInstance(struct UAVOData *obj, uint16_t instId)
|
||||
* \return 0 if success or -1 if failure
|
||||
*/
|
||||
static int32_t connectObj(UAVObjHandle obj_handle, xQueueHandle queue,
|
||||
UAVObjEventCallback cb, uint8_t eventMask)
|
||||
UAVObjEventCallback cb, uint8_t eventMask, bool fast)
|
||||
{
|
||||
struct ObjectEventEntry *event;
|
||||
struct UAVOBase *obj;
|
||||
@ -1662,6 +1681,7 @@ static int32_t connectObj(UAVObjHandle obj_handle, xQueueHandle queue,
|
||||
if (event->queue == queue && event->cb == cb) {
|
||||
// Already connected, update event mask and return
|
||||
event->eventMask = eventMask;
|
||||
event->fast = fast;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1674,6 +1694,7 @@ static int32_t connectObj(UAVObjHandle obj_handle, xQueueHandle queue,
|
||||
event->queue = queue;
|
||||
event->cb = cb;
|
||||
event->eventMask = eventMask;
|
||||
event->fast = fast;
|
||||
LL_APPEND(obj->next_event, event);
|
||||
|
||||
// Done
|
||||
|
Loading…
x
Reference in New Issue
Block a user