diff --git a/flight/Libraries/packet_handler.c b/flight/Libraries/packet_handler.c index cbb82d77e..83d79990c 100644 --- a/flight/Libraries/packet_handler.c +++ b/flight/Libraries/packet_handler.c @@ -91,7 +91,7 @@ PHInstHandle PHInitialize(PacketHandlerConfig *cfg) data->lock = xSemaphoreCreateRecursiveMutex(); // Initialize the ECC library. - initialize_ecc(); + initialize_ecc(); // Return the structure. return (PHInstHandle)data; diff --git a/flight/Modules/RadioComBridge/RadioComBridge.c b/flight/Modules/RadioComBridge/RadioComBridge.c index 76c3040a5..429b76f02 100644 --- a/flight/Modules/RadioComBridge/RadioComBridge.c +++ b/flight/Modules/RadioComBridge/RadioComBridge.c @@ -291,7 +291,7 @@ static void comUAVTalkTask(void *parameters) data->txBytes++; // Get a TX packet from the packet handler if required. - if (p == NULL) + if ((p == NULL) && !PIOS_COM_TRANS_COM) { // Wait until we receive a sync. @@ -320,7 +320,8 @@ static void comUAVTalkTask(void *parameters) } // Insert this byte. - p->data[p->header.data_size++] = rx_byte; + if(p) + p->data[p->header.data_size++] = rx_byte; // Keep reading until we receive a completed packet. UAVTalkRxState state = UAVTalkProcessInputStreamQuiet(data->inUAVTalkCon, rx_byte); @@ -390,12 +391,14 @@ static void comUAVTalkTask(void *parameters) } // Release the packet, since we don't need it. - PHReleaseTXPacket(pios_packet_handler, p); + if(p) + PHReleaseTXPacket(pios_packet_handler, p); } else { - // Otherwise, queue the packet for transmission. - xQueueSend(data->sendPacketQueue, &p, MAX_PORT_DELAY); + // Otherwise, queue the packet for transmission if we're using UAVTalk comms. + if(p) + xQueueSend(data->sendPacketQueue, &p, MAX_PORT_DELAY); } } else @@ -425,13 +428,15 @@ static void comUAVTalkTask(void *parameters) } // Release the packet, since we don't need it. - PHReleaseTXPacket(pios_packet_handler, p); + if(p) + PHReleaseTXPacket(pios_packet_handler, p); } } else { - // Queue the packet for transmission. - xQueueSend(data->sendPacketQueue, &p, MAX_PORT_DELAY); + // Queue the packet for transmission if we're using UAVTalk comms. + if(p) + xQueueSend(data->sendPacketQueue, &p, MAX_PORT_DELAY); } p = NULL; @@ -449,12 +454,14 @@ static void comUAVTalkTask(void *parameters) xQueueSend(data->objEventQueue, &ev, MAX_PORT_DELAY); // Release the packet and start over again. - PHReleaseTXPacket(pios_packet_handler, p); + if(p) + PHReleaseTXPacket(pios_packet_handler, p); } else { // Transmit the packet anyway... - xQueueSend(data->sendPacketQueue, &p, MAX_PORT_DELAY); + if(p) + xQueueSend(data->sendPacketQueue, &p, MAX_PORT_DELAY); } p = NULL; } @@ -630,7 +637,7 @@ static void transparentCommTask(void * parameters) // Receive data from the com port uint32_t cur_rx_bytes = PIOS_COM_ReceiveBuffer(PIOS_COM_TRANS_COM, p->data + p->header.data_size, - PH_MAX_DATA - p->header.data_size, timeout); + PH_MAX_DATA - p->header.data_size, timeout); // Do we have an data to send? p->header.data_size += cur_rx_bytes;