Does mbed has scanf function with non-blocking ?
Hello,
Shortly, nope.
The scanf function is provided by STD library (nothing to do with Mbed’s code) and it counts with with specified format of input, how is shown in example of scanf function. So if you want read some random string from stdin, then scanf is not the right function for you.
For random string you can try to use getchar - C++ Reference (cplusplus.com), collecting chars to your buffer until EOF occurred.
BR, Jan
Thanks a lot.But I realy want a non-blocking input from STDIO, It seem to getchar is not the right function for me.
Reading Blocking vs Non-Blocking
in Hitchhiker’s Guide to Printf in Mbed 6 might help.
Yes, I was wrong with getc/getchar, that is also blocking.
Then you can do it via Mbed APIs by your self.
BufferedSerial - API references and tutorials | Mbed OS 6 Documentation
UnbufferedSerial - API references and tutorials | Mbed OS 6 Documentation
BR, Jan
I’v got it.Thanks very much!