<< Previous | Next >>

serXread

int serXread( void * data, int length, unsigned long tmout ); /* where X is A-F */

Description

Reads length bytes from serial port X or until tmout milliseconds transpires between bytes. The countdown of tmout does not begin until a byte has been received. A timeout occurs immediately if there are no characters to read. This function is non-reentrant.

The functions serEread() and serFread() may be used with the Rabbit 3000 and Rabbit 4000.

NOTE Alternatively you can use another form of this function that has been generalized for all serial ports. Instead of substituting for "X" in the function name, the prototype of the generalized function is: serXread(int port, ...), where "port" is one of the macros SER_PORT_A through SER_PORT_F.

Parameters

data
Data structure to read from serial port X

length
Number of bytes to read

tmout
Maximum wait in milliseconds for any byte from previous one

Return value

The number of bytes read from serial port X.

Library

RS232.LIB

Example

// echoes a blocks of characters
main() {
int n;
char s[16];
serAopen(19200);
while (1) {
if ((n = serAread(s, 15, 20)) > 0) {
serAwrite(s, n);
}
}
serAclose();
}


Dynamic C Functions << Previous | Next >> rabbit.com