Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(BLE): Add WSF Terminal flush on Console UART error #1212

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
*/
/*************************************************************************************************/

#include "util/terminal.h"

#include "pal_uart.h"
#include "pal_led.h"
#include "pal_sys.h"
Expand Down Expand Up @@ -92,7 +94,12 @@ void UART_CommonHandler(mxc_uart_regs_t *uart)
{
const uint8_t uartIdx = MXC_UART_GET_IDX(uart);

if( uartIdx == CONSOLE_UART || uartIdx == HCI_UART)
if(uartIdx == CONSOLE_UART)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this solve the problem we're having? I haven't seen RX errors in the testing that I've done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have gotten a handful of overflow errors when it is automated. You probably won't when manually doing it. It used to be an assertion that fired off, which happened 5-10% of runs. It is my best guess right now for the no action bound issue I see.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're better off preventing the overflow with slower writes from the automation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will close it if you want, but we can't guarantee that the issue wont happen regardless.

{
TerminalFlush();
MXC_UART_ClearRXFIFO(uart);
}
else if(uartIdx == HCI_UART)
{
MXC_UART_ClearRXFIFO(uart);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
*/
/*************************************************************************************************/

#include "util/terminal.h"

#include "pal_uart.h"
#include "pal_led.h"
#include "pal_sys.h"
Expand Down Expand Up @@ -90,10 +92,16 @@ void UART_CommonHandler(mxc_uart_regs_t *uart)
{
const uint8_t uartIdx = MXC_UART_GET_IDX(uart);

if( uartIdx == CONSOLE_UART || uartIdx == HCI_UART)
if( uartIdx == CONSOLE_UART)
{
TerminalFlush();
MXC_UART_ClearRXFIFO(uart);
}
else if(uartIdx == HCI_UART)
{
MXC_UART_ClearRXFIFO(uart);
}

else
{
PAL_SYS_ASSERT(err == E_NO_ERROR);
Expand Down
7 changes: 7 additions & 0 deletions Libraries/Cordio/wsf/include/util/terminal.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ void TerminalTxPrint(const char *pStr, ...);
/*************************************************************************************************/
void TerminalTx(const uint8_t *pData, uint16_t len);

/*************************************************************************************************/
/*!
* \brief Flush terminal parser
*/
/*************************************************************************************************/
void TerminalFlush(void);

/*! \} */ /* WSF_UTIL_API */

#endif /* TERMINAL_H */
6 changes: 6 additions & 0 deletions Libraries/Cordio/wsf/sources/util/terminal.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,3 +496,9 @@ static uint8_t terminalCommandEchoHandler(uint32_t argc, char **argv)
return TERMINAL_ERROR_OK;
}


void TerminalFlush(void)
{
memset(terminalCb.buf, 0, TERMINAL_MAX_COMMAND_LEN + 1);
terminalCb.bufOffset = 0;
}
Loading