1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

OP-1212 Add "priority" attribute to uavojects that grant them higher priority when sent with telemetry

This commit is contained in:
Alessio Morale 2014-02-04 21:03:42 +01:00
parent 01822d7a0c
commit 13f1f3f23a
8 changed files with 46 additions and 12 deletions

View File

@ -268,12 +268,11 @@ static void updateObject(UAVObjHandle obj, int32_t eventType)
eventMask |= EV_LOGGING_MANUAL; eventMask |= EV_LOGGING_MANUAL;
break; break;
} }
if(UAVObjIsSettings(obj)){ if (UAVObjIsPriority(obj)) {
UAVObjConnectQueue(obj, priorityQueue, eventMask); UAVObjConnectQueue(obj, priorityQueue, eventMask);
} else { } else {
UAVObjConnectQueue(obj, queue, eventMask); UAVObjConnectQueue(obj, queue, eventMask);
} }
} }
/** /**
@ -376,10 +375,10 @@ static void telemetryTxTask(__attribute__((unused)) void *parameters)
*/ */
#if defined(PIOS_TELEM_PRIORITY_QUEUE) #if defined(PIOS_TELEM_PRIORITY_QUEUE)
// Loop forever // Loop forever
while (xQueueReceive(priorityQueue, &ev, 1) == pdTRUE) { while (xQueueReceive(priorityQueue, &ev, 1) == pdTRUE) {
// Process event // Process event
processObjEvent(&ev); processObjEvent(&ev);
} }
#endif #endif
// Wait for queue message // Wait for queue message
if (xQueueReceive(queue, &ev, 1) == pdTRUE) { if (xQueueReceive(queue, &ev, 1) == pdTRUE) {

View File

@ -44,6 +44,7 @@
#define $(NAMEUC)_OBJID $(OBJIDHEX) #define $(NAMEUC)_OBJID $(OBJIDHEX)
#define $(NAMEUC)_ISSINGLEINST $(ISSINGLEINST) #define $(NAMEUC)_ISSINGLEINST $(ISSINGLEINST)
#define $(NAMEUC)_ISSETTINGS $(ISSETTINGS) #define $(NAMEUC)_ISSETTINGS $(ISSETTINGS)
#define $(NAMEUC)_ISPRIORITY $(ISPRIORITY)
#define $(NAMEUC)_NUMBYTES sizeof($(NAME)Data) #define $(NAMEUC)_NUMBYTES sizeof($(NAME)Data)
/* Generic interface functions */ /* Generic interface functions */

View File

@ -147,8 +147,7 @@ typedef struct {
int32_t UAVObjInitialize(); int32_t UAVObjInitialize();
void UAVObjGetStats(UAVObjStats *statsOut); void UAVObjGetStats(UAVObjStats *statsOut);
void UAVObjClearStats(); void UAVObjClearStats();
UAVObjHandle UAVObjRegister(uint32_t id, UAVObjHandle UAVObjRegister(uint32_t id, bool isSingleInstance, bool isSettings, bool isPriority, uint32_t num_bytes, UAVObjInitializeCallback initCb);
int32_t isSingleInstance, int32_t isSettings, uint32_t numBytes, UAVObjInitializeCallback initCb);
UAVObjHandle UAVObjGetByID(uint32_t id); UAVObjHandle UAVObjGetByID(uint32_t id);
uint32_t UAVObjGetID(UAVObjHandle obj); uint32_t UAVObjGetID(UAVObjHandle obj);
uint32_t UAVObjGetNumBytes(UAVObjHandle obj); uint32_t UAVObjGetNumBytes(UAVObjHandle obj);
@ -158,6 +157,7 @@ uint16_t UAVObjCreateInstance(UAVObjHandle obj_handle, UAVObjInitializeCallback
bool UAVObjIsSingleInstance(UAVObjHandle obj); bool UAVObjIsSingleInstance(UAVObjHandle obj);
bool UAVObjIsMetaobject(UAVObjHandle obj); bool UAVObjIsMetaobject(UAVObjHandle obj);
bool UAVObjIsSettings(UAVObjHandle obj); bool UAVObjIsSettings(UAVObjHandle obj);
bool UAVObjIsPriority(UAVObjHandle obj);
int32_t UAVObjUnpack(UAVObjHandle obj_handle, uint16_t instId, const uint8_t *dataIn); 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 UAVObjPack(UAVObjHandle obj_handle, uint16_t instId, uint8_t *dataOut);
uint8_t UAVObjUpdateCRC(UAVObjHandle obj_handle, uint16_t instId, uint8_t crc); uint8_t UAVObjUpdateCRC(UAVObjHandle obj_handle, uint16_t instId, uint8_t crc);

View File

@ -65,7 +65,7 @@ int32_t $(NAME)Initialize(void)
// Register object with the object manager // Register object with the object manager
handle = UAVObjRegister($(NAMEUC)_OBJID, handle = UAVObjRegister($(NAMEUC)_OBJID,
$(NAMEUC)_ISSINGLEINST, $(NAMEUC)_ISSETTINGS, $(NAMEUC)_NUMBYTES, &$(NAME)SetDefaults); $(NAMEUC)_ISSINGLEINST, $(NAMEUC)_ISSETTINGS, $(NAMEUC)_ISPRIORITY, $(NAMEUC)_NUMBYTES, &$(NAME)SetDefaults);
// Done // Done
return handle ? 0 : -1; return handle ? 0 : -1;

View File

@ -108,6 +108,7 @@ struct UAVOBase {
bool isMeta : 1; bool isMeta : 1;
bool isSingle : 1; bool isSingle : 1;
bool isSettings : 1; bool isSettings : 1;
bool isPriority : 1;
} flags; } flags;
} __attribute__((packed)); } __attribute__((packed));
@ -339,7 +340,7 @@ static struct UAVOData *UAVObjAllocMulti(uint32_t num_bytes)
* \return * \return
*/ */
UAVObjHandle UAVObjRegister(uint32_t id, UAVObjHandle UAVObjRegister(uint32_t id,
int32_t isSingleInstance, int32_t isSettings, bool isSingleInstance, bool isSettings, bool isPriority,
uint32_t num_bytes, uint32_t num_bytes,
UAVObjInitializeCallback initCb) UAVObjInitializeCallback initCb)
{ {
@ -368,8 +369,11 @@ UAVObjHandle UAVObjRegister(uint32_t id,
uavo_data->instance_size = num_bytes; uavo_data->instance_size = num_bytes;
if (isSettings) { if (isSettings) {
uavo_data->base.flags.isSettings = true; uavo_data->base.flags.isSettings = true;
// settings defaults to being sent with priority
uavo_data->base.flags.isPriority = true;
} else {
uavo_data->base.flags.isPriority = isPriority;
} }
/* Initialize the embedded meta UAVO */ /* Initialize the embedded meta UAVO */
UAVObjInitMetaData(&uavo_data->metaObj); UAVObjInitMetaData(&uavo_data->metaObj);
@ -605,6 +609,22 @@ bool UAVObjIsSettings(UAVObjHandle obj_handle)
return uavo_base->flags.isSettings; 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 * Unpack an object from a byte array
* \param[in] obj The object handle * \param[in] obj The object handle

View File

@ -72,6 +72,9 @@ void replaceCommonTags(QString & out, ObjectInfo *info)
// Replace $(ISSETTINGS) tag // Replace $(ISSETTINGS) tag
out.replace(QString("$(ISSETTINGS)"), boolTo01String(info->isSettings)); out.replace(QString("$(ISSETTINGS)"), boolTo01String(info->isSettings));
out.replace(QString("$(ISSETTINGSTF)"), boolToTRUEFALSEString(info->isSettings)); out.replace(QString("$(ISSETTINGSTF)"), boolToTRUEFALSEString(info->isSettings));
// Replace $(ISPRIORITY) tag
out.replace(QString("$(ISPRIORITY)"), boolTo01String(info->isPriority));
out.replace(QString("$(ISPRIORITYTF)"), boolToTRUEFALSEString(info->isPriority));
// Replace $(GCSACCESS) tag // Replace $(GCSACCESS) tag
value = accessModeStr[info->gcsAccess]; value = accessModeStr[info->gcsAccess];
out.replace(QString("$(GCSACCESS)"), value); out.replace(QString("$(GCSACCESS)"), value);

View File

@ -623,9 +623,19 @@ QString UAVObjectParser::processObjectAttributes(QDomNode & node, ObjectInfo *in
} else if (attr.nodeValue().compare(QString("false")) == 0) { } else if (attr.nodeValue().compare(QString("false")) == 0) {
info->isSettings = false; info->isSettings = false;
} else { } else {
return QString("Object:settings attribute value is invalid"); return QString("Object:settings attribute value is invalid (true|false)");
} }
// Get priority attribute
attr = attributes.namedItem("priority");
info->isPriority = false;
if (!attr.isNull()) {
if (attr.nodeValue().compare(QString("true")) == 0) {
info->isPriority = true;
} else if (attr.nodeValue().compare(QString("false")) != 0) {
return QString("Object:priority attribute value is invalid (true|false)");
}
}
// Settings objects can only have a single instance // Settings objects can only have a single instance
if (info->isSettings && !info->isSingleInst) { if (info->isSettings && !info->isSingleInst) {

View File

@ -84,6 +84,7 @@ typedef struct {
quint32 id; quint32 id;
bool isSingleInst; bool isSingleInst;
bool isSettings; bool isSettings;
bool isPriority;
AccessMode gcsAccess; AccessMode gcsAccess;
AccessMode flightAccess; AccessMode flightAccess;
bool flightTelemetryAcked; bool flightTelemetryAcked;