Nonblocking scanf

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Nonblocking scanf

跳至解决方案
4,037 次查看
dynamix
Contributor II
破坏者
 

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 项奖励
回复
1 解答
4,029 次查看
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

在原帖中查看解决方案

2 回复数
3,808 次查看
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().

标记 (1)
0 项奖励
回复
4,030 次查看
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