NetBurner 3.5.0
PDF Version
 
IOSYS - I/O System

Typedefs

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

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.
 

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

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.
 

Detailed Description

#include< iosys.h >

I/O system functions use file descriptors for communication and status of network interfaces, serial interfaces, and any custom file descriptors created by an application.

Typedef Documentation

◆ FDCallBack

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

#include <iosys.h>

Define the function signature for file descriptor notification callbacks.

Parameters
fdThe file descriptor number
changeThe reason for the call back, FDChangeType
*pDataA void pointer passed into the register function. Can be used to reference objects or other data
See also
FDChangeType, RegisterFDCallBack

Enumeration Type Documentation

◆ FDChangeType

#include <iosys.h>

The notifications that a registered FD monitor can receive.

Enumerator
eReadSet 

When read data changes from not available to available.

eWriteSet 

When an FD changes from not writable to writeable.

eErrorSet 

When an FD goes from no error to having an error.

eClosingNow 

when the underlying protocol closes the fd

Function Documentation

◆ charavail()

int charavail ( )

#include <iosys.h>

Checks to see if data is available for read on stdin. By default, stdin is the boot/debug serial port.

Return values
1Data available
0No data available
See also
dataavail(), getchar(), writeavail(), read()

◆ close()

int close ( int fd)

#include <iosys.h>

Close the specified file descriptor and free the associated resources.

Parameters
fdThe file descriptor number
Returns
0 on success, or a resource specific error on failure.
See also
peek()
PeekWithTimeout()
read()
ReadWithTimeout()
write()

◆ CurrentStdioFD()

int CurrentStdioFD ( int stdio_fd)

#include <iosys.h>

Returns the current file descriptor mapped to the stdio file descriptor.

Parameters
stdio_fdThe 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)

#include <iosys.h>

Check the specified file descriptor to detmeine if data is available to be read.

Parameters
fdThe file descriptor number
Return values
1Data available
0No data available
See also
charavail(), getchar(), peek(), read(), ReadWithTimeout()

◆ FD_CLR()

void FD_CLR ( int fd,
fd_set * pfds )

#include <iosys.h>

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.

Parameters
fdThe file descriptor number
*pfdsPointer to the fd_set to modify
See also
FD_ZERO(), FD_SET(), FD_ISSET(), select()

◆ FD_CLRFROMSET()

void FD_CLRFROMSET ( const fd_set * from,
fd_set * to )

#include <iosys.h>

A fd_set (file descriptor set) holds a set of file descriptors (fds). This function remove the file descriptors in one set from another.

Parameters
*fromPointer to the fd_set defining which file descriptors to remove.
*toPointer to the fd_set containing file descritpors to remove.
See also
FD_ZERO(), FD_CLR(), FD_ISSET(), select()

◆ FD_COPY()

void FD_COPY ( const fd_set * from,
fd_set * to )

#include <iosys.h>

A fd_set (file descriptor set) holds a set of file descriptors (fds). This function copies one file descriptor set to another.

Parameters
*fromPointer to the file descriptor set being copied from.
*toPointer to the fd_set to copy to.
See also
FD_ZERO(), FD_CLR(), FD_ISSET(), select()

◆ FD_ISSET()

int FD_ISSET ( int fd,
fd_set * pfds )

#include <iosys.h>

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.

For example:

if ( FD_ISSET( fdListen, &readFds ) )
{
// do processing for fdListen
}
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...
Parameters
fdThe file descriptor number
*pfdsA pointer to the fd_set to test
Return values
0File descriptor is not set in the file descriptor set
>0File descriptor is set in the file descriptor set
See also
FD_ZERO(), FD_CLR(), FD_SET(), FD_OVERLAP(), select()

◆ FD_OVERLAP()

int FD_OVERLAP ( const fd_set * f1,
const fd_set * f2 )

#include <iosys.h>

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.

