Nonblocking scanf

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

Nonblocking scanf

Jump to solution
1,822 Views
dynamix
Contributor II
Spoiler
 

Hey all,

 

I need to send a parameter to the board (imxrt1050) once in a while. I am using scanf right now, but it blocks the whole program and wait for the user input. How can I change it to a non-blocking one?

 

Thanks,

0 Kudos
1 Solution
1,814 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi dynamix,

   Do you use the UART to receive your parameter?

  If yes, I think you totally can use the UART interrupt to receive it, that one don't need to blocks the whole program, because when receive the data, it is using the interrupt.

  More details, you can refer to the SDK code:

SDK_2.8.6_EVKB-IMXRT1050\boards\evkbimxrt1050\driver_examples\lpuart

There has a lot of uart interrupt code.

The SDK download link is:

https://mcuxpresso.nxp.com/

 

Wish it helps you!

If you still have questions about, please kindly let me know.

If your question is solved, please help to mark the correct answer just to close this case, thanks.

Best Regards,

Kerry

View solution in original post

2 Replies
1,593 Views
felix1
Contributor IV

According to my test, you can change DbgConsole_Scanf() to DbgConsole_TryGetchar() and define DEBUG_CONSOLE_TRANSFER_NON_BLOCKING. This API is non-blocking scanf().

Tags (1)
0 Kudos
1,815 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi dynamix,

   Do you use the UART to receive your parameter?

  If yes, I think you totally can use the UART interrupt to receive it, that one don't need to blocks the whole program, because when receive the data, it is using the interrupt.

  More details, you can refer to the SDK code:

SDK_2.8.6_EVKB-IMXRT1050\boards\evkbimxrt1050\driver_examples\lpuart

There has a lot of uart interrupt code.

The SDK download link is:

https://mcuxpresso.nxp.com/

 

Wish it helps you!

If you still have questions about, please kindly let me know.

If your question is solved, please help to mark the correct answer just to close this case, thanks.

Best Regards,

Kerry