dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
UAVObject handling code

Files

file  eventdispatcher.h
 Event dispatcher, distributes object events as callbacks. Alternative to using tasks and queues. All callbacks are invoked from the event task.
 
file  uavobjectmanager.c
 Object manager library. This library holds a collection of all objects. It can be used by all modules/libraries to find an object reference.
 

Data Structures

struct  EventStats
 
struct  ObjectEventEntry
 
struct  ObjectEventEntryThrottled
 
struct  UAVOBase
 
struct  UAVOMeta
 
struct  UAVOData
 
struct  UAVOSingle
 
struct  UAVOMultiInst
 
struct  UAVOMulti
 

Macros

#define SET_BITS(var, shift, value, mask)   var = (var & ~(mask << shift)) | (value << shift);
 
#define MetaNumBytes   sizeof(UAVObjMetadata)
 
#define MetaBaseObjectPtr(obj)   ((struct UAVOData *)((obj)-offsetof(struct UAVOData, metaObj)))
 
#define MetaObjectPtr(obj)   (&((obj)->metaObj.base))
 
#define MetaDataPtr(obj)   ((UAVObjMetadata*)&((obj)->instance0))
 
#define LinkedMetaDataPtr(obj)   ((UAVObjMetadata*)&((obj)->metaObj.instance0))
 
#define MetaObjectId(id)   ((id)+1)
 
#define ObjSingleInstanceDataOffset(obj)   ((void*)(&(( (struct UAVOSingle*)obj )->instance0)))
 
#define InstanceDataOffset(inst)   ((void*)&(( (struct UAVOMultiInst*)inst )->instance))
 
#define InstanceData(instance)   (void*)instance
 
#define UAVO_CB_STACK_SIZE   512
 
#define INSTANCE_COPY_ALL   0xffffffff
 
#define invokeCallback   realInvokeCallback
 

Typedefs

typedef void * InstanceHandle
 

Functions

void EventGetStats (EventStats *statsOut)
 
void EventClearStats ()
 
int32_t EventPeriodicCallbackCreate (UAVObjEvent *ev, UAVObjEventCallback cb, uint16_t periodMs)
 
int32_t EventPeriodicCallbackUpdate (UAVObjEvent *ev, UAVObjEventCallback cb, uint16_t periodMs)
 
int32_t EventPeriodicQueueCreate (UAVObjEvent *ev, struct pios_queue *queue, uint16_t periodMs)
 
int32_t EventPeriodicQueueUpdate (UAVObjEvent *ev, struct pios_queue *queue, uint16_t periodMs)
 
struct UAVOBase __attribute__ ((packed))
 
static int32_t sendEvent (struct UAVOBase *obj, uint16_t instId, UAVObjEventType event, void *obj_data, int len)
 
static InstanceHandle createInstance (struct UAVOData *obj, uint16_t instId)
 
static InstanceHandle getInstance (struct UAVOData *obj, uint16_t instId)
 
static int32_t connectObj (UAVObjHandle obj_handle, struct pios_queue *queue, UAVObjEventCallback cb, void *cbCtx, uint8_t eventMask, uint16_t interval)
 
static int32_t disconnectObj (UAVObjHandle obj_handle, struct pios_queue *queue, UAVObjEventCallback cb, void *cbCtx)
 
int32_t UAVObjInitialize ()
 
void UAVObjGetStats (UAVObjStats *statsOut)
 
void UAVObjClearStats ()
 
static void UAVObjInitMetaData (struct UAVOMeta *obj_meta)
 
static struct UAVODataUAVObjAllocSingle (uint32_t num_bytes)
 
static struct UAVODataUAVObjAllocMulti (uint32_t num_bytes)
 
UAVObjHandle UAVObjRegister (uint32_t id, int32_t isSingleInstance, int32_t isSettings, uint32_t num_bytes, UAVObjInitializeCallback initCb)
 
UAVObjHandle UAVObjGetByID (uint32_t id)
 
uint32_t UAVObjGetID (UAVObjHandle obj_handle)
 
uint32_t UAVObjGetNumBytes (UAVObjHandle obj)
 
UAVObjHandle UAVObjGetLinkedObj (UAVObjHandle obj_handle)
 
uint16_t UAVObjGetNumInstances (UAVObjHandle obj_handle)
 
uint16_t UAVObjCreateInstance (UAVObjHandle obj_handle, UAVObjInitializeCallback initCb)
 
bool UAVObjIsSingleInstance (UAVObjHandle obj_handle)
 
bool UAVObjIsMetaobject (UAVObjHandle obj_handle)
 
bool UAVObjIsSettings (UAVObjHandle obj_handle)
 
int32_t UAVObjUnpack (UAVObjHandle obj_handle, uint16_t instId, const uint8_t *dataIn)
 
