Modules | |
I/O Control Command Flags | |
I/O Control Options | |
Typedefs | |
typedef void | FDCallBack(int fd, FDChangeType change, void *pData) |
This defines the funciton signature for FD notifcation callbacks. More... | |
Enumerations | |
enum | FDChangeType |
This enum lists the notificatiosn that a registered FD monitor can recieve. | |
Functions | |
int | close (int fd) |
This function closes the resources associated with a file descriptor (fd). This can be a TCP socket or a Serial I/O port. More... | |
int | read (int fd, char *buf, int nbytes) |
This function reads data from a file descriptor (fd), and will block forever until at least one byte is available to be read (as opposed to the ReadWithTimeout() function which reads data from a file descriptor with a specified time-out value). This function can be used to read from stdio, TCP sockets, or Serial ports. More... | |
int | peek (int fd, char *c) |
This function peeks at data from a file descriptor (fd), and will block forever until at least one byte is available to be read (as opposed to the ReadWithTimeout() function which reads data from a file descriptor with a specified time-out value). This function can be used to peek from stdio, TCP sockets, or Serial ports. More... | |
int | write (int fd, const char *buf, int nbytes) |
This function writes data to the stream associated with a file descriptor (fd). More... | |
int | writestring (int fd, const char *str) |
This function writes null terminated string data to the stream associated with a file descriptor (fd). This function can be used to write data to stdio, a TCP socket, or a Serial port. More... | |
int | writeall (int fd, const char *buf, int nbytes) |
This function writes data to the stream associated with a file descriptor (fd). More... | |
int | ReadWithTimeout (int fd, char *buf, int nbytes, unsigned long timeout) |
This function reads data from a file descriptor (fd), with a specified time-out value (as opposed to the read function which will block forever until at least one byte is available to be read). More... | |
int | ReadAllWithTimeout (int fd, char *buf, int nbytes, unsigned long timeout) |
This function reads data from a file descriptor (fd), with a specified time-out value (as opposed to the read function which will block forever until at least one byte is available to be read). More... | |
int | readall (int fd, char *buf, int nbytes) |
This function reads data from a file descriptor (fd), with a specified time-out value (as opposed to the read function which will block forever until at least one byte is available to be read). More... | |
int | PeekWithTimeout (int fd, char *c, unsigned long timeout) |
This function peeks at data from a file descriptor (fd), with a specified time-out value (as opposed to the peek function which will block forever until at least one byte is available to be read). This function can be used to peek from stdio, TCP sockets, or Serial ports. More... | |
int | dataavail (int fd) |
This function checks to see if data is available for read. More... | |
int | writeavail (int fd) |
Check to see if a file descriptor is available for write. More... | |
int | haserror (int fd) |
Check to see if a file descriptor has an error. More... | |
int | charavail () |
This function checks to see if data is available for read on stdin. More... | |
void | RegisterFDCallBack (int fd, FDCallBack *fp, void *pData) |
Register a call back function to recieve notifcation when an FD state changes. Register a NULL pf to remove the notifcation. More... | |
void | FD_ZERO (fd_set *pfds) |
This function zero's an fd_set (file descriptor set) so that it has no file descriptors (fds) selected. More... | |
void | FD_CLR (int fd, fd_set *pfds) |
An fd_set (file descriptor set) holds a set of file descriptors (fds). This function clears or removes a specific file descriptor in an fd_set. More... | |
void | FD_SET (int fd, fd_set *pfds) |
An fd_set (file descriptor set) holds a set of file descriptors (fds). This function sets or adds a specific file descriptor to an fd_set. More... | |
int | FD_ISSET (int fd, fd_set *pfds) |
An fd_set (file descriptor set) holds a set of file descriptors (fds). This function indicates whether (or not) a specific fd is in a specific fd_set. More... | |
int | select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, unsigned long timeout) |
This function waits for events to occur on one or more I/O resources associated with a set of file descriptors (fds). More... | |
int | ZeroWaitSelect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds) |
This function returns whether events have occurred on one or more I/O resources associated with a set of file descriptors (fds). More... | |
int | ioctl (int fd, int cmd) |
This function controls the selection of input/output control options for stdio: stdin = 0, stdout = 1 and stderr = 2. More... | |
int | ReplaceStdio (int stdio_fd, int new_fd) |
This function allows you to map stdio to any file descriptor (fd). More... | |
int | CurrentStdioFD (int stdio_fd) |
Determine the current file descriptor mapped to stdio file. More... | |
void | IrqStdio () |
Automatically open the system default serial port in interrupt mode using the system default baud rate and assign this serial port to stdin, stdout and stderr. | |
The NetBurner I/O System Group
typedef void FDCallBack(int fd, FDChangeType change, void *pData) |
This defines the funciton signature for FD notifcation callbacks.
int | fd The file descriptor number |
change | the reason for the call back |
pData | a void * passed into the register function so one can refernce objects etc... |
int charavail | ( | ) |
This function checks to see if data is available for read on stdin.
1 | If data is available |
0 | If no data is available |
int close | ( | int | fd | ) |
This function closes the resources associated with a file descriptor (fd). This can be a TCP socket or a Serial I/O port.
fd | The file descriptor number |
0 | On success |
Code | A resource specific error code on failure |
int CurrentStdioFD | ( | int | stdio_fd | ) |
Determine the current file descriptor mapped to stdio file.
fd | stdio_fd The stdio file descriptor to check. Options are stdin (0), stdout (1), and stderr (2). |
int dataavail | ( | int | fd | ) |
This function checks to see if data is available for read.
fd | The file descriptor number. |
1 | If data is available |
0 | If no data is available |
void FD_CLR | ( | int | fd, |
fd_set * | pfds | ||
) |
An fd_set (file descriptor set) holds a set of file descriptors (fds). This function clears or removes a specific file descriptor in an fd_set.
fd | The file descriptor number. |
*pfds | A pointer to the fd_set to modify. |
int FD_ISSET | ( | int | fd, |
fd_set * | pfds | ||
) |
void FD_SET | ( | int | fd, |
fd_set * | pfds | ||
) |
An fd_set (file descriptor set) holds a set of file descriptors (fds). This function sets or adds a specific file descriptor to an fd_set.
fd | The file descriptor number. |
*pfds | A pointer to the fd_set to modify. |
void FD_ZERO | ( | fd_set * | pfds | ) |
This function zero's an fd_set (file descriptor set) so that it has no file descriptors (fds) selected.
*pfds | A pointer to the fd_set. |
int haserror | ( | int | fd | ) |
Check to see if a file descriptor has an error.
fd | The file descriptor number. |
1 | The file descriptor has an error |
0 | The file descriptor does not have an error |
int ioctl | ( | int | fd, |
int | cmd | ||
) |
This function controls the selection of input/output control options for stdio: stdin = 0, stdout = 1 and stderr = 2.
The legal options are listed in I/O Control Options.
fd | The file descriptor number. The three options are stdin (0), stdout (1), and stderr (2). |
cmd | The ioctl command options are I/O Control Command Flags and the bit of the associated options as defined by I/O Control Options. |
int peek | ( | int | fd, |
char * | c | ||
) |
This function peeks at data from a file descriptor (fd), and will block forever until at least one byte is available to be read (as opposed to the ReadWithTimeout() function which reads data from a file descriptor with a specified time-out value). This function can be used to peek from stdio, TCP sockets, or Serial ports.
The byte returned is not removed from the fd. The byte returned will be the first byte of data returned on the first subsequent read().
fd | The file descriptor number. |
*buf | A pointer to the read destination. |
1 | Number of bytes peeked |
<0 | Error when reading from file descriptor |
int PeekWithTimeout | ( | int | fd, |
char * | c, | ||
unsigned long | timeout | ||
) |
This function peeks at data from a file descriptor (fd), with a specified time-out value (as opposed to the peek function which will block forever until at least one byte is available to be read). This function can be used to peek from stdio, TCP sockets, or Serial ports.
The byte returned is not removed from the fd. The byte returned will be the first byte of data returned on the first subsequent read().
fd | The file descriptor number. |
*buf | A pointer to the read destination. |
0 | Timeout, but the file descriptor is still valid |
1 | Number of bytes peeked |
<0 | Error when reading from file descriptor |
int read | ( | int | fd, |
char * | buf, | ||
int | nbytes | ||
) |
This function reads data from a file descriptor (fd), and will block forever until at least one byte is available to be read (as opposed to the ReadWithTimeout() function which reads data from a file descriptor with a specified time-out value). This function can be used to read from stdio, TCP sockets, or Serial ports.
fd | The file descriptor number. |
*buf | A pointer to the read destination. |
nbytes | Maximum number of bytes to read. |
>0 | Number of bytes read |
<0 | Error when reading from file descriptor |
int readall | ( | int | fd, |
char * | buf, | ||
int | nbytes | ||
) |
This function reads data from a file descriptor (fd), with a specified time-out value (as opposed to the read function which will block forever until at least one byte is available to be read).
This function will block until either the requested number of bytes have been read or the file descriptor returns an error. This function can be used to read from stdio, TCP sockets, or Serial ports.
fd | The file descriptor number. |
*buf | A pointer to the read destination. |
nbytes | Number of bytes to read. |
0 | Timeout, but TCP connection is still valid |
>0 | The number of bytes read |
-1 | TCP connection is no longer valid |
int ReadAllWithTimeout | ( | int | fd, |
char * | buf, | ||
int | nbytes, | ||
unsigned long | timeout | ||
) |
This function reads data from a file descriptor (fd), with a specified time-out value (as opposed to the read function which will block forever until at least one byte is available to be read).
This function will block until either the time-out expires, the requested number of bytes have been read, or the file descriptor returns an error. This function can be used to read from stdio, TCP sockets, or Serial ports.
fd | The file descriptor number. |
*buf | A pointer to the read destination. |
nbytes | Number of bytes to read. |
timeout | The number of timer ticks to wait for data. |
0 | Timeout, but TCP connection is still valid |
>0 | The number of bytes read |
-1 | TCP connection is no longer valid |
int ReadWithTimeout | ( | int | fd, |
char * | buf, | ||
int | nbytes, | ||
unsigned long | timeout | ||
) |
This function reads data from a file descriptor (fd), with a specified time-out value (as opposed to the read function which will block forever until at least one byte is available to be read).
This function will block until either the time-out expires or at least one byte is available to be read. This function can be used to read from stdio, TCP sockets, or Serial ports.
Important: This function operates like a read function in that it reads all available bytes and returns. The addition of a time-out does not cause the function to block until the maximum number of bytes specified in the function call is available. As with read, the application must use the return value of the ReadWithTimeout function to determine how many bytes were read, and call the function again if necessary.
fd | The file descriptor number. |
*buf | A pointer to the read destination. |
nbytes | Maximum number of bytes to read. |
timeout | The number of timer ticks to wait for data. |
0 | Timeout, but TCP connection is still valid |
>0 | The number of bytes read |
-1 | TCP connection is no longer valid |
void RegisterFDCallBack | ( | int | fd, |
FDCallBack * | fp, | ||
void * | pData | ||
) |
Register a call back function to recieve notifcation when an FD state changes. Register a NULL pf to remove the notifcation.
int | fd The file descriptor number |
fp | The function pointer to call back |
pData | a void * passed into the call back function to enable object references etc... |
int ReplaceStdio | ( | int | stdio_fd, |
int | new_fd | ||
) |
This function allows you to map stdio to any file descriptor (fd).
If the file descriptor generates an error (like a closed TCP connection), then stdio will be remapped to a negative fd (this will cause stdio to generate errors). When this function is used to remap stdio channel that has errored, then the error will be cleared.
stdio_fd | The stdio file descriptor to map to. Options are stdin (0), stdout (1), and stderr (2). |
new_fd | The file descriptor to replace stdio with. Note: A value of 0 returns stdio to the default debug monitor based traps. |
0 | If stdio had not been previously mapped |
>0 | The value of the fd for the previous stdio override |
int select | ( | int | nfds, |
fd_set * | readfds, | ||
fd_set * | writefds, | ||
fd_set * | errorfds, | ||
unsigned long | timeout | ||
) |
This function waits for events to occur on one or more I/O resources associated with a set of file descriptors (fds).
The user indicates his/her interest in specific fds by setting them in the fd_sets (file descriptor set) that are passed into the function. Note: This function will "unblock" when at least one byte is available for the file descriptor you add to the output set.
nfds | The number of file descriptors to examine. Note: This parameter is currently ignored. |
*readfds | A pointer to the fd_set to select for read events. Note: This parameter can be NULL. It is modified on exit to reflect the read availability of the selected fds in the set. |
*writefds | A pointer to the fd_set to select for write availability events. Note: This parameter can be NULL. It is modified on exit to reflect the write availability of the selected fds in the set. |
*errorfds | Apointer to the fd_set to select for error events. Note: This parameter can be NULL. It is modified on exit to reflect the error state of the selected fds in the set. |
*timeout | The number of time ticks to wait before timing out if no events occurred in the selected fd set. |
0 | If the function timed out |
>0 | The number of fds in all of the non null fd_sets |
int write | ( | int | fd, |
const char * | buf, | ||
int | nbytes | ||
) |
This function writes data to the stream associated with a file descriptor (fd).
This function can be used to write data to stdio, a TCP socket, or a Serial port. Note: The write function will block until at least one byte is written, but does not have to write all the bytes requested. For example, if you wanted to write 100 bytes, and there was only room in the buffer for 5, then the write function would return 5.
fd | The file descriptor number. |
*buf | A pointer to the byte to write. |
nbytes | Maximum number of bytes to write. |
0 | If the write timed out |
>0 | The number of bytes written (Note: This value can be less than the number of bytes requested) |
<0 | If an error occured |
int writeall | ( | int | fd, |
const char * | buf, | ||
int | nbytes | ||
) |
This function writes data to the stream associated with a file descriptor (fd).
This function can be used to write data to stdio, a TCP socket, or a Serial port. It will block and wait for the fd to either send the whole requested amount or to return an error.
fd | The file descriptor number. |
*buf | A pointer to the byte to write. |
nbytes | Maximum number of bytes to write. |
>=0 | The number of bytes written |
<0 | If an error occured |
int writeavail | ( | int | fd | ) |
Check to see if a file descriptor is available for write.
fd | The file descriptor number. |
1 | If write is available |
0 | If write is not available |
int writestring | ( | int | fd, |
const char * | str | ||
) |
This function writes null terminated string data to the stream associated with a file descriptor (fd). This function can be used to write data to stdio, a TCP socket, or a Serial port.
fd | The file descriptor number. |
*str | A pointer to the NULL terminated string to write. |
0 | If the write timed out |
>0 | The number of bytes written (Note: This value can be less than the number of bytes requested) |
<0 | If an error occured |
int ZeroWaitSelect | ( | int | nfds, |
fd_set * | readfds, | ||
fd_set * | writefds, | ||
fd_set * | errorfds | ||
) |
This function returns whether events have occurred on one or more I/O resources associated with a set of file descriptors (fds).
The user indicates his/her interest in specific fds by setting them in the fd_sets (file descriptor set) that are passed into the function.
nfds | The number of file descriptors to examine. Note: This parameter is currently ignored. |
*readfds | A pointer to the fd_set to select for read events. Note: This parameter can be NULL. It is modified on exit to reflect the read availability of the selected fds in the set. |
*writefds | A pointer to the fd_set to select for write availability events. Note: This parameter can be NULL. It is modified on exit to reflect the write availability of the selected fds in the set. |
*errorfds | Apointer to the fd_set to select for error events. Note: This parameter can be NULL. It is modified on exit to reflect the error state of the selected fds in the set. |
0 | If there is no valid fds |
>0 | The number of fds in all of the non null fd_sets |