I'm trying to configure STDIO with the "IO_SERIAL_NON_BLOCKING" flag because I need the reception not to block waiting for X amount of characters. I have added the IO_SERIAL_NON_BLOCKING flag in the BSP_DEFAULT_IO_OPEN_MODE in the "twrk64f120m.h" file to have the configuration like this:
#define BSP_DEFAULT_IO_OPEN_MODE (void *) (IO_SERIAL_XON_XOFF | IO_SERIAL_TRANSLATION | IO_SERIAL_ECHO | IO_SERIAL_NON_BLOCKING)
But if I do that printf stops working. I single stepped through the code to see what is going on and I noticed that when the line:
result = _io_doprint(stdout, _io_fputc, -1, (char *)fmt_ptr, ap);
is executed in "printf" (function "_io_printf" in file "io_pntf.c"), the function call in the macro stdout (function "_io_get_handle" in file "io_ghand.c") is returning NULL instead of _io_serial_polled_write and therefore the 1st argument of _io_doprint is NULL. And because it is null, then when the _io_fputc function is called to print one character it returns prematurely with IO_EOF instead of continuing and eventually calling _io_serial_polled_write to send the character to the UART.
Why is this happening?
Hi Manuel:
It is not a valid combination of IO_SERIAL_NON_BLOCKING | IO_SERIAL_TRANSLATION | IO_SERIAL_ECHO | IO_SERIAL_XON_XOFF)
Please see code below.
Function _io_serial_polled_open()
mqx/source/io/serial/polled/serl_pol.c, Line 259
...
if ((_mqx_uint)flags & IO_SERIAL_NON_BLOCKING) {
if ((_mqx_uint)flags & (IO_SERIAL_TRANSLATION | IO_SERIAL_ECHO | IO_SERIAL_XON_XOFF)) {
result = MQX_INVALID_PARAMETER;
...
Regards
Daniel
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Even if I configure with IO_SERIAL_NON_BLOCKING and nothing else it doesn't work. I just want to know how can I configure the STDIO as non-blocking. Is that even possible?
Thanks!
Hi Manuel:
I tried your suggestion, configure with IO_SERIAL_NON_BLOCKING and nothing else, it can work on my side.
I attached my user_config.h and twrk64f120m.h for your reference.
Regards
Daniel
That didn't work for me. I had to enable the "i" version of the TTY. For example, in my case, I had to use "ITTYE" to make it work which is actually better. Otherwise, with "TTYE" printf just displays the "H".