Enable non-blocking reads for Mbed OS I/O target redefines

Hello Jasper,

The scanf & printf use the console for input and output. In a library (or in the main function) you can get the the associated FileHandle’s as:

    FileHandle* console_in = mbed_file_handle(STDIN_FILENO);
    FileHandle* console_out = mbed_file_handle(STDOUT_FILENO);

After that you can enable non-blocking as console_in.set_blocking(false) or check if characters are available as console_in.readable().

See also Hitchhiker's Guide to Printf in Mbed 6 - #41 by Hans_Waldherr

1 Like