int32_t UAVObjPack (UAVObjHandle obj_handle, uint16_t instId, uint8_t *dataOut)
 
int32_t UAVObjSave (UAVObjHandle obj_handle, uint16_t instId)
 
int32_t UAVObjLoad (UAVObjHandle obj_handle, uint16_t instId)
 
int32_t UAVObjDeleteById (uint32_t obj_id, uint16_t inst_id)
 
int32_t UAVObjSaveSettings ()
 
int32_t UAVObjLoadSettings ()
 
int32_t UAVObjDeleteSettings ()
 
int32_t UAVObjSaveMetaobjects ()
 
int32_t UAVObjLoadMetaobjects ()
 
int32_t UAVObjDeleteMetaobjects ()
 
int32_t UAVObjSetData (UAVObjHandle obj_handle, const void *dataIn)
 
int32_t UAVObjSetDataField (UAVObjHandle obj_handle, const void *dataIn, uint32_t offset, uint32_t size)
 
int32_t UAVObjGetData (UAVObjHandle obj_handle, void *dataOut)
 
int32_t UAVObjGetDataField (UAVObjHandle obj_handle, void *dataOut, uint32_t offset, uint32_t size)
 
int32_t UAVObjSetInstanceData (UAVObjHandle obj_handle, uint16_t instId, const void *dataIn)
 
int32_t UAVObjSetInstanceDataField (UAVObjHandle obj_handle, uint16_t instId, const void *dataIn, uint32_t offset, uint32_t size)
 
int32_t UAVObjGetInstanceData (UAVObjHandle obj_handle, uint16_t instId, void *dataOut)
 
int32_t UAVObjGetInstanceDataField (UAVObjHandle obj_handle, uint16_t instId, void *dataOut, uint32_t offset, uint32_t size)
 
int32_t UAVObjSetMetadata (UAVObjHandle obj_handle, const UAVObjMetadata *dataIn)
 
int32_t UAVObjGetMetadata (UAVObjHandle obj_handle, UAVObjMetadata *dataOut)
 
UAVObjAccessType UAVObjGetAccess (const UAVObjMetadata *metadata)
 
void UAVObjSetAccess (UAVObjMetadata *metadata, UAVObjAccessType mode)
 
UAVObjAccessType UAVObjGetGcsAccess (const UAVObjMetadata *metadata)
 
void UAVObjSetGcsAccess (UAVObjMetadata *metadata, UAVObjAccessType mode)
 
uint8_t UAVObjGetTelemetryAcked (const UAVObjMetadata *metadata)
 
void UAVObjSetTelemetryAcked (UAVObjMetadata *metadata, uint8_t val)
 
uint8_t UAVObjGetGcsTelemetryAcked (const UAVObjMetadata *metadata)
 
void UAVObjSetGcsTelemetryAcked (UAVObjMetadata *metadata, uint8_t val)
 
UAVObjUpdateMode UAVObjGetTelemetryUpdateMode (const UAVObjMetadata *metadata)
 
void UAVObjSetTelemetryUpdateMode (UAVObjMetadata *metadata, UAVObjUpdateMode val)
 
UAVObjUpdateMode UAVObjGetGcsTelemetryUpdateMode (const UAVObjMetadata *metadata)
 
void UAVObjSetGcsTelemetryUpdateMode (UAVObjMetadata *metadata, UAVObjUpdateMode val)
 
int8_t UAVObjReadOnly (UAVObjHandle obj_handle)
 
int32_t UAVObjConnectQueueThrottled (UAVObjHandle obj_handle, struct pios_queue *queue, uint8_t eventMask, uint16_t interval)
 
int32_t UAVObjConnectQueue (UAVObjHandle obj_handle, struct pios_queue *queue, uint8_t eventMask)
 
int32_t UAVObjDisconnectQueue (UAVObjHandle obj_handle, struct pios_queue *queue)
 
void UAVObjCbSetFlag (const UAVObjEvent *objEv, void *ctx, void *obj, int len)
 
void UAVObjCbCopyData (const UAVObjEvent *objEv, void *ctx, void *obj, int len)
 
int32_t UAVObjConnectCallbackThrottled (UAVObjHandle obj_handle, UAVObjEventCallback cb, void *cbCtx, uint8_t eventMask, uint16_t interval)
 
int32_t UAVObjConnectCallback (UAVObjHandle obj_handle, UAVObjEventCallback cb, void *cbCtx, uint8_t eventMask)
 
int32_t UAVObjDisconnectCallback (UAVObjHandle obj_handle, UAVObjEventCallback cb, void *cbCtx)
 
void UAVObjUpdated (UAVObjHandle obj_handle)
 
void UAVObjInstanceUpdated (UAVObjHandle obj_handle, uint16_t instId)
 
void UAVObjIterate (void(*iterator)(UAVObjHandle obj))
 