Parameters
*f1Pointer to the first file descriptor set.
*f2Pointer to the second file descriptor set.
See also
FD_ZERO(), FD_CLR(), FD_ISSET(), select()

◆ FD_SET()

void FD_SET ( int fd,
fd_set * pfds )

#include <iosys.h>

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.

Parameters
fdThe file descriptor number
*pfdsPointer to the fd_set to modify
See also
FD_ZERO(), FD_CLR(), FD_ISSET(), select()

◆ FD_SETFROMSET()

void FD_SETFROMSET ( const fd_set * from,
fd_set * to )

#include <iosys.h>

A fd_set (file descriptor set) holds a set of file descriptors (fds). This function adds the file descriptors from one set to another.

Parameters
*fromPointer to the file descriptor set being copied from.
*toPointer to the fd_set to add to.
See also
FD_ZERO(), FD_CLR(), FD_ISSET(), select()

◆ FD_ZERO()

void FD_ZERO ( fd_set * pfds)

#include <iosys.h>

Clear (set to 0) a fd_set (file descriptor set) so no file descriptors (fds) are selected.

Parameters
*pfdsPointer to the file descriptor set
See also
FD_CLR(), FD_SET(), FD_ISSET(), select()

◆ getchar()

int getchar ( )

#include <iosys.h>

Get a character from stdin. Will block if no character is available, from stdio library. The default stdin is the debug serial port.

Returns
Character value (int) from stdin.
See also
charavail(), dataavail(), peek(), read(), ReadWithTimeout()

◆ haserror()

int haserror ( int fd)

#include <iosys.h>

Check if a file descriptor has an error.

Parameters
fdFile 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 )

#include <iosys.h>

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 ioctlOptions.

Parameters
fdThe file descriptor number. The three options are stdin (0), stdout (1), and stderr (2).
cmdThe ioctl command options are ioctlCmdFlags and the bit of the associated options as defined by ioctlOptions.
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
#define IOCTL_SET
Set an option.
Definition iosys.h:666
#define IOCTL_CLR
Clear an option.
Definition iosys.h:667
#define IOCTL_RX_PROCESS_EDITS
When set, process backspace and do simple line editing.
Definition iosys.h:655
int ioctl(int fd, int cmd)
This function controls the selection of input/output control options for stdio: stdin = 0,...
#define IOCTL_RX_CHANGE_CRLF
When set, received \r\n get turned into \n
Definition iosys.h:654
#define IOCTL_ALL_OPTIONS
When set, turns on all options.
Definition iosys.h:658
See also
ReplaceStdio()

◆ peek()

int peek ( int fd,
char * c )

#include <iosys.h>

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.

Parameters
fdFile descriptor
*cPointer to the read destination character string
Returns
See also
TCP Socket Status, close(), read(), PeekWithTimeout(), ReadWithTimeout(), write()

◆ PeekWithTimeout()

int PeekWithTimeout ( int fd,
char * c,
unsigned long timeout )

#include <iosys.h>

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.

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
*cA pointer to the read destination
timeoutThe number if time ticks to wait for at least 1 byte of data
Returns
See also
TCP Socket Status, close(), peek(), read(), ReadWithTimeout(), write()

◆ read()

int read ( int fd,
char * buf,
int nbytes )

#include <iosys.h>

Read data from a file descriptor (fd).

This function will block forever until at least one byte is available to be read from the input buffer of the specified file descriptor. To wait for a period of time if no data is immediately available in the buffer, please see ReadWithTimeout()

File descriptors include: TCP, UDP, Serial and Extra File Descriptors (EFD). EFDs can be used for custom purposes, such as reading/writing to buffers, or any periperal custom to your application.

The function will return the number of bytes read, or a negative number if there is an error condition. The error value depends on the type of file descriptor, such as TCP or Serial:

Parameters
fdThe file descriptor number.
*bufPointer to the read data destination.
nbytesMaximum number of bytes to read.
Returns
See also
TCP Socket Status, close(), peek(), PeekWithTimeout(), ReadWithTimeout(), ReadAllWithTimeout(), readall(), write()

