NetBurner 3.5.0
PDF Version
 
iosys.h File Reference

NetBurner I/O System Library API. More...

#include <constants.h>
#include <stdio.h>
#include <basictypes.h>

Go to the source code of this file.

Macros

I/O Control Options

The legal options for use with ioctl() and in conjunction with ioctlCmdFlags

#define IOCTL_TX_CHANGE_CRLF   (1)
 When set, transmitted char \n gets converted to \r\n
 
#define IOCTL_RX_CHANGE_CRLF   (2)
 When set, received \r\n get turned into \n
 
#define IOCTL_RX_PROCESS_EDITS   (4)
 When set, process backspace and do simple line editing.
 
#define IOCTL_RX_ECHO   (8)
 When set, echo chars received to tx.
 
#define IOCTL_TX_NO_BLOCK   (32)
 When set, stdout and stderr will drop output instead of blocking.
 
#define IOCTL_ALL_OPTIONS   (15)
 When set, turns on all options.
 
I/O Control Command Flags

The command flags to use in contuction with ioctl() and ioctlOptions

#define IOCTL_SET   (0x4000)
 Set an option.
 
#define IOCTL_CLR   (0x2000)
 Clear an option.
 

Typedefs

typedef void FDCallBack(int fd, FDChangeType change, void *pData)
 Define the function signature for file descriptor notification callbacks.
 

Enumerations

FD Change Type

The notifications that a registered FD monitor can receive.

enum  FDChangeType { eReadSet , eWriteSet , eErrorSet , eClosingNow }
 The notifications that a registered FD monitor can receive. More...
 

Functions

int close (int fd)
 Close the specified file descriptor and free the associated resources.
 
int read (int fd, char *buf, int nbytes)
 Read data from a file descriptor (fd).
 
int peek (int fd, char *c)
 Peek at the data for the specified file descriptor (fd). Will block forever until at least one byte is available to be read. The byte returned is not removed from the fd buffer, it will be the first byte of data returned on any subsequent read operation.
 
int write (int fd, const char *buf, int nbytes)
 Write data to the stream associated with a file descriptor (fd). Can be used to write data to stdio, a TCP socket, or a Serial port.
 
int writestring (int fd, const char *str)
 Write a null terminated ascii string to the stream associated with a file descriptor (fd). Can be used to write data to stdio, a TCP socket, or a Serial port.
 
int writeall (int fd, const char *buf, int nbytes=0)
 Write the specified number of bytes to a file descriptor. Will block until all bytes are sent, or a file descriptor error occurs (such as a TCP socket error). Can be used to write data to stdio, a TCP socket, or a Serial port.
 
int ReadWithTimeout (int fd, char *buf, int nbytes, unsigned long timeout)
 Read data from a file descriptor(fd), or return if at least one byte is not read within the specified timeout. Can be used instead of the read() function, which will block forever until at least one byte is read. File descriptors include such things as stdio, TCP sockets, TLS sockets, and Serial ports.
 
int ReadWithTickTimeout (int fd, char *buf, int nbytes, TickTimeout &timeout)
 Same as ReadWithTimeout(), except the timeout value parameter is of type TickTimeout instead of an unsigned long. The TickTimeout object is more robust in terms of sequential timeout calls and rollover protection.
 
int ReadAllWithTimeout (int fd, char *buf, int nbytes, unsigned long timeout)
 Attempt to read the specified number of bytes from a file descriptor, or return with the number of bytes read if the timeout value has expired.
 
int ReadAllWithTickTimeout (int fd, char *buf, int nbytes, TickTimeout &timeout)
 Same as ReadWithTimeout(), except the timeout value parameter is of type TickTimeout instead of an unsigned long. The TickTimeout object is more robust in terms of sequential timeout calls and rollover protection.
 
int readall (int fd, char *buf, int nbytes)
 Read the specified number of bytes from a file descriptor (fd). This function will block until either the requested number of bytes have been read, or a file descriptor error occurs. It can be used to read from stdio, TCP sockets, or Serial ports.
 
int PeekWithTimeout (int fd, char *c, unsigned long timeout)
 This function peeks at data from a file descriptor (fd), with a specified timeout 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.
 
int getchar ()
 Get a character from stdin. Will block if no character is available, from stdio library. The default stdin is the debug serial port.
 
int dataavail (int fd)
 Check the specified file descriptor to detmeine if data is available to be read.
 
int writeavail (int fd)
 Check the specified file descriptor to determine data can be written.
 
int haserror (int fd)
 Check if a file descriptor has an error.
 
int charavail ()
 Checks to see if data is available for read on stdin. By default, stdin is the boot/debug serial port.
 
void RegisterFDCallBack (int fd, FDCallBack *fp, void *pData)
 Register a callback function to receive notification when an FD state changes. Register a NULL fp to remove the notification.
 
void FD_ZERO (fd_set *pfds)
 Clear (set to 0) a fd_set (file descriptor set) so no file descriptors (fds) are selected.
 
void FD_CLR (int fd, fd_set *pfds)
 A 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.
 
void FD_SET (int fd, fd_set *pfds)
 A 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.
 
int FD_ISSET (int fd, fd_set *pfds)
 A fd_set (file descriptor set) holds a set of file descriptors (fds). This function checks whether or not a particular fd is set in the specified fd_set.
 
int FD_OVERLAP (const fd_set *f1, const fd_set *f2)
 A fd_set (file descriptor set) holds a set of file descriptors (fds). This function determines whether there exists a common file descriptor between the two sets.
 
void FD_COPY (const fd_set *from, fd_set *to)
 A fd_set (file descriptor set) holds a set of file descriptors (fds). This function copies one file descriptor set to another.
 
void FD_SETFROMSET (const fd_set *from, fd_set *to)
 A fd_set (file descriptor set) holds a set of file descriptors (fds). This function adds the file descriptors from one set to another.
 
void FD_CLRFROMSET (const fd_set *from, fd_set *to)
 A fd_set (file descriptor set) holds a set of file descriptors (fds). This function remove the file descriptors in one set from another.
 
int select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, unsigned long timeout)
 Wait for events to occur on one or more I/O resources associated with a set of file descriptors (fds), such as data available to be read, a resource is available to write data, or an error has occurred.
 
int ZeroWaitSelect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds)
 Returns whether events have occurred on one or more I/O resources associated with a set of file descriptors (fds), and returns immediately.
 
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.
 
int ReplaceStdio (int stdio_fd, int new_fd)
 Maps stdio to any file descriptor (fd).
 
int CurrentStdioFD (int stdio_fd)
 Returns the current file descriptor mapped to the stdio file descriptor.
 
void IrqStdio ()
 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.
 

Detailed Description

NetBurner I/O System Library API.