1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-11 19:24:10 +01:00

OP-1289 Merge OP-1803 Only create local telemetry queues/tasks if needed

This commit is contained in:
Steve Evans 2015-04-11 10:10:04 +01:00
parent 73aeb5d653
commit 7c7b19ff2d

View File

@ -157,18 +157,16 @@ static void updateSettings(channelContext *channel);
*/ */
int32_t TelemetryStart(void) int32_t TelemetryStart(void)
{ {
// Only start the local telemetry tasks if needed
if (localPort()) {
UAVObjIterate(&registerLocalObject); UAVObjIterate(&registerLocalObject);
UAVObjIterate(&registerRadioObject);
// Listen to objects of interest // Listen to objects of interest
#ifdef PIOS_TELEM_PRIORITY_QUEUE #ifdef PIOS_TELEM_PRIORITY_QUEUE
GCSTelemetryStatsConnectQueue(localChannel.priorityQueue); GCSTelemetryStatsConnectQueue(localChannel.priorityQueue);
GCSTelemetryStatsConnectQueue(radioChannel.priorityQueue);
#else /* PIOS_TELEM_PRIORITY_QUEUE */ #else /* PIOS_TELEM_PRIORITY_QUEUE */
GCSTelemetryStatsConnectQueue(localChannel.queue); GCSTelemetryStatsConnectQueue(localChannel.queue);
GCSTelemetryStatsConnectQueue(radioChannel.queue);
#endif /* PIOS_TELEM_PRIORITY_QUEUE */ #endif /* PIOS_TELEM_PRIORITY_QUEUE */
// Start telemetry tasks // Start telemetry tasks
xTaskCreate(telemetryTxTask, xTaskCreate(telemetryTxTask,
"TelTx", "TelTx",
@ -186,6 +184,17 @@ int32_t TelemetryStart(void)
&localChannel.rxTaskHandle); &localChannel.rxTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYRX, PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYRX,
localChannel.rxTaskHandle); localChannel.rxTaskHandle);
}
// Start the telemetry tasks associated with Radio/USB
UAVObjIterate(&registerRadioObject);
// Listen to objects of interest
#ifdef PIOS_TELEM_PRIORITY_QUEUE
GCSTelemetryStatsConnectQueue(radioChannel.priorityQueue);
#else /* PIOS_TELEM_PRIORITY_QUEUE */
GCSTelemetryStatsConnectQueue(radioChannel.queue);
#endif /* PIOS_TELEM_PRIORITY_QUEUE */
xTaskCreate(telemetryTxTask, xTaskCreate(telemetryTxTask,
"RadioTx", "RadioTx",
@ -207,6 +216,35 @@ int32_t TelemetryStart(void)
return 0; return 0;
} }
/* Intialise a telemetry channel */
void TelemetryInitializeChannel(channelContext *channel)
{
// Create object queues
channel->queue = xQueueCreate(MAX_QUEUE_SIZE,
sizeof(UAVObjEvent));
#if defined(PIOS_TELEM_PRIORITY_QUEUE)
channel->priorityQueue = xQueueCreate(MAX_QUEUE_SIZE,
sizeof(UAVObjEvent));
#endif /* PIOS_TELEM_PRIORITY_QUEUE */
// Initialise UAVTalk
channel->uavTalkCon = UAVTalkInitialize(&transmitLocalData);
// Create periodic event that will be used to update the telemetry stats
UAVObjEvent ev;
memset(&ev, 0, sizeof(UAVObjEvent));
#ifdef PIOS_TELEM_PRIORITY_QUEUE
EventPeriodicQueueCreate(&ev,
channel->priorityQueue,
STATS_UPDATE_PERIOD_MS);
#else /* PIOS_TELEM_PRIORITY_QUEUE */
EventPeriodicQueueCreate(&ev,
channel->queue,
STATS_UPDATE_PERIOD_MS);
#endif /* PIOS_TELEM_PRIORITY_QUEUE */
}
/** /**
* Initialise the telemetry module * Initialise the telemetry module
* \return -1 if initialisation failed * \return -1 if initialisation failed
@ -214,58 +252,38 @@ int32_t TelemetryStart(void)
*/ */
int32_t TelemetryInitialize(void) int32_t TelemetryInitialize(void)
{ {
HwSettingsInitialize();
FlightTelemetryStatsInitialize(); FlightTelemetryStatsInitialize();
GCSTelemetryStatsInitialize(); GCSTelemetryStatsInitialize();
// Initialize vars // Initialize vars
timeOfLastObjectUpdate = 0; timeOfLastObjectUpdate = 0;
// Create object queues // Reset link stats
localChannel.queue = xQueueCreate(MAX_QUEUE_SIZE, txErrors = 0;
sizeof(UAVObjEvent)); txRetries = 0;
radioChannel.queue = xQueueCreate(MAX_QUEUE_SIZE,
sizeof(UAVObjEvent));
#if defined(PIOS_TELEM_PRIORITY_QUEUE)
localChannel.priorityQueue = xQueueCreate(MAX_QUEUE_SIZE,
sizeof(UAVObjEvent));
radioChannel.priorityQueue = xQueueCreate(MAX_QUEUE_SIZE,
sizeof(UAVObjEvent));
#endif /* PIOS_TELEM_PRIORITY_QUEUE */
// Set channel port handlers // Set channel port handlers
localChannel.getPort = localPort; localChannel.getPort = localPort;
radioChannel.getPort = radioPort; radioChannel.getPort = radioPort;
HwSettingsInitialize(); // Set the local telemetry baud rate
updateSettings(&localChannel); updateSettings(&localChannel);
// Only initialise local channel if telemetry port enabled
if (localPort()) {
// Initialise channel
TelemetryInitializeChannel(&localChannel);
// Initialise UAVTalk // Initialise UAVTalk
localChannel.uavTalkCon = UAVTalkInitialize(&transmitLocalData); localChannel.uavTalkCon = UAVTalkInitialize(&transmitLocalData);
}
// Initialise channel
TelemetryInitializeChannel(&radioChannel);
// Initialise UAVTalk
radioChannel.uavTalkCon = UAVTalkInitialize(&transmitRadioData); radioChannel.uavTalkCon = UAVTalkInitialize(&transmitRadioData);
// Create periodic event that will be used to update the telemetry stats
// FIXME STATS_UPDATE_PERIOD_MS is 4000ms while FlighTelemetryStats update period is 5000ms...
txErrors = 0;
txRetries = 0;
UAVObjEvent ev;
memset(&ev, 0, sizeof(UAVObjEvent));
#ifdef PIOS_TELEM_PRIORITY_QUEUE
EventPeriodicQueueCreate(&ev,
localChannel.priorityQueue,
STATS_UPDATE_PERIOD_MS);
EventPeriodicQueueCreate(&ev,
radioChannel.priorityQueue,
STATS_UPDATE_PERIOD_MS);
#else /* PIOS_TELEM_PRIORITY_QUEUE */
EventPeriodicQueueCreate(&ev,
localChannel.queue,
STATS_UPDATE_PERIOD_MS);
EventPeriodicQueueCreate(&ev,
radioChannel.queue,
STATS_UPDATE_PERIOD_MS);
#endif /* PIOS_TELEM_PRIORITY_QUEUE */
return 0; return 0;
} }