mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-19 04:52:12 +01:00
Merged in f5soh/librepilot/LP-182_Telemetry_issue (pull request #122)
LP-182 Set telemetry port baudrate settings or still to default 57600.
This commit is contained in:
commit
e966d1af54
@ -100,30 +100,35 @@
|
|||||||
#ifdef PIOS_INCLUDE_RFM22B
|
#ifdef PIOS_INCLUDE_RFM22B
|
||||||
#define HAS_RADIO
|
#define HAS_RADIO
|
||||||
#endif
|
#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
|
||||||
uint32_t (*getPort)();
|
uint32_t (*getPort)();
|
||||||
// Main telemetry queue
|
// Main telemetry queue
|
||||||
xQueueHandle queue;
|
xQueueHandle queue;
|
||||||
|
|
||||||
#ifdef PIOS_TELEM_PRIORITY_QUEUE
|
#ifdef PIOS_TELEM_PRIORITY_QUEUE
|
||||||
// Priority telemetry queue
|
// Priority telemetry queue
|
||||||
xQueueHandle priorityQueue;
|
xQueueHandle priorityQueue;
|
||||||
#endif /* PIOS_TELEM_PRIORITY_QUEUE */
|
#endif /* PIOS_TELEM_PRIORITY_QUEUE */
|
||||||
|
|
||||||
// Transmit/receive task handles
|
// Transmit/receive task handles
|
||||||
xTaskHandle txTaskHandle;
|
xTaskHandle txTaskHandle;
|
||||||
xTaskHandle rxTaskHandle;
|
xTaskHandle rxTaskHandle;
|
||||||
// Telemetry stream
|
// Telemetry stream
|
||||||
UAVTalkConnection uavTalkCon;
|
UAVTalkConnection uavTalkCon;
|
||||||
} channelContext;
|
} channelContext;
|
||||||
|
|
||||||
#ifdef HAS_RADIO
|
#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();
|
||||||
|
#endif /* ifdef HAS_RADIO */
|
||||||
|
|
||||||
static void updateSettings(channelContext *channel);
|
static void updateSettings(channelContext *channel);
|
||||||
#endif
|
|
||||||
|
|
||||||
// OPLink telemetry channel
|
// OPLink telemetry channel
|
||||||
static channelContext radioChannel;
|
static channelContext radioChannel;
|
||||||
@ -165,6 +170,7 @@ static void gcsTelemetryStatsUpdated();
|
|||||||
*/
|
*/
|
||||||
int32_t TelemetryStart(void)
|
int32_t TelemetryStart(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef HAS_RADIO
|
#ifdef HAS_RADIO
|
||||||
// Only start the local telemetry tasks if needed
|
// Only start the local telemetry tasks if needed
|
||||||
if (localPort()) {
|
if (localPort()) {
|
||||||
@ -195,6 +201,7 @@ int32_t TelemetryStart(void)
|
|||||||
localChannel.rxTaskHandle);
|
localChannel.rxTaskHandle);
|
||||||
}
|
}
|
||||||
#endif /* ifdef HAS_RADIO */
|
#endif /* ifdef HAS_RADIO */
|
||||||
|
|
||||||
// Start the telemetry tasks associated with Radio/USB
|
// Start the telemetry tasks associated with Radio/USB
|
||||||
UAVObjIterate(®isterRadioObject);
|
UAVObjIterate(®isterRadioObject);
|
||||||
|
|
||||||
@ -231,6 +238,7 @@ void TelemetryInitializeChannel(channelContext *channel)
|
|||||||
// Create object queues
|
// Create object queues
|
||||||
channel->queue = xQueueCreate(MAX_QUEUE_SIZE,
|
channel->queue = xQueueCreate(MAX_QUEUE_SIZE,
|
||||||
sizeof(UAVObjEvent));
|
sizeof(UAVObjEvent));
|
||||||
|
|
||||||
#if defined(PIOS_TELEM_PRIORITY_QUEUE)
|
#if defined(PIOS_TELEM_PRIORITY_QUEUE)
|
||||||
channel->priorityQueue = xQueueCreate(MAX_QUEUE_SIZE,
|
channel->priorityQueue = xQueueCreate(MAX_QUEUE_SIZE,
|
||||||
sizeof(UAVObjEvent));
|
sizeof(UAVObjEvent));
|
||||||
@ -283,6 +291,7 @@ int32_t TelemetryInitialize(void)
|
|||||||
// Reset link stats
|
// Reset link stats
|
||||||
txErrors = 0;
|
txErrors = 0;
|
||||||
txRetries = 0;
|
txRetries = 0;
|
||||||
|
|
||||||
#ifdef HAS_RADIO
|
#ifdef HAS_RADIO
|
||||||
// Set channel port handlers
|
// Set channel port handlers
|
||||||
localChannel.getPort = localPort;
|
localChannel.getPort = localPort;
|
||||||
@ -297,10 +306,14 @@ int32_t TelemetryInitialize(void)
|
|||||||
// Initialise UAVTalk
|
// Initialise UAVTalk
|
||||||
localChannel.uavTalkCon = UAVTalkInitialize(&transmitLocalData);
|
localChannel.uavTalkCon = UAVTalkInitialize(&transmitLocalData);
|
||||||
}
|
}
|
||||||
|
#endif /* ifdef HAS_RADIO */
|
||||||
|
|
||||||
#endif
|
|
||||||
// Set channel port handlers
|
// Set channel port handlers
|
||||||
radioChannel.getPort = radioPort;
|
radioChannel.getPort = radioPort;
|
||||||
|
|
||||||
|
// Set the channel port baud rate
|
||||||
|
updateSettings(&radioChannel);
|
||||||
|
|
||||||
// Initialise channel
|
// Initialise channel
|
||||||
TelemetryInitializeChannel(&radioChannel);
|
TelemetryInitializeChannel(&radioChannel);
|
||||||
// Initialise UAVTalk
|
// Initialise UAVTalk
|
||||||
@ -310,6 +323,7 @@ int32_t TelemetryInitialize(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MODULE_INITCALL(TelemetryInitialize, TelemetryStart);
|
MODULE_INITCALL(TelemetryInitialize, TelemetryStart);
|
||||||
|
|
||||||
#ifdef HAS_RADIO
|
#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
|
||||||
@ -333,7 +347,8 @@ static void registerLocalObject(UAVObjHandle obj)
|
|||||||
EV_NONE);
|
EV_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* ifdef HAS_RADIO */
|
||||||
|
|
||||||
static void registerRadioObject(UAVObjHandle obj)
|
static void registerRadioObject(UAVObjHandle obj)
|
||||||
{
|
{
|
||||||
if (UAVObjIsMetaobject(obj)) {
|
if (UAVObjIsMetaobject(obj)) {
|
||||||
@ -459,6 +474,7 @@ static void updateObject(
|
|||||||
UAVObjConnectQueue(obj, channel->priorityQueue, eventMask);
|
UAVObjConnectQueue(obj, channel->priorityQueue, eventMask);
|
||||||
} else
|
} else
|
||||||
#endif /* PIOS_TELEM_PRIORITY_QUEUE */
|
#endif /* PIOS_TELEM_PRIORITY_QUEUE */
|
||||||
|
|
||||||
UAVObjConnectQueue(obj, channel->queue, eventMask);
|
UAVObjConnectQueue(obj, channel->queue, eventMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -584,6 +600,7 @@ static void telemetryTxTask(void *parameters)
|
|||||||
/**
|
/**
|
||||||
* Tries to empty the high priority queue before handling any standard priority item
|
* Tries to empty the high priority queue before handling any standard priority item
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef PIOS_TELEM_PRIORITY_QUEUE
|
#ifdef PIOS_TELEM_PRIORITY_QUEUE
|
||||||
// empty priority queue, non-blocking
|
// empty priority queue, non-blocking
|
||||||
while (xQueueReceive(channel->priorityQueue, &ev, 0) == pdTRUE) {
|
while (xQueueReceive(channel->priorityQueue, &ev, 0) == pdTRUE) {
|
||||||
@ -606,6 +623,7 @@ static void telemetryTxTask(void *parameters)
|
|||||||
processObjEvent(channel, &ev);
|
processObjEvent(channel, &ev);
|
||||||
}
|
}
|
||||||
#endif /* PIOS_TELEM_PRIORITY_QUEUE */
|
#endif /* PIOS_TELEM_PRIORITY_QUEUE */
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -650,7 +668,8 @@ static uint32_t localPort()
|
|||||||
{
|
{
|
||||||
return PIOS_COM_TELEM_RF;
|
return PIOS_COM_TELEM_RF;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
#endif /* ifdef HAS_RADIO */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the port to be used for communication on the radio channel
|
* Determine the port to be used for communication on the radio channel
|
||||||
@ -688,7 +707,7 @@ static int32_t transmitLocalData(uint8_t *data, int32_t length)
|
|||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* ifdef HAS_RADIO */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transmit data buffer to the radioport.
|
* Transmit data buffer to the radioport.
|
||||||
@ -811,9 +830,11 @@ static void updateTelemetryStats()
|
|||||||
|
|
||||||
// Get stats
|
// Get stats
|
||||||
UAVTalkGetStats(radioChannel.uavTalkCon, &utalkStats, true);
|
UAVTalkGetStats(radioChannel.uavTalkCon, &utalkStats, true);
|
||||||
|
|
||||||
#ifdef HAS_RADIO
|
#ifdef HAS_RADIO
|
||||||
UAVTalkAddStats(localChannel.uavTalkCon, &utalkStats, true);
|
UAVTalkAddStats(localChannel.uavTalkCon, &utalkStats, true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Get object data
|
// Get object data
|
||||||
FlightTelemetryStatsGet(&flightStats);
|
FlightTelemetryStatsGet(&flightStats);
|
||||||
GCSTelemetryStatsGet(&gcsStats);
|
GCSTelemetryStatsGet(&gcsStats);
|
||||||
@ -895,7 +916,6 @@ 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
|
||||||
@ -939,7 +959,6 @@ static void updateSettings(channelContext *channel)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* ifdef HAS_RADIO */
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
* @}
|
* @}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user