◆ readall()

int readall ( int fd,
char * buf,
int nbytes )

#include <iosys.h>

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.

Parameters
fdFile descriptor
*bufPointer to the read destination buffer
nbytesNumber of bytes to read
Returns
See also
close(), peek(), read(), PeekWithTimeout(), ReadWithTimeout(), ReadAllWithTimeout(), write()

◆ ReadAllWithTickTimeout()

int ReadAllWithTickTimeout ( int fd,
char * buf,
int nbytes,
TickTimeout & timeout )

#include <iosys.h>

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.

This function can be used to read from stdio, TCP sockets, or Serial ports. This function will block until on of the following conditions occurs:

  • The requested number of bytes have been read.
  • The timeout expires. The number of bytes read are returned, and buf contains the data.
  • An error occurs on the file descripor, such as a TCP socet error.
Note
The return value must be checked to verify the number of bytes read and that a timeout or error did not occur.
Parameters
fdThe file descriptor number
*bufA pointer to the read destination
nbytesNumber of bytes to read
timeoutA reference to the timeout value of type TickTimeout.
Returns
See also
close(), peek(), read(), PeekWithTimeout(), ReadWithTimeout(), ReadAllWithTimeout(), readall(), write()

◆ ReadAllWithTimeout()

int ReadAllWithTimeout ( int fd,
char * buf,
int nbytes,
unsigned long timeout )

#include <iosys.h>

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.

This function can be used to read from stdio, TCP sockets, or Serial ports. This function will block until on of the following conditions occurs:

  • The requested number of bytes have been read.
  • The timeout expires. The number of bytes read are returned, and buf contains the data.
  • An error occurs on the file descripor, such as a TCP socet error.
Note
The return value must be checked to verify the number of bytes read and that a timeout or error did not occur.
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
Returns
See also
close(), peek(), read(), PeekWithTimeout(), ReadWithTimeout(), ReadAllWithTickTimeout(), ReadWithTickTimeout(), readall(), write()

◆ ReadWithTickTimeout()

int ReadWithTickTimeout ( int fd,
char * buf,
int nbytes,
TickTimeout & timeout )

#include <iosys.h>

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.

Note
This function operates like the read function in that it reads all available bytes up to the maximum and returns. The addition of a timeout does not cause the function to block until the specified maximum number of bytes are 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.
When using with a TCP socket, you may want to use the SockReadWithTimeout() function, which returns additional values related to network connections.
Parameters
fdThe file descriptor number.
*bufA pointer to the read destination.
nbytesMaximum number of bytes to read.
timeoutA reference to the timeout value of type TickTimeout.
Returns
See also
close(), peek(), read(), PeekWithTimeout(), ReadWithTimeout(), ReadAllWithTimeout(), readall(), SockReadWithTimeout(), write()

◆ ReadWithTimeout()

int ReadWithTimeout ( int fd,
char * buf,
int nbytes,
unsigned long timeout )

#include <iosys.h>

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.

Note
This function operates like the read function in that it reads all available bytes up to the maximum and returns. The addition of a timeout does not cause the function to block until the specified maximum number of bytes are 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.
When using with a TCP socket, you may want to use the SockReadWithTimeout() function, which returns additional values related to network connections.
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.
Returns
See also
close(), peek(), read(), PeekWithTimeout(), ReadWithTickTimeout(), ReadAllWithTimeout(), readall(), SockReadWithTimeout(), write()

◆ RegisterFDCallBack()

void RegisterFDCallBack ( int fd,
FDCallBack * fp,
void * pData )

#include <iosys.h>

Register a callback function to receive notification when an FD state changes. Register a NULL fp to remove the notification.

Parameters
fdThe file descriptor number
*fpThe function pointer to call back
*pDataA void * passed to the callback function, can be used for any purpose, such as object references
See also
FDChangeType, FDCCallBack

