41 #include <objectpersistence.h>
42 #include <radiocombridgestats.h>
43 #include "hwtaulink.h"
46 #if defined(PIOS_INCLUDE_FLASH_EEPROM)
47 #include <pios_eeprom.h>
51 #include "flightbatterystate.h"
52 #include "flightstatus.h"
53 #include "positionactual.h"
54 #include "velocityactual.h"
55 #include "baroaltitude.h"
56 #include "modulesettings.h"
63 #include <uavtalkreceiver.h>
68 #define STACK_SIZE_BYTES 600
69 #define TASK_PRIORITY PIOS_THREAD_PRIO_LOW
71 #define MAX_PORT_DELAY 200
72 #define COMSTATS_INJECT 400
73 #define RETRY_TIMEOUT_MS 150
74 #define USB_ACTIVITY_TIMEOUT_MS 6000
112 void *ctx,
void *obj,
int len)
114 (void) ctx; (void) obj; (void) len;
123 #if defined(PIOS_COM_TELEM_USB)
132 static volatile uint32_t usb_last_active;
140 if (usb_last_active) {
154 #endif // PIOS_COM_TELEM_USB
161 #if defined(PIOS_COM_TELEM_USB)
194 #ifdef PIOS_INCLUDE_WDG
232 if (RadioComBridgeStatsInitialize() == -1) {
236 if ((FlightBatteryStateInitialize() == -1) ||
237 (FlightStatusInitialize() == -1) ||
238 (PositionActualInitialize() == -1) ||
239 (VelocityActualInitialize() == -1) ||
240 (BaroAltitudeInitialize() == -1)) {
265 RadioComBridgeStatsData radioComBridgeStats;
274 RadioComBridgeStatsGet(&radioComBridgeStats);
277 radioComBridgeStats.TelemetryTxBytes +=
279 radioComBridgeStats.TelemetryTxFailures +=
282 radioComBridgeStats.TelemetryRxBytes +=
284 radioComBridgeStats.TelemetryRxFailures +=
286 radioComBridgeStats.TelemetryRxCrcErrors +=
287 telemetryUAVTalkStats.
rxCRC;
289 radioComBridgeStats.RadioTxBytes += radioUAVTalkStats.
txBytes;
290 radioComBridgeStats.RadioTxFailures += radioUAVTalkStats.
txErrors;
292 radioComBridgeStats.RadioRxBytes += radioUAVTalkStats.
rxBytes;
293 radioComBridgeStats.RadioRxFailures += radioUAVTalkStats.
rxErrors;
294 radioComBridgeStats.RadioRxCrcErrors += radioUAVTalkStats.
rxCRC;
297 RadioComBridgeStatsSet(&radioComBridgeStats);
312 #ifdef PIOS_INCLUDE_WDG
317 uint8_t serial_data[32];
318 uint16_t bytes_to_process =
323 if (bytes_to_process > 0) {
326 i < bytes_to_process;
i++) {
341 RadioComBridgeStatsHandle(),
365 #ifdef PIOS_INCLUDE_WDG
384 uint8_t serial_data[32];
385 uint16_t bytes_to_process =
390 if (bytes_to_process > 0) {
395 for (uint8_t
i = 0;
i < bytes_to_process;
457 #define MetaObjectId(x) (x+1)
485 case HWTAULINK_OBJID:
487 case UAVTALKRECEIVER_OBJID:
527 case HWTAULINK_OBJID:
529 case UAVTALKRECEIVER_OBJID:
532 case FLIGHTBATTERYSTATE_OBJID:
533 case FLIGHTSTATUS_OBJID:
534 case POSITIONACTUAL_OBJID:
535 case VELOCITYACTUAL_OBJID:
536 case BAROALTITUDE_OBJID:
544 outConnectionHandle);
uint32_t PIOS_Thread_Systime(void)
static int32_t RadioSendHandler(void *ctx, uint8_t *buf, int32_t length)
struct pios_thread * telemetryRxTaskHandle
static uintptr_t getComPort()
static void NewReceiverData(const UAVObjEvent *ev, void *ctx, void *obj, int len)
UAVTalkConnection radioUAVTalkCon
void UAVTalkGetStats(UAVTalkConnection connection, UAVTalkStats *stats)
static void ProcessLocalStream(UAVTalkConnection inConnectionHandle, UAVTalkConnection outConnectionHandle, uint8_t rxbyte)
Process a byte of data received on the telemetry stream.
static void updateRadioComBridgeStats()
bool PIOS_WDG_RegisterFlag(uint16_t flag_requested)
Register a module against the watchdog.
bool PIOS_WDG_UpdateFlag(uint16_t flag)
Function called by modules to indicate they are still running.
void * PIOS_malloc(size_t size)
struct pios_thread * radioRxTaskHandle
#define PIOS_COM_TELEM_USB
static RadioComBridgeData * data
MODULE_INITCALL(RadioComBridgeInitialize, RadioComBridgeStart)
#define PIOS_WDG_TELEMETRY
#define PIOS_COM_TELEM_SER
#define USB_ACTIVITY_TIMEOUT_MS
static void radioRxTask(void *parameters)
UAVTalkConnection UAVTalkInitialize(void *ctx, UAVTalkOutputCb outputStream, UAVTalkAckCb ackCallback, UAVTalkReqCb reqCallback, UAVTalkFileCb fileCallback)
static bool processUsbActivity(bool seen_active)
uint16_t PIOS_COM_ReceiveBuffer(uintptr_t com_id, uint8_t *buf, uint16_t buf_len, uint32_t timeout_ms)
Private include file of the UAVTalk library.
UAVTalkConnection telemUAVTalkCon
struct pios_thread * PIOS_Thread_Create(void(*fp)(void *), const char *namep, size_t stack_bytes, void *argp, enum pios_thread_prio_e prio)
Event dispatcher, distributes object events as callbacks. Alternative to using tasks and queues...
bool PIOS_Thread_Period_Elapsed(const uint32_t prev_systime, const uint32_t increment_ms)
Determine if a period has elapsed since a datum.
uint16_t PIOS_COM_GetNumReceiveBytesPending(uintptr_t com_id)
Tracking statistics for a UAVTalk connection.
void PIOS_Thread_Sleep(uint32_t time_ms)
void PIOS_ANNUNC_Toggle(uint32_t annunc_id)
static void telemetryRxTask(void *parameters)
int32_t UAVTalkSendObject(UAVTalkConnection connection, UAVObjHandle obj, uint16_t instId, uint8_t acked)
UAVTalkRxState UAVTalkProcessInputStreamQuiet(UAVTalkConnection connection, uint8_t rxbyte)
#define PIOS_COM_RADIOBRIDGE
static int32_t RadioComBridgeInitialize(void)
Initialise the module.
Includes PiOS and core architecture components.
int32_t UAVTalkReceiveObject(UAVTalkConnection connectionHandle)
int32_t PIOS_COM_SendBufferStallTimeout(uintptr_t com_id, const uint8_t *buffer, uint16_t len, uint32_t max_ms)
void telemetry_set_inhibit(bool inhibit)
int32_t UAVTalkRelayPacket(UAVTalkConnection inConnectionHandle, UAVTalkConnection outConnectionHandle)
Include file of the UAVTalk library.
static int32_t RadioComBridgeStart(void)
Start the module.
uint32_t UAVTalkGetPacketObjId(UAVTalkConnection connection)
static int32_t UAVTalkSendHandler(void *ctx, uint8_t *buf, int32_t length)
Transmit data buffer to the com port.
bool PIOS_COM_Available(uintptr_t com_id)
static void ProcessRadioStream(UAVTalkConnection inConnectionHandle, UAVTalkConnection outConnectionHandle, uint8_t rxbyte)
Process a byte of data received on the radio data stream.