static void __attribute__ ((used))
 
static int32_t pumpOneEvent (UAVObjEvent *msg, void *obj_data, int len)
 
int32_t getEventMask (UAVObjHandle obj_handle, struct pios_queue *queue)
 
uint8_t UAVObjCount ()
 
uint32_t UAVObjIDByIndex (uint8_t index)
 
void UAVObjUnblockThrottle (struct ObjectEventEntryThrottled *throttled)
 
void UAVObjRegisterNewInstanceCB (new_uavo_instance_cb_t callback)
 

Variables

uintptr_t pios_uavo_settings_fs_id
 
static struct UAVODatauavo_list
 
static struct ObjectEventEntryevents_unused
 
static struct ObjectEventEntryevents_unused_throttled
 
static struct
pios_recursive_mutex
mutex
 
static const UAVObjMetadata defMetadata
 
static UAVObjStats stats
 
static new_uavo_instance_cb_t newUavObjInstanceCB
 
static void * cb_stack
 

Detailed Description

Macro Definition Documentation

#define INSTANCE_COPY_ALL   0xffffffff

Definition at line 1114 of file uavobjectmanager.c.

#define InstanceData (   instance)    (void*)instance

Definition at line 176 of file uavobjectmanager.c.

#define InstanceDataOffset (   inst)    ((void*)&(( (struct UAVOMultiInst*)inst )->instance))

Definition at line 175 of file uavobjectmanager.c.

#define invokeCallback   realInvokeCallback

Definition at line 1722 of file uavobjectmanager.c.

#define LinkedMetaDataPtr (   obj)    ((UAVObjMetadata*)&((obj)->metaObj.instance0))

Definition at line 170 of file uavobjectmanager.c.

#define MetaBaseObjectPtr (   obj)    ((struct UAVOData *)((obj)-offsetof(struct UAVOData, metaObj)))
Todo:
All this reckless casting needs to die a horrific death!

Definition at line 166 of file uavobjectmanager.c.

#define MetaDataPtr (   obj)    ((UAVObjMetadata*)&((obj)->instance0))

Definition at line 169 of file uavobjectmanager.c.

#define MetaNumBytes   sizeof(UAVObjMetadata)

all information about a metaobject are hardcoded constants

Definition at line 163 of file uavobjectmanager.c.

#define MetaObjectId (   id)    ((id)+1)

Definition at line 171 of file uavobjectmanager.c.

#define MetaObjectPtr (   obj)    (&((obj)->metaObj.base))

Definition at line 168 of file uavobjectmanager.c.

#define ObjSingleInstanceDataOffset (   obj)    ((void*)(&(( (struct UAVOSingle*)obj )->instance0)))

all information about instances are dependant on object type

Definition at line 174 of file uavobjectmanager.c.

#define SET_BITS (   var,
  shift,
  value,
  mask 
)    var = (var & ~(mask << shift)) | (value << shift);

Definition at line 53 of file uavobjectmanager.c.

#define UAVO_CB_STACK_SIZE   512

Definition at line 209 of file uavobjectmanager.c.

Typedef Documentation

typedef void* InstanceHandle

List of event queues and the eventmask associated with the queue.opaque type for instances

Definition at line 60 of file uavobjectmanager.c.

Function Documentation

struct UAVOBase __attribute__ ( (packed)  )

Definition at line 38 of file serial_4way.h.

static void __attribute__ ( (used)  )
static

Definition at line 1674 of file uavobjectmanager.c.

static int32_t connectObj ( UAVObjHandle  obj_handle,
struct pios_queue queue,
UAVObjEventCallback  cb,
void *  cbCtx,
uint8_t  eventMask,
uint16_t  interval 
)
static

Connect an event queue to the object, if the queue is already connected then the event mask is only updated.

Parameters
[in]objThe object handle
[in]queueThe event queue
[in]cbThe event callback
[in]eventMaskThe event mask, if EV_MASK_ALL_UPDATES then all events are enabled (e.g. EV_UPDATED | EV_UPDATED_MANUAL)
[in]intervalThe interval at which to throttle updates; 0 is unthrottled
Returns
0 if success or -1 if failure

Definition at line 1976 of file uavobjectmanager.c.

static InstanceHandle createInstance ( struct UAVOData obj,
uint16_t  instId 
)
static

Create a new object instance, return the instance info or NULL if failure.

Definition at line 1876 of file uavobjectmanager.c.

static int32_t disconnectObj ( UAVObjHandle  obj_handle,
struct pios_queue queue,
UAVObjEventCallback  cb,
void *  cbCtx 
)
static

Disconnect an event queue from the object

Parameters
[in]objThe object handle
[in]queueThe event queue
[in]cbThe event callback
Returns
0 if success or -1 if failure

Definition at line 2076 of file uavobjectmanager.c.

void EventClearStats ( )

