CSerial Class Reference

Send and receive data over a COM port. More...

#include <Serial.h>

List of all members.

Public Member Functions

BOOL Open (const char *port, int nBaud=9600)
 Open connection to serial port.
BOOL Close (void)
 Close the serial connection.
int ReadData (void *, int)
 Read data from COM port.
int SendData (const unsigned char *, int)
 Send data to the COM port.
int ReadDataWaiting (void)
 Check for data waiting to be read.
BOOL IsOpened (void)

Protected Member Functions

BOOL WriteCommByte (unsigned char)

Protected Attributes

HANDLE m_hIDComDev
OVERLAPPED m_OverlappedRead
OVERLAPPED m_OverlappedWrite
BOOL m_bOpened


Detailed Description

Send and receive data over a COM port.

This is adapted from http://www.codeguru.com/cpp/i-n/network/serialcommunications/article.php/c2503

This version Copyright (c) 2008 by James Bremner All rights reserved.

Use license: Modified from standard BSD license.

Redistribution and use in source and binary forms are permitted provided that the above copyright notice and this paragraph are duplicated in all such forms and that any documentation, advertising materials, Web server pages, and other materials related to such distribution and use acknowledge that the software was developed by James Bremner. The name "James Bremner" may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.


Member Function Documentation

BOOL CSerial::Close void   ) 
 

Close the serial connection.

Returns:
always true

BOOL CSerial::Open const char *  szPort,
int  nBaud = 9600
 

Open connection to serial port.

Parameters:
[in] port name of port, e.g COM1
[in] nBaud port speed, e.g 9800
Returns:
TRUE if successful

int CSerial::ReadData void *  buffer,
int  limit
 

Read data from COM port.

Parameters:
[in] buffer pointer to location to store data
[in] limit maximum number of bytes to read
Returns:
0 if error

int CSerial::ReadDataWaiting void   ) 
 

Check for data waiting to be read.

Returns:
the number of bytes waiting to be read

int CSerial::SendData const unsigned char *  buffer,
int  size
 

Send data to the COM port.

Parameters:
[in] buffer pointer to data to be written
[in] size number of bytes to write
Returns:
0 if error


The documentation for this class was generated from the following files:
Generated on Tue Sep 9 11:15:36 2008 by  doxygen 1.4.6-NO