sub_rs_xfer |
Top Previous Next |
Got to SUB-20 page |
Synopsis int sub_rs_xfer( sub_handle hndl, char* tx_buf, int tx_sz, char* rx_buf, int rx_sz )
Transmit and/or receive message(s) via UART configured with sub_rs_set_config and in accordance with transfer timing set with sub_rs_timing. Parameters •tx_buf - buffer with data to be transmitted •tx_sz - number of bytes to transmit (can be 0 if transmit not required) •rx_buf - buffer to store received data •rx_sz - maximal number of bytes to receive (can be 0 if reception is not required)
rx_sz and tx_sz should not be grater then 62 bytes. Function will terminate after following conditions fulfilled: tx_sz bytes transmitted and either rx_sz bytes received or one of the timeouts occurs (see sub_rs_timing)
For 9bit transfer data in tx_buf and rx_buf has following format
Even bytes (0,2,4,....) contain 8'th bit in LSB. Odd bytes (1,3,5,...) contain bits 7..0. Data is shifted out beginning from bit 0 (see RS232 RS485 Frame format). Parameters tx_sz and rx_sz should correspond to total number of bytes in tx_buf and rx_buf. Return value On success function returns non negative value that denotes number of received bytes. It can be less then rx_sz if timeout occurs. Otherwise -1 will be returned and sub_errno will contain error code. Example /* Set timing */ sub_rs_timing( hndl, RS_RX_AFTER_TX, 0, 1000000, 200000 );
/* Transmit 3 bytes and try to receive up to 5 bytes in 1s with 200ms byte to byte timeout */ sub_rs_xfer( hndl, "at\r", 3, rx_buf, 5 ); Compatibility
|