mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-31 16:52:10 +01:00
LP-5 - Use a single Task for telemetry when no radio is available
This commit is contained in:
parent
5e9a034e6e
commit
711ef272c1
@ -95,6 +95,9 @@
|
|||||||
#define STATS_UPDATE_PERIOD_MS 4000
|
#define STATS_UPDATE_PERIOD_MS 4000
|
||||||
#define CONNECTION_TIMEOUT_MS 8000
|
#define CONNECTION_TIMEOUT_MS 8000
|
||||||
|
|
||||||
|
#ifdef PIOS_INCLUDE_RFM22B
|
||||||
|
#define HAS_RADIO
|
||||||
|
#endif
|
||||||
// Private types
|
// Private types
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// Determine port on which to communicate telemetry information
|
// Determine port on which to communicate telemetry information
|
||||||
@ -111,12 +114,14 @@ typedef struct {
|
|||||||
// Telemetry stream
|
// Telemetry stream
|
||||||
UAVTalkConnection uavTalkCon;
|
UAVTalkConnection uavTalkCon;
|
||||||
} channelContext;
|
} channelContext;
|
||||||
|
#ifdef HAS_RADIO
|
||||||
// Main telemetry channel
|
// Main telemetry channel
|
||||||
static channelContext localChannel;
|
static channelContext localChannel;
|
||||||
static int32_t transmitLocalData(uint8_t *data, int32_t length);
|
static int32_t transmitLocalData(uint8_t *data, int32_t length);
|
||||||
static void registerLocalObject(UAVObjHandle obj);
|
static void registerLocalObject(UAVObjHandle obj);
|
||||||
static uint32_t localPort();
|
static uint32_t localPort();
|
||||||
|
static void updateSettings(channelContext *channel);
|
||||||
|
#endif
|
||||||
|
|
||||||
// OPLink telemetry channel
|
// OPLink telemetry channel
|
||||||
static channelContext radioChannel;
|
static channelContext radioChannel;
|
||||||
@ -150,7 +155,6 @@ static int32_t setLoggingPeriod(
|
|||||||
int32_t updatePeriodMs);
|
int32_t updatePeriodMs);
|
||||||
static void updateTelemetryStats();
|
static void updateTelemetryStats();
|
||||||
static void gcsTelemetryStatsUpdated();
|
static void gcsTelemetryStatsUpdated();
|
||||||
static void updateSettings(channelContext *channel);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialise the telemetry module
|
* Initialise the telemetry module
|
||||||
@ -159,6 +163,7 @@ static void updateSettings(channelContext *channel);
|
|||||||
*/
|
*/
|
||||||
int32_t TelemetryStart(void)
|
int32_t TelemetryStart(void)
|
||||||
{
|
{
|
||||||
|
#ifdef HAS_RADIO
|
||||||
// Only start the local telemetry tasks if needed
|
// Only start the local telemetry tasks if needed
|
||||||
if (localPort()) {
|
if (localPort()) {
|
||||||
UAVObjIterate(®isterLocalObject);
|
UAVObjIterate(®isterLocalObject);
|
||||||
@ -187,8 +192,8 @@ int32_t TelemetryStart(void)
|
|||||||
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYRX,
|
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYRX,
|
||||||
localChannel.rxTaskHandle);
|
localChannel.rxTaskHandle);
|
||||||
}
|
}
|
||||||
|
#endif /* ifdef HAS_RADIO */
|
||||||
// Start the telemetry tasks associated with Radio/USB
|
// Start the telemetry tasks associated with Radio/USB
|
||||||
UAVObjIterate(®isterRadioObject);
|
UAVObjIterate(®isterRadioObject);
|
||||||
|
|
||||||
// Listen to objects of interest
|
// Listen to objects of interest
|
||||||
@ -229,9 +234,6 @@ void TelemetryInitializeChannel(channelContext *channel)
|
|||||||
sizeof(UAVObjEvent));
|
sizeof(UAVObjEvent));
|
||||||
#endif /* PIOS_TELEM_PRIORITY_QUEUE */
|
#endif /* PIOS_TELEM_PRIORITY_QUEUE */
|
||||||
|
|
||||||
// Initialise UAVTalk
|
|
||||||
channel->uavTalkCon = UAVTalkInitialize(&transmitLocalData);
|
|
||||||
|
|
||||||
// Create periodic event that will be used to update the telemetry stats
|
// Create periodic event that will be used to update the telemetry stats
|
||||||
UAVObjEvent ev;
|
UAVObjEvent ev;
|
||||||
memset(&ev, 0, sizeof(UAVObjEvent));
|
memset(&ev, 0, sizeof(UAVObjEvent));
|
||||||
@ -267,7 +269,7 @@ int32_t TelemetryInitialize(void)
|
|||||||
radio_port = PIOS_COM_RF;
|
radio_port = PIOS_COM_RF;
|
||||||
}
|
}
|
||||||
#else /* PIOS_INCLUDE_RFM22B */
|
#else /* PIOS_INCLUDE_RFM22B */
|
||||||
radio_port = 0;
|
radio_port = PIOS_COM_TELEM_RF;
|
||||||
#endif /* PIOS_INCLUDE_RFM22B */
|
#endif /* PIOS_INCLUDE_RFM22B */
|
||||||
|
|
||||||
FlightTelemetryStatsInitialize();
|
FlightTelemetryStatsInitialize();
|
||||||
@ -279,10 +281,9 @@ int32_t TelemetryInitialize(void)
|
|||||||
// Reset link stats
|
// Reset link stats
|
||||||
txErrors = 0;
|
txErrors = 0;
|
||||||
txRetries = 0;
|
txRetries = 0;
|
||||||
|
#ifdef HAS_RADIO
|
||||||
// Set channel port handlers
|
// Set channel port handlers
|
||||||
localChannel.getPort = localPort;
|
localChannel.getPort = localPort;
|
||||||
radioChannel.getPort = radioPort;
|
|
||||||
|
|
||||||
// Set the local telemetry baud rate
|
// Set the local telemetry baud rate
|
||||||
updateSettings(&localChannel);
|
updateSettings(&localChannel);
|
||||||
@ -295,6 +296,9 @@ int32_t TelemetryInitialize(void)
|
|||||||
localChannel.uavTalkCon = UAVTalkInitialize(&transmitLocalData);
|
localChannel.uavTalkCon = UAVTalkInitialize(&transmitLocalData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
// Set channel port handlers
|
||||||
|
radioChannel.getPort = radioPort;
|
||||||
// Initialise channel
|
// Initialise channel
|
||||||
TelemetryInitializeChannel(&radioChannel);
|
TelemetryInitializeChannel(&radioChannel);
|
||||||
// Initialise UAVTalk
|
// Initialise UAVTalk
|
||||||
@ -304,7 +308,7 @@ int32_t TelemetryInitialize(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MODULE_INITCALL(TelemetryInitialize, TelemetryStart);
|
MODULE_INITCALL(TelemetryInitialize, TelemetryStart);
|
||||||
|
#ifdef HAS_RADIO
|
||||||
/**
|
/**
|
||||||
* Register a new object, adds object to local list and connects the queue depending on the object's
|
* Register a new object, adds object to local list and connects the queue depending on the object's
|
||||||
* telemetry settings.
|
* telemetry settings.
|
||||||
@ -327,7 +331,7 @@ static void registerLocalObject(UAVObjHandle obj)
|
|||||||
EV_NONE);
|
EV_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
static void registerRadioObject(UAVObjHandle obj)
|
static void registerRadioObject(UAVObjHandle obj)
|
||||||
{
|
{
|
||||||
if (UAVObjIsMetaobject(obj)) {
|
if (UAVObjIsMetaobject(obj)) {
|
||||||
@ -635,7 +639,7 @@ static void telemetryRxTask(void *parameters)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_RADIO
|
||||||
/**
|
/**
|
||||||
* Determine the port to be used for communication on the telemetry channel
|
* Determine the port to be used for communication on the telemetry channel
|
||||||
* \return com port number
|
* \return com port number
|
||||||
@ -644,7 +648,7 @@ static uint32_t localPort()
|
|||||||
{
|
{
|
||||||
return PIOS_COM_TELEM_RF;
|
return PIOS_COM_TELEM_RF;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the port to be used for communication on the radio channel
|
* Determine the port to be used for communication on the radio channel
|
||||||
@ -664,7 +668,7 @@ static uint32_t radioPort()
|
|||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_RADIO
|
||||||
/**
|
/**
|
||||||
* Transmit data buffer to the modem or USB port.
|
* Transmit data buffer to the modem or USB port.
|
||||||
* \param[in] data Data buffer to send
|
* \param[in] data Data buffer to send
|
||||||
@ -682,7 +686,7 @@ static int32_t transmitLocalData(uint8_t *data, int32_t length)
|
|||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transmit data buffer to the radioport.
|
* Transmit data buffer to the radioport.
|
||||||
@ -804,9 +808,10 @@ static void updateTelemetryStats()
|
|||||||
uint32_t timeNow;
|
uint32_t timeNow;
|
||||||
|
|
||||||
// Get stats
|
// Get stats
|
||||||
UAVTalkGetStats(localChannel.uavTalkCon, &utalkStats, true);
|
UAVTalkGetStats(radioChannel.uavTalkCon, &utalkStats, true);
|
||||||
UAVTalkAddStats(radioChannel.uavTalkCon, &utalkStats, true);
|
#ifdef HAS_RADIO
|
||||||
|
UAVTalkAddStats(localChannel.uavTalkCon, &utalkStats, true);
|
||||||
|
#endif
|
||||||
// Get object data
|
// Get object data
|
||||||
FlightTelemetryStatsGet(&flightStats);
|
FlightTelemetryStatsGet(&flightStats);
|
||||||
GCSTelemetryStatsGet(&gcsStats);
|
GCSTelemetryStatsGet(&gcsStats);
|
||||||
@ -888,6 +893,7 @@ static void updateTelemetryStats()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_RADIO
|
||||||
/**
|
/**
|
||||||
* Update the telemetry settings, called on startup.
|
* Update the telemetry settings, called on startup.
|
||||||
* FIXME: This should be in the TelemetrySettings object. But objects
|
* FIXME: This should be in the TelemetrySettings object. But objects
|
||||||
@ -931,7 +937,7 @@ static void updateSettings(channelContext *channel)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* ifdef HAS_RADIO */
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
* @}
|
* @}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user