RS485 missing received data

All about Sub-20 Multi Interface USB Adapter USB to I2C, SPI, GPIO, RS232, RS485, Ir, LCD

Moderator: serg

Post Reply
davidl
Posts: 1
Joined: Mon Feb 06, 2012 12:33 pm

RS485 missing received data

Post by davidl »

I am waiting for received data on the RS485 interface using the following loop

do {
rxDataLen = sub_rs_xfer(m_hRadioComPort, (char*) txDataBuf, 0, (char*) rxDataBuf, 15);
} while (rxDataLen == 0);

and am finding that some data is sometimes lost in the interval between sub_rs_xfer timing out and being called again.

The fifo is not available to use with the RS485 interface, and there does not seem to be any way to tell sub_rs_xfer not to time out.

Has anyone else seen this problem, and are they aware of any solution?

xol
Site Admin
Posts: 241
Joined: Sat Aug 29, 2009 8:04 am

Re: RS485 missing received data

Post by xol »

HI,
The loop you use is good for receiving messages of known size with an interval between messages of at least 5-10ms.
This is to compensate interval between subsequent calls to sub_rs_xfer.

If you want to ONLY RECEIVE data you CAN use FIFO.
Something like this:

Code: Select all

sub_rs_set_config(...);

sub_fifo_config( hndl, FIFO_SELECT_UART );

read_sz =0;
while( read_sz < DESIRED_SZ )
{
   read_sz += sub_fifo_read( hndl, buf+read_sz, 64, to_ms );
}
FIFO write will not work for RS485. This is because SUB-20 will not turn on RS485 transmitter driver.
To transmit you should:

Code: Select all

sub_fifo_config( hndl, 0 );   /* Disconnect FIFO from UART */
sub_rs_xfer( ... );
Keep in mind that RS485 is half duplex bus and you can not receive and transmit at the same time. Or more exactly you can but at the transmit time you will receive data you are transmitting.
Try it this way and let us know. I have ideas how to add some functionality to SUB-20 but not sure it is required in your case.

Post Reply