Lost chars on uart TX

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

Lost chars on uart TX

512件の閲覧回数
OldNick
Contributor IV

Using MQX370 on Kinetis. 

ITTYE at 115,200 no handshake.

 

BSP_DEFAULT_IO_OPEN_MODE                          (pointer) ( IO_SERIAL_RAW_IO | IO_SERIAL_NON_BLOCKING)

 

A single task looks every 10mS to see if any chars have come in, and reliably detects them all.

 

A series of calls to _io_write() from within the same task will intermittently fail to transmit the chars.

 

Buffer size is set to 64, and we never get close to filling that.

 

Lowest level call (_io_serial_int_putc_internal) appears to offer a pass/fail return, but I think MQX throws that away half-way up the stack?  As usual, the documentation is pathetic.

(From the IOUG)

The serial device driver provides these services:
API
Calls              Interrupt-driven               Polled
_io_fopen() _io_serial_int_open() _io_serial_polled_open()
_io_fclose() _io_serial_int_close() _io_serial_polled_close()
_io_read() _io_serial_int_read() _io_serial_polled_read()
_io_write() _io_serial_int_write() _io_serial_polled_write()
_io_ioctl() _io_serial_int_ioctl() _io_serial_polled_ioctl()

 

Well that was useful!

 

This used to be simple - an IRQ for RX chars, and a blocking call waiting on TXBuffEmpty to transmit them was 100% reliable.

 

But there is no setting for "non-blocking on RX only" in the MQX driver.

 

Anybody got any ideas?  Maybe use IOControl calls to see if it is safe to send?  look for the rval on _io_write, and do what?  Flush the bufffer on every character transmit?

Thanks in advance

OldNick

0 件の賞賛
2 返答(返信)

131件の閲覧回数
MarkP_
Contributor V

I changed the defines:

#define IO_SERIAL_NON_BLOCKING_RD    (0x10)

#define IO_SERIAL_NON_BLOCKING_WR    (0x40)

At each build error location change the define by ..RD or ..WR depending if it is read or write operation.

More info:

https://community.freescale.com/thread/93460

~Mark

 

131件の閲覧回数
OldNick
Contributor IV

Thansk Mark.  At least I am not the only one.

 

I thought of doing that, but reluctant to patch the library.  That's Freescale's job, no?

 

Don't think it is any better in MQX380 either.  Maybe you know different?

 

Went native and put in a while loop checking IOCTL_CAN_TRANSMIT just to get reliable TX,

 

void serialP_putchar(  char c )
{
_mqx_int param ;
     do//wait here until there is enough space in the buffer
     {
       (void)ioctl( rs232_dev,IO_IOCTL_SERIAL_CAN_TRANSMIT,&param);
     }while (param <1);
     _io_write( rs232_dev, &c, 1 );//now send it
}

Functional, but not elegant - as it keeps the task active.

 

Anybody got any other ideas?  Reliable Serial TX is kinda fundamental...

 

 

0 件の賞賛