Rabbit 2000 Getting Started - page 30
Getting Started Manual
25
4.3.4 Single-User Cofunction Input Functions
These are Dynamic C cofunctions. If the input buffer they use is locked or becomes full
during the course of their operation, they yield to other tasks, but do not return to execute
the next statement within their own costatement block until they have completed their operation.
scofunc int cof_serXgetc ( );
Reads a single character from the serial port, yielding when not successful, and only returning when a
character is successfully read.
Parameters
None
Return Value
An integer with the character read in the low byte.
scofunc int cof_serXgets(char *s, int length,
unsigned long tmout);
Reads a null-terminated string, completes its execution when a carriage return is read,
length
number
of characters are read, or the character to character timeout period elapses after the first character is read.
It yields to other tasks while the input buffer is locked or becomes empty during its execution, and only
returns control to the following statement in its own costatement block when it completes.
Parameters
data
—Destination data structure. The user must ensure data is allocated for at least length bytes.
length
—The number of bytes to read.
tmout
—The number of milliseconds to wait for each character after the first character is read.
Return Value
1—CR or
length
bytes read into
s
.
0—Function times out before reading CR or
length
bytes.
scofunc int cof_serXread(void *data, int length,
unsigned long tmout);
Reads a block of characters, completes its execution when
length
number of characters are read, or
the character-to-character timeout period elapses after the first character is read. It yields to other tasks
while the input buffer is locked or becomes empty during its execution and only returns control to the
following statement in its own costatement block when it completes.
Parameters
data
—Destination data structure. The user must ensure data is allocated for at least length bytes.
length
—The number of bytes to read.
tmout
—The number of milliseconds to wait for each character after the first.
Return Value
The number of bytes read.