@@ -57,7 +57,7 @@ extern uintptr_t pios_uavo_settings_fs_id;
5757 */
5858
5959/** opaque type for instances **/
60- typedef void * InstanceHandle ;
60+ typedef void * InstanceHandle ;
6161
6262struct ObjectEventEntry {
6363 union {
@@ -76,6 +76,7 @@ struct ObjectEventEntryThrottled {
7676
7777 uint32_t due ;
7878 uint16_t interval ;
79+ volatile uint8_t inhibited ;
7980};
8081
8182/*
@@ -130,7 +131,7 @@ struct UAVOSingle {
130131 struct UAVOData uavo ;
131132
132133 uint8_t instance0 [];
133- /*
134+ /*
134135 * Additional space will be malloc'd here to hold the
135136 * the data for this instance.
136137 */
@@ -140,7 +141,7 @@ struct UAVOSingle {
140141struct UAVOMultiInst {
141142 struct UAVOMultiInst * next ;
142143 uint8_t instance [];
143- /*
144+ /*
144145 * Additional space will be malloc'd here to hold the
145146 * the data for this instance.
146147 */
@@ -345,7 +346,7 @@ static struct UAVOData * UAVObjAllocMulti(uint32_t num_bytes)
345346 * \return Object handle, or NULL if failure.
346347 * \return
347348 */
348- UAVObjHandle UAVObjRegister (uint32_t id ,
349+ UAVObjHandle UAVObjRegister (uint32_t id ,
349350 int32_t isSingleInstance , int32_t isSettings ,
350351 uint32_t num_bytes ,
351352 UAVObjInitializeCallback initCb )
@@ -1293,7 +1294,7 @@ int32_t UAVObjGetInstanceDataField(UAVObjHandle obj_handle, uint16_t instId, voi
12931294 if ((size + offset ) > obj -> instance_size ) {
12941295 goto unlock_exit ;
12951296 }
1296-
1297+
12971298 // Set data
12981299 memcpy (dataOut , InstanceData (instEntry ) + offset , size );
12991300 }
@@ -1485,8 +1486,8 @@ void UAVObjSetGcsTelemetryUpdateMode(UAVObjMetadata* metadata, UAVObjUpdateMode
14851486/**
14861487 * Check if an object is read only
14871488 * \param[in] obj The object handle
1488- * \return
1489- * \arg 0 if not read only
1489+ * \return
1490+ * \arg 0 if not read only
14901491 * \arg 1 if read only
14911492 * \arg -1 if unable to get meta data
14921493 */
@@ -1724,31 +1725,48 @@ static int32_t pumpOneEvent(UAVObjEvent msg, void *obj_data, int len) {
17241725 struct ObjectEventEntry * event ;
17251726 LL_FOREACH (msg .obj -> next_event , event ) {
17261727 if (event -> eventMask == 0
1727- || (event -> eventMask & msg .event ) != 0 ) {
1728+ || (event -> eventMask & msg .event ) != 0 ) {
1729+ struct ObjectEventEntryThrottled * throtInfo =
1730+ (struct ObjectEventEntryThrottled * ) event ;
1731+
17281732 if (event -> hasThrottle ) {
17291733 // This is a throttled event (triggered with a spacing of at least "interval" ms)
17301734 struct ObjectEventEntryThrottled * throtInfo =
17311735 (struct ObjectEventEntryThrottled * ) event ;
17321736
17331737 uint32_t now = PIOS_Thread_Systime ();
1734- if (throtInfo -> due > now ){
1738+ if (throtInfo -> due > now ) {
17351739 continue ;
17361740 }
17371741
17381742 // Set time for next callback
17391743 throtInfo -> due += ((now - throtInfo -> due ) / throtInfo -> interval + 1 ) * throtInfo -> interval ;
1744+
1745+ if (throtInfo -> inhibited ) {
1746+ continue ;
1747+ }
1748+
1749+ msg .throttle = throtInfo ;
1750+ } else {
1751+ msg .throttle = NULL ;
17401752 }
17411753
17421754 // Invoke callback (from event task) if a valid one is registered
17431755 if (event -> cb ) {
17441756 // invoke callback directly; callbacks must be well behaved
17451757 invokeCallback (event , & msg , obj_data , len );
17461758 } else if (event -> cbInfo .queue ) {
1759+ if (event -> hasThrottle ) {
1760+ throtInfo -> inhibited = 1 ;
1761+ }
17471762 // Send to queue if a valid queue is registered
17481763 // will not block
17491764 if (PIOS_Queue_Send (event -> cbInfo .queue , & msg , 0 ) != true) {
17501765 stats .lastQueueErrorID = UAVObjGetID (msg .obj );
17511766 ++ stats .eventQueueErrors ;
1767+ if (event -> hasThrottle ) {
1768+ throtInfo -> inhibited = 0 ;
1769+ }
17521770 }
17531771 }
17541772
@@ -2154,6 +2172,17 @@ uint32_t UAVObjIDByIndex(uint8_t index)
21542172 return 0 ;
21552173}
21562174
2175+ /**
2176+ * Unblocks a throttled event-- allows it to be inserted into queues once
2177+ * again.
2178+ */
2179+ void UAVObjUnblockThrottle (struct ObjectEventEntryThrottled * throttled )
2180+ {
2181+ if (throttled ) {
2182+ throttled -> inhibited = 0 ;
2183+ }
2184+ }
2185+
21572186/**
21582187 * Registers a new UAVO instance created callback
21592188 */
0 commit comments