Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
212 dhylands 1
/****************************************************************************
2
*
3
*     Copyright (c) 2003 Dave Hylands
4
*           All Rights Reserved
5
*
6
*   Permission is granted to any individual or institution to use, copy, or
7
*   redistribute this software so long as it is not sold for profit, and that
8
*   this copyright notice is retained.
9
*
10
****************************************************************************/
11
/**
12
*
13
*   @file   SerialComm.h
14
*
15
*   @brief  Implements the abstract communications device using a serial port.
16
*
17
****************************************************************************/
18
/**
19
*  @defgroup    SerialComm  Serial Communications Device
20
*  @ingroup     CommDev
21
*
22
*  @brief   Implements the abstract communications device using a serial port.
23
*/
24
 
25
#if !defined( SERIALCOMM_H )
26
#define SERIALCOMM_H                   ///< Include Guard
27
 
28
// ---- Include Files -------------------------------------------------------
29
 
30
#include "CommDev.h"
31
 
32
#if !defined( _WINDOWS_ )
33
#   include <windows.h>
34
#endif
35
 
36
/**
37
 * @addtogroup SerialComm
38
 * @{
39
 */
40
 
41
//---------------------------------------------------------------------------
42
/**
43
*  The SerialComm class implements the serial communications device.
44
*/
45
 
46
class SerialComm : public CommDev
47
{
48
public:
49
 
50
    //------------------------------------------------------------------------
51
    // Default constructor
52
 
53
    SerialComm();
54
 
55
    //------------------------------------------------------------------------
56
    // Destructor
57
 
58
    virtual ~SerialComm();
59
 
60
    //------------------------------------------------------------------------
61
    // Aborts a read, if one is pending.
62
 
63
    virtual void AbortRead();
64
 
65
    //------------------------------------------------------------------------
66
    // Close a previsouly opened device.
67
 
68
    virtual void Close();
69
 
70
    //------------------------------------------------------------------------
71
    // Returns connection information (for display purposes)
72
 
73
    virtual const char *ConnectionInfo() const;
74
 
75
    //------------------------------------------------------------------------
76
    // Open a communication device. This provides a generic interface,
77
    // but a derived class may choose to provide a more specialized version.
78
 
79
    virtual bool Open( const char *openStr );
80
 
81
    //------------------------------------------------------------------------
82
    // Read data from the communication device.
83
 
84
    virtual bool Read( void *buf, size_t bufSize, size_t *bytesRead );
85
 
86
    //------------------------------------------------------------------------
87
    // Write data to the communication device.
88
 
89
    virtual bool Write( const void *buf, size_t bufSize, size_t *bytesWritten );
90
 
91
private:
92
 
93
    //------------------------------------------------------------------------
94
    // The copy constructor and assignment operator are not need for this
95
    // class so we declare them private and don't provide an implementation.
96
 
97
    SerialComm( const SerialComm & copy );
98
    SerialComm &operator =( const SerialComm &rhs );
99
 
100
    //------------------------------------------------------------------------
101
 
102
    HANDLE      m_serialHndl;       ///< Handle to open serial port
103
    OVERLAPPED  m_readOverlapped;   ///< Overlapped data for reading.
104
    OVERLAPPED  m_writeOverlapped;  ///< Overlapped data for writing.
105
    HANDLE      m_abortEvent;       ///< Set to get the read to break
106
 
107
    char        m_connectionInfo[ 20 ]; ///< Describes speed etc.
108
};
109
 
110
// ---- Inline Functions ----------------------------------------------------
111
 
112
/** @} */
113
 
114
#endif // SERIALCOMM_H
115