Nonblocking scanf

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
4,040件の閲覧回数
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,032件の閲覧回数
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,811件の閲覧回数
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,033件の閲覧回数
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