Clear the statistics counters

Definition at line 869 of file systemmod.c.

void EventGetStats ( EventStats statsOut)

Get the statistics counters

Parameters
[out]statsOutThe statistics counters will be copied there

Definition at line 859 of file systemmod.c.

int32_t EventPeriodicCallbackCreate ( UAVObjEvent ev,
UAVObjEventCallback  cb,
uint16_t  periodMs 
)

Dispatch an event at periodic intervals.

Parameters
[in]evThe event to be dispatched
[in]cbThe callback to be invoked
[in]periodMsThe period the event is generated
Returns
Success (0), failure (-1)
Todo:
would be nice to get context record logic in these

Definition at line 884 of file systemmod.c.

int32_t EventPeriodicCallbackUpdate ( UAVObjEvent ev,
UAVObjEventCallback  cb,
uint16_t  periodMs 
)

Update the period of a periodic event.

Parameters
[in]evThe event to be dispatched
[in]cbThe callback to be invoked
[in]periodMsThe period the event is generated
Returns
Success (0), failure (-1)

Definition at line 896 of file systemmod.c.

int32_t EventPeriodicQueueCreate ( UAVObjEvent ev,
struct pios_queue queue,
uint16_t  periodMs 
)

Dispatch an event at periodic intervals.

Parameters
[in]evThe event to be dispatched
[in]queueThe queue that the event will be pushed in
[in]periodMsThe period the event is generated
Returns
Success (0), failure (-1)

Definition at line 908 of file systemmod.c.

int32_t EventPeriodicQueueUpdate ( UAVObjEvent ev,
struct pios_queue queue,
uint16_t  periodMs 
)

Update the period of a periodic event.

Parameters
[in]evThe event to be dispatched
[in]queueThe queue
[in]periodMsThe period the event is generated
Returns
Success (0), failure (-1)

Definition at line 920 of file systemmod.c.

int32_t getEventMask ( UAVObjHandle  obj_handle,
struct pios_queue queue 
)

getEventMask Iterates through the connections and returns the event mask

Parameters
[in]objThe object handle
[in]queueThe event queue
Returns
eventMask The event mask, if EV_MASK_ALL then all events are disabled

Definition at line 2112 of file uavobjectmanager.c.

static InstanceHandle getInstance ( struct UAVOData obj,
uint16_t  instId 
)
static

Get the instance information or NULL if the instance does not exist

Definition at line 1925 of file uavobjectmanager.c.

static int32_t pumpOneEvent ( UAVObjEvent msg,
void *  obj_data,
int  len 
)
static

Definition at line 1725 of file uavobjectmanager.c.

static int32_t sendEvent ( struct UAVOBase obj,
uint16_t  instId,
UAVObjEventType  triggered_event,
void *  obj_data,
int  len 
)
static

Send a triggered event to all event queues registered on the object.

Definition at line 1787 of file uavobjectmanager.c.

static struct UAVOData* UAVObjAllocMulti ( uint32_t  num_bytes)
static

Definition at line 308 of file uavobjectmanager.c.

static struct UAVOData* UAVObjAllocSingle ( uint32_t  num_bytes)
static

Definition at line 285 of file uavobjectmanager.c.

void UAVObjCbCopyData ( const UAVObjEvent objEv,
void *  ctx,
void *  obj,
int  len 
)

Copies the passed in object to the ctx pointer. Conforms to the UAVObjConnectCallback* signature.

Using UAVObjCbSetFlag is preferred. This should only be used via the wrapper in the individual UAV objects to ensure that objects are not mismatched (wrong registration type -> ctx mapping).

Parameters
[in]ctxThe event callback context.
[in]objThe pointer to the raw object data.
[in]lenThe length of data to copy.

Definition at line 1579 of file uavobjectmanager.c.

void UAVObjCbSetFlag ( const UAVObjEvent objEv,
void *  ctx,
void *  obj,
int  len 
)

Sets a flag passed in the ctx parameter to true. Conforms to the UAVObjConnectCallback* signature.

Using this is a best practice to listen for configuration changes. This sets a volatile flag that you can check at the top of the task main function, and update configuration as appropriate.

Note that the flag is considered a uint8_t, but the width doesn't really matter– it will be "set" as long as it is at least 8 bits wide.

Parameters
[in]ctxThe event callback context

Definition at line 1560 of file uavobjectmanager.c.

void UAVObjClearStats ( )

Clear the statistics counters

Definition at line 261 of file uavobjectmanager.c.

int32_t UAVObjConnectCallback ( UAVObjHandle  obj_handle,
UAVObjEventCallback  cb,
void *  cbCtx,
uint8_t  eventMask 
)

Definition at line 1604 of file uavobjectmanager.c.

