From 7b6cce7bcb54e70d2c3a1dcc6ca221906c2b3f79 Mon Sep 17 00:00:00 2001 From: Vladimir Zidar Date: Wed, 15 Jun 2022 00:39:02 +0200 Subject: [PATCH] LP-457 Add missing PIOS_COM_ClearRxBuffer() to simposix target --- flight/pios/posix/pios_com.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/flight/pios/posix/pios_com.c b/flight/pios/posix/pios_com.c index 8cd754055..5998b84c5 100644 --- a/flight/pios/posix/pios_com.c +++ b/flight/pios/posix/pios_com.c @@ -280,6 +280,26 @@ int32_t PIOS_COM_ChangeBaud(uint32_t com_id, uint32_t baud) return 0; } +/** + * Clear Rx buffer + * \param[in] port COM port + * \return -1 if port not available + * \return 0 on success + */ +int32_t PIOS_COM_ClearRxBuffer(uint32_t com_id) +{ + struct pios_com_dev *com_dev = PIOS_COM_find_dev(com_id); + + if (!PIOS_COM_validate(com_dev)) { + /* Undefined COM port for this board (see pios_board.c) */ + return -1; + } + + fifoBuf_clearData(&com_dev->rx); + + return 0; +} + /** * Sends a package over given port * \param[in] port COM port