From bcdd5a8bba429901d67e9d57108254d8d7993741 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Fri, 20 Jul 2012 13:45:31 -0500 Subject: [PATCH] Fixes to the overo module where it was thinking the fifo buffer writes failed --- flight/Modules/OveroSync/overosync.c | 5 ++--- flight/PiOS/STM32F4xx/pios_overo.c | 19 +++++++++++-------- flight/PiOS/inc/pios_overo.h | 1 + flight/Revolution/System/pios_board.c | 4 ++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/flight/Modules/OveroSync/overosync.c b/flight/Modules/OveroSync/overosync.c index 1e563b30e..e0554dadc 100644 --- a/flight/Modules/OveroSync/overosync.c +++ b/flight/Modules/OveroSync/overosync.c @@ -186,7 +186,6 @@ static void overoSyncTask(void *parameters) // Update stats. This will trigger a local send event too OveroSyncStatsData syncStats; syncStats.Send = overosync->sent_bytes; - syncStats.Received = 0; syncStats.Connected = syncStats.Send > 500 ? OVEROSYNCSTATS_CONNECTED_TRUE : OVEROSYNCSTATS_CONNECTED_FALSE; syncStats.DroppedUpdates = overosync->failed_objects; syncStats.Packets = PIOS_OVERO_GetPacketCount(pios_overo_id); @@ -212,9 +211,9 @@ static int32_t packData(uint8_t * data, int32_t length) { portTickType tickTime = xTaskGetTickCount(); - if( PIOS_COM_SendBufferNonBlocking(pios_com_overo_id, (uint8_t *) &tickTime, sizeof(tickTime)) != 0) + if( PIOS_COM_SendBufferNonBlocking(pios_com_overo_id, (uint8_t *) &tickTime, sizeof(tickTime)) < 0) goto fail; - if( PIOS_COM_SendBufferNonBlocking(pios_com_overo_id, data, length) != 0) + if( PIOS_COM_SendBufferNonBlocking(pios_com_overo_id, data, length) < 0) goto fail; overosync->sent_bytes += length + 4; diff --git a/flight/PiOS/STM32F4xx/pios_overo.c b/flight/PiOS/STM32F4xx/pios_overo.c index b7b83fc77..5642c2eda 100644 --- a/flight/PiOS/STM32F4xx/pios_overo.c +++ b/flight/PiOS/STM32F4xx/pios_overo.c @@ -171,14 +171,6 @@ void PIOS_OVERO_DMA_irq_handler(uint32_t overo_id) // Load any pending bytes from TX fifo PIOS_OVERO_WriteData(overo_dev); - - /*if (overo_dev->tx_out_cb) { - bool tx_need_yield = false; - (overo_dev->tx_out_cb)(overo_dev->tx_out_context, &overo_dev->tx_buffer[overo_dev->writing_buffer][0], PACKET_SIZE, NULL, &tx_need_yield); - if (tx_need_yield) { - vPortYieldFromISR(); - } - }*/ overo_dev->packets++; } @@ -193,6 +185,17 @@ int32_t PIOS_OVERO_GetPacketCount(uint32_t overo_id) return overo_dev->packets; } +/** + * Debugging information to check how it is runnign + */ +int32_t PIOS_OVERO_GetWrittenBytes(uint32_t overo_id) +{ + struct pios_overo_dev * overo_dev = (struct pios_overo_dev *) overo_id; + PIOS_Assert(PIOS_OVERO_validate(overo_dev)); + + return overo_dev->writing_offset; +} + /** * Initialise a single Overo device */ diff --git a/flight/PiOS/inc/pios_overo.h b/flight/PiOS/inc/pios_overo.h index e02e2bac1..9e0f1d4e7 100644 --- a/flight/PiOS/inc/pios_overo.h +++ b/flight/PiOS/inc/pios_overo.h @@ -32,6 +32,7 @@ extern void PIOS_OVERO_DMA_irq_handler(uint32_t overo_id); extern int32_t PIOS_OVERO_GetPacketCount(uint32_t overo_id); +extern int32_t PIOS_OVERO_GetWrittenBytes(uint32_t overo_id); #endif /* PIOS_OVERO_H */ diff --git a/flight/Revolution/System/pios_board.c b/flight/Revolution/System/pios_board.c index 7f2a8ebcd..df4bfd74a 100644 --- a/flight/Revolution/System/pios_board.c +++ b/flight/Revolution/System/pios_board.c @@ -795,8 +795,8 @@ void PIOS_Board_Init(void) { PIOS_Assert(rx_buffer); PIOS_Assert(tx_buffer); if (PIOS_COM_Init(&pios_com_overo_id, &pios_overo_com_driver, pios_overo_id, - rx_buffer, PIOS_COM_TELEM_USB_RX_BUF_LEN, - tx_buffer, PIOS_COM_TELEM_USB_TX_BUF_LEN)) { + rx_buffer, PACKET_SIZE, + tx_buffer, PACKET_SIZE)) { PIOS_Assert(0); } }