|
|
 |
|
|
 |
Collaboration diagram for Low Level I/O:
Detailed Description
Low level input and output operations.
Standard C runtime file interface to Nut/OS devices.
|
Defines |
| #define | _O_RDONLY |
| #define | _O_WRONLY |
| #define | _O_RDWR |
| #define | _O_APPEND |
| #define | _O_CREAT |
| #define | _O_TRUNC |
| #define | _O_EXCL |
| #define | _O_TEXT |
| #define | _O_BINARY |
Functions |
| int | _close (int fd) |
| | Close a file, device or socket.
|
| long | _filelength (int fd) |
| | Return the length of a file.
|
| int | _ioctl (int fd, int cmd, void *data) |
| | Perform device specific control functions.
|
| int | _open (CONST char *name, int mode) |
| | Open a file.
|
| int | _read (int fd, void *buffer, unsigned int count) |
| | Read data from a file, device or socket.
|
| int | _write (int fd, CONST void *data, unsigned int count) |
| | Write data to a file, device or socket.
|
| int | _write_P (int fd, PGM_P data, unsigned int count) |
| | Writes data from program space to a file, device or socket.
|
Define Documentation
|
|
Start writing at the end. |
|
|
Create file if it does not exist. |
|
|
Open only if it does not exist. |
|
|
Truncate file if it exists. |
Function Documentation
|
|
Close a file, device or socket.
The calling thread may be suspended until all buffered output data has been written.
- Parameters:
-
| fd | Descriptor of a previously opened file, device or connected socket. |
- Returns:
- 0 if the file was successfully closed or -1 to indicate an error.
|
| long _filelength |
( |
int |
fd |
) |
|
|
|
|
Return the length of a file.
- Parameters:
-
| fd | Descriptor of a previously opened file, device or connected socket. |
- Returns:
- Filelength in bytes or -1 in case of an error.
|
| int _ioctl |
( |
int |
fd, |
|
|
int |
cmd, |
|
|
void * |
data |
|
) |
|
|
|
|
Perform device specific control functions.
Check the specific device driver for a list of supported control functions.
- Parameters:
-
| fd | Descriptor of a previously opened device or connected socket. |
| cmd | Requested control function. |
| data | Points to a buffer that contains any data required for the given control function or receives data from that function. |
|
| int _open |
( |
CONST char * |
name, |
|
|
int |
mode |
|
) |
|
|
|
|
Open a file.
- Parameters:
-
| name | The name of a registered device, optionally followed by a colon and a filename. |
| mode | Operation mode. May be any of the following:
- _O_APPEND Always write at the end.
- _O_BINARY Raw mode.
- _O_CREAT Create file if it does not exist.
- _O_EXCL Open only if it does not exist.
- _O_RDONLY Read only.
- _O_RDWR Read and write.
- _O_TEXT End of line translation.
- _O_TRUNC Truncate file if it exists.
- _O_WRONLY Write only.
|
- Returns:
- File descriptor for the opened file or -1 to indicate an error.
|
| int _read |
( |
int |
fd, |
|
|
void * |
buffer, |
|
|
unsigned int |
count |
|
) |
|
|
|
|
Read data from a file, device or socket.
- Parameters:
-
| fd | Descriptor of a previously opened file, device or connected socket. |
| buffer | Pointer to the buffer that receives the data. |
| count | Maximum number of bytes to read. |
- Returns:
- The number of bytes read, which may be less than the number of bytes specified. A return value of -1 indicates an error.
- Examples:
-
uart/uart.c.
|
| int _write |
( |
int |
fd, |
|
|
CONST void * |
data, |
|
|
unsigned int |
count |
|
) |
|
|
|
|
Write data to a file, device or socket.
- Parameters:
-
| fd | Descriptor of a previously opened file, device or connected socket. |
| data | Pointer to data in program space to be written. |
| count | Number of bytes to write. |
- Returns:
- The number of bytes written, which may be less than the number of bytes specified. A return value of -1 indicates an error.
- Note:
- The write implementation of the underlying driver does not need to be thread-safe. Parallel writes using device usartavr will lead to intermixed data (if data doesn't fit into ringbuffer on the first try )
- Examples:
-
uart/uart.c.
|
| int _write_P |
( |
int |
fd, |
|
|
PGM_P |
data, |
|
|
unsigned int |
count |
|
) |
|
|
|
|
Writes data from program space to a file, device or socket.
Similar to _write() except that the data is located in program memory.
- Parameters:
-
| fd | Descriptor of a previously opened file, device or connected socket. |
| data | Pointer to data in program space to be written. |
| count | Number of bytes to write. |
- Returns:
- The number of bytes written, which may be less than the number of bytes specified. A return value of -1 indicates an error.
- Note:
- The write implementation of the underlying driver does not need to be thread-safe. Parallel writes using device usartavr will lead to intermixed data (if data doesn't fit into ringbuffer on the first try )
- Examples:
-
uart/uart.c.
|
|
 |
|