non-blocking write and read, writes and reads respectively only the first character of the string (Txed or Rxed)

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

non-blocking write and read, writes and reads respectively only the first character of the string (Txed or Rxed)

ソリューションへジャンプ
2,117件の閲覧回数
chandrasekarkan
Contributor III

Tower K60.

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

and

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?

1 解決策
1,003件の閲覧回数
chandrasekarkan
Contributor III

Enabled "ITTYC" in user_config.h and changed fopen("ttyc:", NULL) to fopen("ittyc", NULL)... this did the trick for me...

元の投稿で解決策を見る

0 件の賞賛
3 返答(返信)
1,003件の閲覧回数
DavidS
NXP Employee
NXP Employee

Hi Chandrasekar,

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.

Regards,

David

1,004件の閲覧回数
chandrasekarkan
Contributor III

Enabled "ITTYC" in user_config.h and changed fopen("ttyc:", NULL) to fopen("ittyc", NULL)... this did the trick for me...

0 件の賞賛
1,003件の閲覧回数
BielikM
Contributor III

Hi,

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.

Regards,

Martin