NetBurner 3.1
IOSYS - I/O System

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.
 

Detailed Description

The NetBurner I/O System Group

Typedef Documentation

◆ FDCallBack

typedef void FDCallBack(int fd, FDChangeType change, void *pData)

This defines the funciton signature for FD notifcation callbacks.

Parameters
intfd The file descriptor number
changethe reason for the call back
pDataa void * passed into the register function so one can refernce objects etc...
See also
FDChangeType
RegisterFDCallBack

Function Documentation

◆ charavail()

int charavail ( )

This function checks to see if data is available for read on stdin.

Return values
1If data is available
0If no data is available
See also
dataavail()
writeavail()
read()

◆ close()

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.

Parameters
fdThe file descriptor number
Return values
0On success
CodeA resource specific error code on failure
See also
peek()
PeekWithTimeout()
read()
ReadWithTimeout()
write()

◆ CurrentStdioFD()

int CurrentStdioFD ( int  stdio_fd)

Determine the current file descriptor mapped to stdio file.

Parameters
fdstdio_fd The stdio file descriptor to check. Options are stdin (0), stdout (1), and stderr (2).
Returns
The current file descriptor mapped to stdio_fd

◆ dataavail()

int dataavail ( int  fd)

This function checks to see if data is available for read.

Parameters
fdThe file descriptor number.
Return values
1If data is available
0If no data is available
See also
charavail()
peek()
read()
ReadWithTimeout()

◆ FD_CLR()

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.

Parameters
fdThe file descriptor number.
*pfdsA pointer to the fd_set to modify.
See also
FD_ZERO()
FD_SET()
FD_ISSET()
select()

◆ FD_ISSET()

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.

Parameters
fdThe file descriptor number.
*pfdsA pointer to the fd_set to test.
See also
FD_ZERO()
FD_CLR()
FD_SET()
select()

◆ FD_SET()

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.

Parameters
fdThe file descriptor number.
*pfdsA pointer to the fd_set to modify.
See also
FD_ZERO()
FD_CLR()
FD_ISSET()
select()

◆ FD_ZERO()

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.

Parameters
*pfdsA pointer to the fd_set.
See also
FD_CLR()
FD_SET()
FD_ISSET()
select()

◆ haserror()

int haserror ( int  fd)

Check to see if a file descriptor has an error.

Parameters
fdThe file descriptor number.
Return values
1The file descriptor has an error
0The file descriptor does not have an error
See also
dataavail()
writeavail()
charavail()

◆ ioctl()

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.

Parameters
fdThe file descriptor number. The three options are stdin (0), stdout (1), and stderr (2).
cmdThe ioctl command options are I/O Control Command Flags and the bit of the associated options as defined by I/O Control Options.
Returns
The old option value.
ioctl(0,IOCTL_SET| IOCTL_ALL_OPTIONS); // Sets all options
ioctl(1,IOCTL_CLR| IOCTL_ALL_OPTIONS); // Clears all options
See also
ReplaceStdio()

◆ peek()

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().

Parameters
fdThe file descriptor number.
*bufA pointer to the read destination.
Return values
1Number of bytes peeked
<0Error when reading from file descriptor
See also
TCP Socket Status
close()
read()
PeekWithTimeout()
ReadWithTimeout()
write()

◆ PeekWithTimeout()

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().

Parameters
fdThe file descriptor number.
*bufA pointer to the read destination.
Return values
0Timeout, but the file descriptor is still valid
1Number of bytes peeked
<0Error when reading from file descriptor
See also
TCP Socket Status
close()
peek()
read()
ReadWithTimeout()
write()

◆ read()

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.

Parameters
fdThe file descriptor number.
*bufA pointer to the read destination.
nbytesMaximum number of bytes to read.
Return values
>0Number of bytes read
<0Error when reading from file descriptor
See also
TCP Socket Status
close()
peek()
PeekWithTimeout()
ReadWithTimeout()
ReadAllWithTimeout()
readall()
write()

◆ readall()

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.

