From 2cf1fe93c68df58abeb36e736c695fd46b8fdec4 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Fri, 30 Dec 2011 12:55:51 -0500 Subject: [PATCH] com: don't block forever waiting for a transmitter Not all transmitters will continue to run when disconnected. USB is one example of this. When the USB cable was disconnected, any transmitter blocked here would wait forever. This was particularly noticeable when the telemetry Tx task blocked forever on USB disconnect. This also resulted in the telemetry Rx task blocking forever waiting on the UAVTalk connection lock. We now block for a max of 5s waiting for space in the transmit buffer. --- flight/PiOS/Common/pios_com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flight/PiOS/Common/pios_com.c b/flight/PiOS/Common/pios_com.c index 29179c99f..e5440d065 100644 --- a/flight/PiOS/Common/pios_com.c +++ b/flight/PiOS/Common/pios_com.c @@ -352,7 +352,7 @@ int32_t PIOS_COM_SendBuffer(uint32_t com_id, const uint8_t *buffer, uint16_t len fifoBuf_getUsed(&com_dev->tx)); } #if defined(PIOS_INCLUDE_FREERTOS) - if (xSemaphoreTake(com_dev->tx_sem, portMAX_DELAY) != pdTRUE) { + if (xSemaphoreTake(com_dev->tx_sem, 5000) != pdTRUE) { return -3; } #endif