Why is "printf" not working when configuring STDIO with IO_SERIAL_NON_BLOCKING flag?

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

Why is "printf" not working when configuring STDIO with IO_SERIAL_NON_BLOCKING flag?

2,267 Views
m4l490n
Contributor V

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?

Tags (3)
0 Kudos
Reply
5 Replies

2,139 Views
danielchen
NXP TechSupport
NXP TechSupport

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.
-------------------------------------------------------------------------------

0 Kudos
Reply

2,139 Views
m4l490n
Contributor V

danielchen@fsl

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!

0 Kudos
Reply

2,138 Views
danielchen
NXP TechSupport
NXP TechSupport

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

0 Kudos
Reply

2,138 Views
m4l490n
Contributor V

danielchen@fsl

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".

0 Kudos
Reply

2,138 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi

I tried the interrupt version :    ittyB.  Please refer to my attached files.

I run the hello world example, it seem ok on my side.

pastedImage_1.png

Regards

Daniel

0 Kudos
Reply