Example of using scanf() in an MQX task?

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

Example of using scanf() in an MQX task?

666 Views
davepfaltzgraff
Senior Contributor I

I would like to set up a task running under MQX that would "listen" for user input via the virtual COM port. Until the user inputs something, this task is to remain in the idle state.

Since scanf() likes to work on a string, I may need to use a variation of getc() and do my own character handling. But, I'd be OK with that as long as the task remains idle until input is available.

Is there a good example of this?

Thanks

0 Kudos
2 Replies

427 Views
soledad
NXP Employee
NXP Employee

Hello David,

Could you please check the below thread?

Please let me know if this helps!!!

Has anyone modified the MQX serial driver to include a timeout?


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

427 Views
davepfaltzgraff
Senior Contributor I

Hi Sol,

The link you pointed to is interesting and may be useful sometime in the future. What I did to take care of the problem is just what I suggested in the original post. Since the getchar() blocks for the next character, I just let the task accumulate an appropriate string and than pass that through sscanf(). Since I am not concerned about timeouts (yet), it works for me.

My problem was in looking at fscanf() as compared to the combo of getcchar()/sscanf().

Thanks for your input.

0 Kudos