◆ ReplaceStdio()

int ReplaceStdio ( int stdio_fd,
int new_fd )

#include <iosys.h>

Maps stdio to any file descriptor (fd).

If the file descriptor generates an error (such as 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 a 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. 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 )

#include <iosys.h>

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.

The most common use for this function is to monitor multiple serial and/or TCP file descriptors at one time to read incoming data. For example, an application could use a single RTOS task and a select() to process incoming data on multiple TCP sockets at one time, instead of using multiple tasks or looping through each fd sequentially.

The file descriptors of interest are specified with file descriptor sets (fds) for read, write and error conditions. select() will block until one of the fd conditions are true, or the specified timeout occurs (a value of 0 blocks forever). For example, if the readfds is used for multiple TCP sockets, select() will return if data is available to read on one or more of them. The application would then use macros such as FD_ISSET() to handle reading the data.

Note
A timeout value can be used to cause select() to return periodically for any type of processing an application would like to do in the event no activity is occurring on the fd sets.
Parameters
nfdsThe number of file descriptors to examine (This parameter is currently ignored)
*readfdsPointer to the fd_set to select for read events, or null if no read events are to be monitored. It is modified on exit to reflect the read availability of the selected fds in the set.
*writefdsPointer to the fd_set to select for write availability events, or null if no events are to be monitored. If non-null, it is modified on exit to reflect the write availability of the selected fds in the set.
*errorfdsPointer to the fd_set to select for error events, or null if no error events are to be monitored. It is modified on exit to reflect the error state of the selected fds in the set.
timeoutThe number of system time ticks to wait before timing out if no events occurred in the selected fd sets. Note: The TICKS_PER_SECOND multiplier should be used to specify the timeout in seconds. For example, TICKS_PER_SECOND * 5 to specify a timeout of 5 seconds.
Return values
0Timeout occurred
>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 )

#include <iosys.h>

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.

Note
The function will block until at least 1 byte is written, but will not write all requested bytes if there is not enough space in the write buffer. The return value must always be checked to verify the number of bytes written.
Parameters
fdFile descriptor
*bufPointer to the buffer to write
nbytesMaximum number of bytes to write
Returns
See also
close(), peek(), read(), PeekWithTimeout(), ReadWithTimeout(), writestring(), writeall()

◆ writeall()

int writeall ( int fd,
const char * buf,
int nbytes = 0 )

#include <iosys.h>

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.

Note
The function will block until at least 1 byte is written, but will not write all requested bytes if there is not enough space in the write buffer. The return value must always be checked to verify the number of bytes written.
Parameters
fdFile descriptor
*bufPointer to the buffer to write
nbytesMaximum number of bytes to write
Returns
See also
close(), peek(), read(), PeekWithTimeout(), ReadWithTimeout(), write(), writestring()

◆ writeavail()

int writeavail ( int fd)

#include <iosys.h>

Check the specified file descriptor to determine data can be written.

Parameters
fdFile descriptor number
Return values
1Data can be written
0Data cannot be written, such as when an output buffer if full
See also
dataavail(), charavail(), haserror()

◆ writestring()

int writestring ( int fd,
const char * str )

#include <iosys.h>

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.

Note
The function will block until at least 1 byte is written, but will not write all requested bytes if there is not enough space in the write buffer. The return value must always be checked to verify the number of bytes written.
Parameters
fdFile descriptor
*strPointer to the null terminated string to write
Returns
See also
close(), peek(), read(), PeekWithTimeout(), ReadWithTimeout(), write(), writeall()

◆ ZeroWaitSelect()

int ZeroWaitSelect ( int nfds,
fd_set * readfds,
fd_set * writefds,
fd_set * errorfds )

#include <iosys.h>

Returns whether events have occurred on one or more I/O resources associated with a set of file descriptors (fds), and returns immediately.

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.
*errorfdsA pointer 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
select(), FD_ZERO(), FD_CLR(), FD_SET(), FD_ISSET()