<< Previous | Next >> | |
|
int cof_serXgets( char * s, int max, unsigned long tmout ); /* where X is A-F */
Description
- This single-user cofunction reads characters from port X until a null terminator, linefeed, or carriage return character is read,
max
characters are read, or untiltmout
milliseconds transpires between characters read. A timeout will never occur if no characters have been received. This function is non-reentrant. It yields to other tasks for as long as the input buffer is locked or whenever the buffer becomes empty as characters are read.s
will always be null terminated upon return. The functionscof_serEgets()
andcof_serFgets()
may be used with the Rabbit 3000 or Rabbit 4000.Parameters
- s
- Character array into which a null terminated string is read.
- max
- The maximum number of characters to read into s.
- tmout
- Millisecond wait period between characters before timing out.
Return value
1
if CR ormax
bytes read intos
.
0
if function times out before reading CR ormax
bytes.Library
- RS232.LIB
Example
main() { // echoes null terminated character strings
int getOk;
char s[16];
serAopen(19200);
loopinit();
while (1) {
loophead();
costate {
wfd getOk = cof_serAgets (s, 15, 20);
if (getOk)
wfd cof_serAputs(s);
else { // timed out: s null terminated, but incomplete
}
}
}
serAclose();
}
Dynamic C Functions | << Previous | Next >> | rabbit.com |