SERIALPORT_structObject Struct Reference

#include <serialport.h>


Detailed Description

The serial port data container. i.e. The serial port 'object'.

An example method for the use of this object follows:

BOOL TestSerialPort()
{
  BOOL result;
  unsigned i;
  unsigned numBytesRead = 0;
  unsigned char buffer[8192]
  SERIALPORT_structObject port;
  result = SERIALPORT_Initialize( &port );

  port.port = 1; // COM1
  port.baudrate = SERIALPORT_BAUD_9600;
  port.parity = SERIALPORT_PARITY_NONE;
  port.databits = SERIALPORT_DATABITS_8;
  port.stopbits = SERIALPORT_STOPBITS_1;
  port.flowcontrol = SERIALPORT_FLOWCONTROL_NONE;
  port.timeout = 0;
  port.behaviour = SERIALPORT_BEHAVIOUR_RETURN_IMMEDIATELY;

  result = SERIALPORT_Open( &port );
  if( !result )
    return FALSE;

  for( i = 0; i < 100; i++ )
  {
    result = SERIALPORT_Read( &port, buffer, 8192, numBytesRead );
    if( !result )
      return FALSE; 
    if( numBytesRead > 0 )
      printf( "%s\n", buffer );
    Sleep(1);
  }

  sprintf( buffer, "Hello SERIALPORT\n" );

  for( i = 0; i < 100; i++ )
  {
    result = SERIALPORT_Write( &port, buffer, strlen( buffer ) );
    if( !result )
      return FALSE; 
    Sleep(1);
  }

  result = SERIALPORT_Close( &port );

  return TRUE;
}

Definition at line 214 of file serialport.h.


Data Fields

SERIALPORT_enumBaudRate baudrate
 The serial port baud rate [bits per second].
SERIALPORT_enumParity parity
 The serial port parity.
SERIALPORT_enumDataBits databits
 The serial port data bits.
SERIALPORT_enumStopBits stopbits
 The serial port stop bits.
SERIALPORT_enumFlowControl flowcontrol
 The serial port flow control setting.
BOOL isPortOpen
 A boolean to indicate if the serial port is open.
unsigned short port
 The serial port number. A value greater than 0.
unsigned int timeout
 The serial port timeout value [ms]. Not used if behaviour == SERIALPORT_BEHAVIOUR_RETURN_IMMEDIATELY.
HANDLE handle
 A windows handle for the serial port.
SERIALPORT_enumBehaviour behaviour
 The serial port behaviour during read operationss.
DCB control_setting
 The control settings for a windows serial communications device. Do not alter the members of the control settings. This is done internally only.

Field Documentation

SERIALPORT_enumBaudRate SERIALPORT_structObject::baudrate

The serial port baud rate [bits per second].

Definition at line 216 of file serialport.h.

SERIALPORT_enumParity SERIALPORT_structObject::parity

The serial port parity.

Definition at line 217 of file serialport.h.

SERIALPORT_enumDataBits SERIALPORT_structObject::databits

The serial port data bits.

Definition at line 218 of file serialport.h.

SERIALPORT_enumStopBits SERIALPORT_structObject::stopbits

The serial port stop bits.

Definition at line 219 of file serialport.h.

SERIALPORT_enumFlowControl SERIALPORT_structObject::flowcontrol

The serial port flow control setting.

Definition at line 220 of file serialport.h.

BOOL SERIALPORT_structObject::isPortOpen

A boolean to indicate if the serial port is open.

Definition at line 222 of file serialport.h.

unsigned short SERIALPORT_structObject::port

The serial port number. A value greater than 0.

Definition at line 224 of file serialport.h.

unsigned int SERIALPORT_structObject::timeout

The serial port timeout value [ms]. Not used if behaviour == SERIALPORT_BEHAVIOUR_RETURN_IMMEDIATELY.

Definition at line 225 of file serialport.h.

HANDLE SERIALPORT_structObject::handle

A windows handle for the serial port.

Definition at line 227 of file serialport.h.

SERIALPORT_enumBehaviour SERIALPORT_structObject::behaviour

The serial port behaviour during read operationss.

Definition at line 229 of file serialport.h.

DCB SERIALPORT_structObject::control_setting

The control settings for a windows serial communications device. Do not alter the members of the control settings. This is done internally only.

Definition at line 232 of file serialport.h.


The documentation for this struct was generated from the following file:
SourceForge.net Logo