Bytes written to FIFO with sub_fifo_write will be shifted out in RS232 frame format (start bit(s), data, optional parity, stop bit(s)) via RS232_PC_RX pin.
Bytes received via RS232_PC_TX pin will be stored in FIFO and could be read with sub_fifo_read.
UART should be configured with sub_rs_set_config.
Currently supported only RS232 model - SUB-20-R25. In next release we will add RS485 support for SUB-20-R45.
Example below shows sending 256 bytes in 9600 8N1 format and receiving 100 bytes back.
Code: Select all
sub_rs_set_config( hndl, RS_RX_ENABLE|RS_TX_ENABLE|RS_CHAR_8|RS_PARITY_NONE|RS_STOP_1, 9600 );
sub_fifo_config( hndl, FIFO_SELECT_UART );
sub_fifo_write( hndl, tx_buf, 256, 300 );
sub_fifo_read( hndl, rx_buf, 100, 1000 );
1. 128 bytes will be stored in FIFO
2. 64 bytes will be sent and first FIFO bank will be released
3. The remaining 2 bytes will be stored in released bank
So timeout should take in account sending 64 bytes at given baud rate.