Parameters
fdThe file descriptor number.
*bufA pointer to the read destination.
nbytesNumber of bytes to read.
Return values
0Timeout, but TCP connection is still valid
>0The number of bytes read
-1TCP connection is no longer valid
See also
close()
peek()
read()
PeekWithTimeout()
ReadWithTimeout()
ReadAllWithTimeout()
write()

◆ ReadAllWithTimeout()

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.

Parameters
fdThe file descriptor number.
*bufA pointer to the read destination.
nbytesNumber of bytes to read.
timeoutThe number of timer ticks to wait for data.
Return values
0Timeout, but TCP connection is still valid
>0The number of bytes read
-1TCP connection is no longer valid
See also
close()
peek()
read()
PeekWithTimeout()
ReadWithTimeout()
readall()
write()

◆ ReadWithTimeout()

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.

Parameters
fdThe file descriptor number.
*bufA pointer to the read destination.
nbytesMaximum number of bytes to read.
timeoutThe number of timer ticks to wait for data.
Return values
0Timeout, but TCP connection is still valid
>0The number of bytes read
-1TCP connection is no longer valid
See also
close()
peek()
read()
PeekWithTimeout()
ReadWithTimeout()
ReadAllWithTimeout()
readall()
write()

◆ RegisterFDCallBack()

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.

Parameters
intfd The file descriptor number
fpThe function pointer to call back
pDataa void * passed into the call back function to enable object references etc...
See also
FDChangeType
FDCCallBack

◆ ReplaceStdio()

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.

Parameters
stdio_fdThe stdio file descriptor to map to. Options are stdin (0), stdout (1), and stderr (2).
new_fdThe file descriptor to replace stdio with. Note: A value of 0 returns stdio to the default debug monitor based traps.
Return values
0If stdio had not been previously mapped
>0The value of the fd for the previous stdio override
See also
ioctl()

◆ select()

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.

Parameters
nfdsThe number of file descriptors to examine. Note: This parameter is currently ignored.
*readfdsA 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.
*writefdsA 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.
*errorfdsApointer 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.
*timeoutThe number of time ticks to wait before timing out if no events occurred in the selected fd set.
Return values
0If the function timed out
>0The number of fds in all of the non null fd_sets
See also
FD_ZERO()
FD_CLR()
FD_SET()
FD_ISSET()

◆ write()

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.

Parameters
fdThe file descriptor number.
*bufA pointer to the byte to write.
nbytesMaximum number of bytes to write.
Return values
0If the write timed out
>0The number of bytes written (Note: This value can be less than the number of bytes requested)
<0If an error occured
See also
close()
peek()
read()
PeekWithTimeout()
ReadWithTimeout()
writestring()
writeall()

◆ writeall()

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.

Parameters
fdThe file descriptor number.
*bufA pointer to the byte to write.
nbytesMaximum number of bytes to write.
Return values
>=0The number of bytes written
<0If an error occured
See also
close()
peek()
read()
PeekWithTimeout()
ReadWithTimeout()
write()
writestring()

◆ writeavail()

int writeavail ( int  fd)

Check to see if a file descriptor is available for write.

Parameters
fdThe file descriptor number.
Return values
1If write is available
0If write is not available
See also
dataavail()
charavail()
haserror()

◆ writestring()

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.

Parameters
fdThe file descriptor number.
*strA pointer to the NULL terminated string to write.
Return values
0If the write timed out
>0The number of bytes written (Note: This value can be less than the number of bytes requested)
<0If an error occured
See also
close()
peek()
read()
PeekWithTimeout()
ReadWithTimeout()
write()
writeall()

◆ ZeroWaitSelect()

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.

Parameters
nfdsThe number of file descriptors to examine. Note: This parameter is currently ignored.
*readfdsA 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.
*writefdsA 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.
*errorfdsApointer 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.
Return values
0If there is no valid fds
>0The number of fds in all of the non null fd_sets
See also
FD_ZERO()
FD_CLR()
FD_SET()
FD_ISSET()