Api details, Cygiowrite, Cygioread – Comtrol eCos User Manual
Page 371: Cyg_io_write, Cyg_io_read, Cyg_io_get_config
Chapter 16. Serial driver details
The field
tx_bufsize
contains the total size of the transmit data buffer. This is set to zero on devices that do not
support buffering (i.e. polled devices).
The field
tx_count
contains the number of bytes currently occupied in the transmit data buffer. This is set to
zero on devices that do not support buffering (i.e. polled devices).
API Details
cyg_io_write
cyg_io_write(handle, buf, len)
Send the data from
buf
to the device. The driver maintains a buffer to hold the data. The size of the intermediate
buffer is configurable within the interface module. The data is not modified at all while it is being buffered. On
return,
*len
contains the amount of characters actually consumed .
It is possible to configure the write call to be blocking (default) or non-blocking. Non-blocking mode requires both
the configuration option
CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING
to be enabled, and the specific device to
be set to non-blocking mode for writes (see
cyg_io_set_config()
).
In blocking mode, the call will not return until there is space in the buffer and the entire contents of
buf
have been
consumed.
In non-blocking mode, as much as possible gets consumed from
buf
. If everything was consumed, the call returns
ENOERR
. If only part of the
buf
contents was consumed,
-EAGAIN
is returned and the caller must try again. On
return,
*len
contains the number of characters actually consumed .
The call can also return
-EINTR
if interrupted via the
cyg_io_get_config()
/
ABORT
key.
cyg_io_read
cyg_io_read(handle, buf, len)
Receive data into the buffer,
buf
, from the device. No manipulation of the data is performed before being trans-
ferred. An interrupt driven interface module will support data arriving when no read is pending by buffering the
data in the serial driver. Again, this buffering is completely configurable. On return,
*len
contains the number of
characters actually received.
It is possible to configure the read call to be blocking (default) or non-blocking. Non-blocking mode requires both
the configuration option
CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING
to be enabled, and the specific device to
be set to non-blocking mode for reads (see
cyg_io_set_config()
).
In blocking mode, the call will not return until the requested amount of data has been read.
In non-blocking mode, data waiting in the device buffer is copied to
buf
, and the call returns immediately. If there
was enough data in the buffer to fulfill the request,
ENOERR
is returned. If only part of the request could be fulfilled,
-EAGAIN
is returned and the caller must try again. On return,
*len
contains the number of characters actually
received.
The call can also return
-EINTR
if interrupted via the
cyg_io_get_config()
/
ABORT
key.
267