int32_t UAVObjConnectCallbackThrottled ( UAVObjHandle  obj_handle,
UAVObjEventCallback  cb,
void *  cbCtx,
uint8_t  eventMask,
uint16_t  interval 
)

Connect an event callback to the object, if the callback is already connected then the event mask is only updated. The supplied callback will be invoked on all events matching the event mask.

Parameters
[in]objThe object handle
[in]cbThe event callback
[in]eventMaskThe event mask, if EV_MASK_ALL_UPDATES then all events are enabled (e.g. EV_UPDATED | EV_UPDATED_MANUAL)
[in]intervalThe interval at which to throttle updates; 0 is unthrottled
Returns
0 if success or -1 if failure

Definition at line 1593 of file uavobjectmanager.c.

int32_t UAVObjConnectQueue ( UAVObjHandle  obj_handle,
struct pios_queue queue,
uint8_t  eventMask 
)

Definition at line 1524 of file uavobjectmanager.c.

int32_t UAVObjConnectQueueThrottled ( UAVObjHandle  obj_handle,
struct pios_queue queue,
uint8_t  eventMask,
uint16_t  interval 
)

Connect an event queue to the object, if the queue is already connected then the event mask is only updated. All events matching the event mask will be pushed to the event queue.

Parameters
[in]objThe object handle
[in]queueThe event queue
[in]eventMaskThe event mask, if EV_MASK_ALL_UPDATES then all events are enabled (e.g. EV_UPDATED | EV_UPDATED_MANUAL)
[in]intervalThe interval at which to throttle updates; 0 is unthrottled
Returns
0 if success or -1 if failure

Definition at line 1512 of file uavobjectmanager.c.

uint8_t UAVObjCount ( )

UAVObjCount returns the registered uav objects count

Returns
number of registered uav objects

Definition at line 2136 of file uavobjectmanager.c.

uint16_t UAVObjCreateInstance ( UAVObjHandle  obj_handle,
UAVObjInitializeCallback  initCb 
)

Create a new instance in the object.

Parameters
[in]objThe object handle
Returns
The instance ID or 0 if an error

Definition at line 538 of file uavobjectmanager.c.

int32_t UAVObjDeleteById ( uint32_t  obj_id,
uint16_t  inst_id 
)

Delete an object from the file system (SD card).

Parameters
[in]obj_idThe object id
[in]inst_idThe object instance
Returns
0 if success or -1 if failure

Definition at line 880 of file uavobjectmanager.c.

int32_t UAVObjDeleteMetaobjects ( )

Delete all metaobjects from the SD card.

Returns
0 if success or -1 if failure

Definition at line 1045 of file uavobjectmanager.c.

int32_t UAVObjDeleteSettings ( )

Delete all settings objects from the SD card.

Returns
0 if success or -1 if failure

Definition at line 955 of file uavobjectmanager.c.

int32_t UAVObjDisconnectCallback ( UAVObjHandle  obj_handle,
UAVObjEventCallback  cb,
void *  cbCtx 
)

Disconnect an event callback from the object.

Parameters
[in]objThe object handle
[in]cbThe event callback
Returns
0 if success or -1 if failure

Definition at line 1616 of file uavobjectmanager.c.

int32_t UAVObjDisconnectQueue ( UAVObjHandle  obj_handle,
struct pios_queue queue 
)

Disconnect an event queue from the object.

Parameters
[in]objThe object handle
[in]queueThe event queue
Returns
0 if success or -1 if failure

Definition at line 1536 of file uavobjectmanager.c.

UAVObjAccessType UAVObjGetAccess ( const UAVObjMetadata *  metadata)

Get the UAVObject metadata access member

Parameters
[in]metadataThe metadata object
Returns
the access type

Definition at line 1367 of file uavobjectmanager.c.

UAVObjHandle UAVObjGetByID ( uint32_t  id)

Retrieve an object from the list given its id

Parameters
[in]Theobject ID
Returns
The object or NULL if not found.

Definition at line 410 of file uavobjectmanager.c.

int32_t UAVObjGetData ( UAVObjHandle  obj_handle,
void *  dataOut 
)

Get the object data

Parameters
[in]objThe object handle
[out]dataOutThe object's data structure
Returns
0 if success or -1 if failure

Definition at line 1098 of file uavobjectmanager.c.

int32_t UAVObjGetDataField ( UAVObjHandle  obj_handle,
void *  dataOut,
uint32_t  offset,
uint32_t  size 
)

Get the object data

Parameters
[in]objThe object handle
[out]dataOutThe object's data structure
Returns
0 if success or -1 if failure

Definition at line 1109 of file uavobjectmanager.c.

UAVObjAccessType UAVObjGetGcsAccess ( const UAVObjMetadata *  metadata)

Get the UAVObject metadata GCS access member

Parameters
[in]metadataThe metadata object
Returns
the GCS access type

Definition at line 1389 of file uavobjectmanager.c.

