I have fisrt installed uart2 from user_config.h so init_bsp.c installs UART2 at this line...
_kuart_polled_install("ttyc:", &_bsp_sci2_init, _bsp_sci2_init.QUEUE_SIZE);
then opened it with "myapp.c"
MQX_FILE_PTR fPtr = fopen("ttyc:", NULL);
int uartparam = 0 | IO_SERIAL_NON_BLOCKING | IO_SERIAL_TRANSLATION;
ioctl( fPtr, IO_SET_SERIAL_FLAGS, &uartparam);
write(fPtr, "HELLO", 5); writes only the first character 'H'.
read(fPtr, rdBuffer, 16); reads only the first character sent from hyperterminal on PC.
What should I do to write a whole string and read a whole string in non-blocking mode?
Solved! Go to Solution.
When you set the UART to polled mode the UART QUEUE is not used. It is only used in interrupt (i.e. ittyc) mode.
If you keep driver in polled mode, then you need to use the fstatus(fPTR); call to determine if a character is present and ready to get. If it returns non-zero then you have a character waiting. If zero no character waiting.
If that doesn't work for you please try the interrupt mode.
You installed polled uart and tried to write data in non blocking mode. It is wrong combination. On k70 uart module is no internal buffer. Your application is faster than uart baudrate. When second byte wants to be send, first byte is still sending and non blocking write returns 1 (1 byte successfully sent). It is not a mistake, it is normal non blocking behavior.
Your solution with iTTYC (interrupt TTYC) should be correct.
In general with non blocking mode you should always check return values from read() or write() functions.