<< Previous | Next >>

cof_serXread

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

Description

This single-user cofunction reads length characters from port X (where X is A, B, C, D, E or F) or until tmout milliseconds transpires between characters read. It yields to other tasks for as long as the input buffer is locked or whenever the buffer becomes empty as characters are read. A timeout will never occur if no characters have been read. This function is non-reentrant.

The functions cof_serEread() and cof_serFread() may be used with the Rabbit 3000 or 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: cof_serXread(int port, ...), where "port" is one of the macros SER_PORT_A through SER_PORT_F.

Parameters

data
Data structure into which characters are read.

length
The number of characters to read into data.

tmout
Millisecond wait period to allow between characters before timing out.

Return value

Number of characters read into data.

Library

RS232.LIB

Example

// echoes a block of characters
main() {
int n;
char s[16];
serAopen(19200);
loopinit();
while (1) {
loophead();
costate {
wfd n = cof_serAread(s, 15, 20);
wfd cof_serAwrite(s, n);
}
}
serAclose();
}


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