uint8_t UAVObjGetGcsTelemetryAcked ( const UAVObjMetadata *  metadata)

Get the UAVObject metadata GCS telemetry acked member

Parameters
[in]metadataThe metadata object
Returns
the telemetry acked boolean

Definition at line 1430 of file uavobjectmanager.c.

UAVObjUpdateMode UAVObjGetGcsTelemetryUpdateMode ( const UAVObjMetadata *  metadata)

Get the UAVObject metadata GCS telemetry update mode

Parameters
[in]metadataThe metadata object
Returns
the GCS telemetry update mode

Definition at line 1470 of file uavobjectmanager.c.

uint32_t UAVObjGetID ( UAVObjHandle  obj_handle)

Get the object's ID

Parameters
[in]objThe object handle
Returns
The object ID

Definition at line 440 of file uavobjectmanager.c.

int32_t UAVObjGetInstanceData ( UAVObjHandle  obj_handle,
uint16_t  instId,
void *  dataOut 
)

Get the data of a specific object instance

Parameters
[in]objThe object handle
[in]instIdThe object instance ID
[out]dataOutThe object's data structure
Returns
0 if success or -1 if failure

Definition at line 1211 of file uavobjectmanager.c.

int32_t UAVObjGetInstanceDataField ( UAVObjHandle  obj_handle,
uint16_t  instId,
void *  dataOut,
uint32_t  offset,
uint32_t  size 
)

Get the data of a specific object instance

Parameters
[in]objThe object handle
[in]instIdThe object instance ID
[out]dataOutThe object's data structure
Returns
0 if success or -1 if failure

Definition at line 1258 of file uavobjectmanager.c.

UAVObjHandle UAVObjGetLinkedObj ( UAVObjHandle  obj_handle)

Get the object this object is linked to. For regular objects, the linked object is the metaobject. For metaobjects the linked object is the parent object. This function is normally only needed by the telemetry module.

Parameters
[in]objThe object handle
Returns
The object linked object handle

Definition at line 493 of file uavobjectmanager.c.

int32_t UAVObjGetMetadata ( UAVObjHandle  obj_handle,
UAVObjMetadata *  dataOut 
)

Get the object metadata

Parameters
[in]objThe object handle
[out]dataOutThe object's metadata structure
Returns
0 if success or -1 if failure

Definition at line 1338 of file uavobjectmanager.c.

uint32_t UAVObjGetNumBytes ( UAVObjHandle  obj)

Get the number of bytes of the object's data (for one instance)

Parameters
[in]objThe object handle
Returns
The number of bytes

Definition at line 465 of file uavobjectmanager.c.

uint16_t UAVObjGetNumInstances ( UAVObjHandle  obj_handle)

Get the number of instances contained in the object.

Parameters
[in]objThe object handle
Returns
The number of instances

Definition at line 518 of file uavobjectmanager.c.

void UAVObjGetStats ( UAVObjStats statsOut)

Get the statistics counters

Parameters
[out]statsOutThe statistics counters will be copied there

Definition at line 251 of file uavobjectmanager.c.

uint8_t UAVObjGetTelemetryAcked ( const UAVObjMetadata *  metadata)

Get the UAVObject metadata telemetry acked member

Parameters
[in]metadataThe metadata object
Returns
the telemetry acked boolean

Definition at line 1410 of file uavobjectmanager.c.

UAVObjUpdateMode UAVObjGetTelemetryUpdateMode ( const UAVObjMetadata *  metadata)

Get the UAVObject metadata telemetry update mode

Parameters
[in]metadataThe metadata object
Returns
the telemetry update mode

Definition at line 1450 of file uavobjectmanager.c.

uint32_t UAVObjIDByIndex ( uint8_t  index)

UAVObjIDByIndex returns the ID of the object with index index

Returns
the ID of the object

Definition at line 2157 of file uavobjectmanager.c.

int32_t UAVObjInitialize ( )

Initialize the object manager

Returns
0 Success
-1 Failure

Definition at line 218 of file uavobjectmanager.c.

static void UAVObjInitMetaData ( struct UAVOMeta obj_meta)
static

Definition at line 272 of file uavobjectmanager.c.

void UAVObjInstanceUpdated ( UAVObjHandle  obj_handle,
uint16_t  instId 
)

Send the object's data to the GCS (triggers a EV_UPDATED_MANUAL event on this object).

Parameters
[in]objThe object handle
[in]instIdThe object instance ID

Definition at line 1641 of file uavobjectmanager.c.

bool UAVObjIsMetaobject ( UAVObjHandle  obj_handle)

Is this a metaobject?

Parameters
[in]objThe object handle
Returns
True (1) if this is metaobject

Definition at line 586 of file uavobjectmanager.c.

bool UAVObjIsSettings ( UAVObjHandle  obj_handle)

