GETCHAR() func. Quick-Hack for Non-Blocking input.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GETCHAR() func. Quick-Hack for Non-Blocking input.

1,124 Views
hi-ro
Contributor II

Hi, forks,

Recentry, DebugConsole do not supports NON-BLOCKING input.

(DbgConsole_TryGetchar  is gone...)

So, I've tried some quick hack DbgConsole_Getchar() to adapt Non-blocking operation.

2 files are modified.

(fsl_debug_console.h) :
 GETCHAR_NB()  DbgConsole_Getchar_NB()

 

(fsl_debug_console.c) :

Add struct entry, like below:

hal_uart_status_t (*getChar_NB)(hal_uart_handle_t handle,
uint8_t *data,
size_t length);

and, init it same manner, like below

s_debugConsole.getChar_NB = HAL_UartReceiveNonBlocking;

add new func.  DbgConsole_Getchar_NB(void)  like  DbgConsole_Getchar() but modification like below :
int DbgConsole_Getchar_NB(void)
 s_debugConsole.getChar_NB((hal_uart_handle_t)&s_debugConsole.uartHandleBuffer[0], (uint8_t *)(&dbgConsoleCh), 1))

 

This is quick hack, it seems working in my test env.

it not have well test.

please use and report hidden?  problem.

Thank you.

 

0 Kudos
Reply
2 Replies

1,110 Views
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @hi-ro,

Thanks for reporting this, I'm sure it will be useful for other users as well. I will pass on these findings to the SDK team so they can evaluate whether or not they add this to a next revision of the SDKs.

BR,
Edwin.

0 Kudos
Reply

1,049 Views
hi-ro
Contributor II

Dear EdwinHz,

Thank you for your reply.

After that, I noticed potential bad code.

In the DbgConsole_Getchar(void) function, it passes dbgConsoleCh variable as pointer,

and ISR writes this variable, so, this variable must be static.

or, leaving function then this variable released to stack.  I troubled about it several hours.

Change "char dbgConsoleCh;" with "static char dbgConsoleCh = 0;" 

  It will help your peace of mind !

Thank you.

 

0 Kudos
Reply