serialport.c File Reference


Detailed Description

serial port communications 'c' function library.

Author:
Glenn D. MacGougan (GDM)
Date:
2008-11-26
Since:
2008-11-26
"LICENSE INFORMATION"
Copyright (c) 2008, refer to 'author' doxygen tags
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file serialport.c.

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "serialport.h"

Go to the source code of this file.

Defines

#define SERIALPORT_SETUPCOMM_INTERNAL_BUFFER_SIZE   (8192)
 Internal buffer size used by the serial port. 8 KB should be plenty.

Functions

BOOL SERIALPORT_Initialize (SERIALPORT_structObject *serialport)
 Initialize a serial port 'object'. This does not open the serial port. Call this function after the declaration of the struct.
BOOL SERIALPORT_Open (SERIALPORT_structObject *serialport)
 
Returns:
TRUE if successful, FALSE otherwise.

BOOL SERIALPORT_Close (SERIALPORT_structObject *serialport)
 
Returns:
TRUE if successful, FALSE otherwise.

BOOL SERIALPORT_Read (SERIALPORT_structObject *serialport, unsigned char *buffer, const unsigned int bytesAvailableInBuffer, unsigned int *bytesRead)
BOOL SERIALPORT_Write (SERIALPORT_structObject *serialport, const unsigned char *buffer, const unsigned int numberOfBytesToWrite)
 
Returns:
TRUE if successful, FALSE otherwise.

BOOL SERIALPORT_WaitOnRingIndicatorEvent (SERIALPORT_structObject *serialport, unsigned short timeout_ms, BOOL *ring_detected)
 
Returns:
TRUE if successful, FALSE otherwise.


Define Documentation

#define SERIALPORT_SETUPCOMM_INTERNAL_BUFFER_SIZE   (8192)

Internal buffer size used by the serial port. 8 KB should be plenty.

Definition at line 42 of file serialport.c.


Function Documentation

BOOL SERIALPORT_Close ( SERIALPORT_structObject serialport  ) 

Returns:
TRUE if successful, FALSE otherwise.

Definition at line 244 of file serialport.c.

BOOL SERIALPORT_Initialize ( SERIALPORT_structObject serialport  ) 

Initialize a serial port 'object'. This does not open the serial port. Call this function after the declaration of the struct.

Returns:
TRUE if successful, FALSE otherwise.

Definition at line 50 of file serialport.c.

BOOL SERIALPORT_Open ( SERIALPORT_structObject serialport  ) 

Returns:
TRUE if successful, FALSE otherwise.

Definition at line 78 of file serialport.c.

BOOL SERIALPORT_Read ( SERIALPORT_structObject serialport,
unsigned char *  buffer,
const unsigned int  bytesAvailableInBuffer,
unsigned int *  bytesRead 
)

Returns:
TRUE if successful, FALSE otherwise.
Parameters:
serialport  The serial port 'object'.
buffer  A valid buffer in which to place data.
bytesAvailableInBuffer  The maximum number of bytes avaiable in the buffer.
bytesRead  The number of bytes read and stored in the buffer.

Definition at line 310 of file serialport.c.

BOOL SERIALPORT_WaitOnRingIndicatorEvent ( SERIALPORT_structObject serialport,
unsigned short  timeout_ms,
BOOL ring_detected 
)

Returns:
TRUE if successful, FALSE otherwise.

Parameters:
serialport  The serial port 'object'.
timeout_ms  Wait for up to this timeout value [ms].
ring_detected  A boolean to indicate if a ring signal was detected.

Definition at line 449 of file serialport.c.

BOOL SERIALPORT_Write ( SERIALPORT_structObject serialport,
const unsigned char *  buffer,
const unsigned int  numberOfBytesToWrite 
)

Returns:
TRUE if successful, FALSE otherwise.

Parameters:
serialport  The serial port 'object'.
buffer  A valid buffer containing the data to write.
numberOfBytesToWrite  The number of bytes to write.

Definition at line 361 of file serialport.c.

SourceForge.net Logo