Is this a settings object?

Parameters
[in]objThe object handle
Returns
True (1) if this is a settings object

Definition at line 601 of file uavobjectmanager.c.

bool UAVObjIsSingleInstance ( UAVObjHandle  obj_handle)

Does this object contains a single instance or multiple instances?

Parameters
[in]objThe object handle
Returns
True (1) if this is a single instance object

Definition at line 574 of file uavobjectmanager.c.

void UAVObjIterate ( void(*)(UAVObjHandle obj)  iterator)

Iterate through all objects in the list.

Parameters
iteratorThis function will be called once for each object, the object will be passed as a parameter

Definition at line 1655 of file uavobjectmanager.c.

int32_t UAVObjLoad ( UAVObjHandle  obj_handle,
uint16_t  instId 
)

Load an object from the file system (SD card). A file with the name of the object will be opened. The object data can be saved using the UAVObjSave function.

Parameters
[in]objThe object handle.
[in]instIdThe object instance
Returns
0 if success or -1 if failure

Definition at line 823 of file uavobjectmanager.c.

int32_t UAVObjLoadMetaobjects ( )

Load all metaobjects from the SD card.

Returns
0 if success or -1 if failure

Definition at line 1016 of file uavobjectmanager.c.

int32_t UAVObjLoadSettings ( )

Load all settings objects from the SD card.

Returns
0 if success or -1 if failure

Definition at line 923 of file uavobjectmanager.c.

int32_t UAVObjPack ( UAVObjHandle  obj_handle,
uint16_t  instId,
uint8_t *  dataOut 
)

Pack an object to a byte array

Parameters
[in]objThe object handle
[in]instIdThe instance ID
[out]dataOutThe byte array
Returns
0 if success or -1 if failure

Definition at line 682 of file uavobjectmanager.c.

int8_t UAVObjReadOnly ( UAVObjHandle  obj_handle)

Check if an object is read only

Parameters
[in]objThe object handle
Returns
  • 0 if not read only
  • 1 if read only
  • -1 if unable to get meta data

Definition at line 1494 of file uavobjectmanager.c.

UAVObjHandle UAVObjRegister ( uint32_t  id,
int32_t  isSingleInstance,
int32_t  isSettings,
uint32_t  num_bytes,
UAVObjInitializeCallback  initCb 
)

Register and new object in the object manager.

Parameters
[in]idUnique object ID
[in]isSingleInstanceIs this a single instance or multi-instance object
[in]isSettingsIs this a settings object
[in]numBytesNumber of bytes of object data (for one instance)
[in]initCbDefault field and metadata initialization function
Returns
Object handle, or NULL if failure.

Definition at line 349 of file uavobjectmanager.c.

void UAVObjRegisterNewInstanceCB ( new_uavo_instance_cb_t  callback)

Registers a new UAVO instance created callback

Definition at line 2194 of file uavobjectmanager.c.

int32_t UAVObjSave ( UAVObjHandle  obj_handle,
uint16_t  instId 
)

Save the data of the specified object to the file system (SD card). If the object contains multiple instances, all of them will be saved. A new file with the name of the object will be created. The object data can be restored using the UAVObjLoad function.

Parameters
[in]objThe object handle.
[in]instIdThe instance ID
[in]fileFile to append to
Returns
0 if success or -1 if failure

Definition at line 739 of file uavobjectmanager.c.

int32_t UAVObjSaveMetaobjects ( )

Save all metaobjects to the SD card.

Returns
0 if success or -1 if failure

Definition at line 987 of file uavobjectmanager.c.

int32_t UAVObjSaveSettings ( )

Save all settings objects to the SD card.

Returns
0 if success or -1 if failure

Definition at line 891 of file uavobjectmanager.c.

void UAVObjSetAccess ( UAVObjMetadata *  metadata,
UAVObjAccessType  mode 
)

Set the UAVObject metadata access member

Parameters
[in]metadataThe metadata object
[in]modeThe access mode

Definition at line 1378 of file uavobjectmanager.c.

int32_t UAVObjSetData ( UAVObjHandle  obj_handle,
const void *  dataIn 
)

Set the object data

Parameters
[in]objThe object handle
[in]dataInThe object's data structure
Returns
0 if success or -1 if failure

Definition at line 1076 of file uavobjectmanager.c.

int32_t UAVObjSetDataField ( UAVObjHandle  obj_handle,
const void *  dataIn,
uint32_t  offset,
uint32_t  size 
)

Set the object data

Parameters
[in]objThe object handle
[in]dataInThe object's data structure
Returns
0 if success or -1 if failure

Definition at line 1087 of file uavobjectmanager.c.

void UAVObjSetGcsAccess ( UAVObjMetadata *  metadata,
UAVObjAccessType  mode 
)

Set the UAVObject metadata GCS access member

Parameters
[in]metadataThe metadata object
[in]modeThe access mode

Definition at line 1400 of file uavobjectmanager.c.

void UAVObjSetGcsTelemetryAcked ( UAVObjMetadata *  metadata,
uint8_t  val 
)

Set the UAVObject metadata GCS telemetry acked member

Parameters
[in]metadataThe metadata object
[in]valThe GCS telemetry acked boolean

Definition at line 1440 of file uavobjectmanager.c.

void UAVObjSetGcsTelemetryUpdateMode ( UAVObjMetadata *  metadata,
UAVObjUpdateMode  val 
)

Set the UAVObject metadata GCS telemetry update mode member

Parameters
[in]metadataThe metadata object
[in]valThe GCS telemetry update mode

Definition at line 1480 of file uavobjectmanager.c.

int32_t UAVObjSetInstanceData ( UAVObjHandle  obj_handle,
uint16_t  instId,
const void *  dataIn 
)

Set the data of a specific object instance

Parameters
[in]objThe object handle
[in]instIdThe object instance ID
[in]dataInThe object's data structure
Returns
0 if success or -1 if failure

Definition at line 1123 of file uavobjectmanager.c.

int32_t UAVObjSetInstanceDataField ( UAVObjHandle  obj_handle,
uint16_t  instId,
const void *  dataIn,
uint32_t  offset,
uint32_t  size 
)

Set the data of a specific object instance

Parameters
[in]objThe object handle
[in]instIdThe object instance ID
[in]dataInThe object's data structure
Returns
0 if success or -1 if failure

Definition at line 1137 of file uavobjectmanager.c.

int32_t UAVObjSetMetadata ( UAVObjHandle  obj_handle,
const UAVObjMetadata *  dataIn 
)

Set the object metadata

Parameters
[in]objThe object handle
[in]dataInThe object's metadata structure
Returns
0 if success or -1 if failure

Definition at line 1315 of file uavobjectmanager.c.

void UAVObjSetTelemetryAcked ( UAVObjMetadata *  metadata,
uint8_t  val 
)

Set the UAVObject metadata telemetry acked member

Parameters
[in]metadataThe metadata object
[in]valThe telemetry acked boolean

Definition at line 1420 of file uavobjectmanager.c.

void UAVObjSetTelemetryUpdateMode ( UAVObjMetadata *  metadata,
UAVObjUpdateMode  val 
)

Set the UAVObject metadata telemetry update mode member

Parameters
[in]metadataThe metadata object
[in]valThe telemetry update mode

Definition at line 1460 of file uavobjectmanager.c.

void UAVObjUnblockThrottle ( struct ObjectEventEntryThrottled throttled)

Unblocks a throttled event– allows it to be inserted into queues once again.

Definition at line 2184 of file uavobjectmanager.c.

int32_t UAVObjUnpack ( UAVObjHandle  obj_handle,
uint16_t  instId,
const uint8_t *  dataIn 
)

Unpack an object from a byte array

Parameters
[in]objThe object handle
[in]instIdThe instance ID
[in]dataInThe byte array
Returns
0 if success or -1 if failure

Definition at line 618 of file uavobjectmanager.c.

void UAVObjUpdated ( UAVObjHandle  obj_handle)

Send the object's data to the GCS (triggers a EV_UPDATED_MANUAL event on this object).

Parameters
[in]objThe object handle

Definition at line 1631 of file uavobjectmanager.c.

Variable Documentation

void* cb_stack
static

Definition at line 211 of file uavobjectmanager.c.

const UAVObjMetadata defMetadata
static
Initial value:
= {
.telemetryUpdatePeriod = 0,
.gcsTelemetryUpdatePeriod = 0,
.loggingUpdatePeriod = 0,
}
#define UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT
#define UAVOBJ_GCS_ACCESS_SHIFT
#define UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT
#define UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT
#define UAVOBJ_TELEMETRY_ACKED_SHIFT
#define UAVOBJ_ACCESS_SHIFT

Definition at line 194 of file uavobjectmanager.c.

struct ObjectEventEntry* events_unused
static

Definition at line 191 of file uavobjectmanager.c.

struct ObjectEventEntry* events_unused_throttled
static

Definition at line 192 of file uavobjectmanager.c.

struct pios_recursive_mutex* mutex
static

Definition at line 193 of file uavobjectmanager.c.

new_uavo_instance_cb_t newUavObjInstanceCB
static

Definition at line 207 of file uavobjectmanager.c.

uintptr_t pios_uavo_settings_fs_id

Simulation of the flash filesystem

Todo:
something nicer about these

Definition at line 50 of file pios_board.c.

UAVObjStats stats
static

Definition at line 206 of file uavobjectmanager.c.

struct UAVOData* uavo_list
static

Definition at line 190 of file uavobjectmanager.c.