IGSTK
igstkSerialCommunicationForWindows.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkSerialCommunicationForWindows.h,v $
5  Language: C++
6  Date: $Date: 2008-02-11 01:41:51 $
7  Version: $Revision: 1.12 $
8 
9  Copyright (c) ISC Insight Software Consortium. All rights reserved.
10  See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 
18 #ifndef __igstkSerialCommunicationForWindows_h
19 #define __igstkSerialCommunicationForWindows_h
20 
21 #include <windows.h>
22 
24 
25 namespace igstk
26 {
27 
45 {
46 public:
47 
51 
52 public:
53 
56 
57 protected:
58 
60  typedef HANDLE HandleType;
61 
64 
67 
69  virtual ResultType InternalOpenPort( void );
70 
73  virtual ResultType InternalUpdateParameters( void );
74 
76  virtual ResultType InternalClosePort( void );
77 
79  virtual ResultType InternalSendBreak( void );
80 
82  virtual void InternalSleep( int milliseconds );
83 
85  virtual ResultType InternalPurgeBuffers( void );
86 
88  virtual ResultType InternalWrite( const char *message,
89  unsigned int numberOfBytes );
90 
92  virtual ResultType InternalRead( char *data, unsigned int numberOfBytes,
93  unsigned int &bytesRead );
94 
98  virtual ResultType InternalSetRTS(unsigned int signal);
99 
101  virtual ResultType InternalSetTimeout( unsigned int timeoutPeriod );
102 
104  virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const;
105 
106 private:
107 
108  unsigned int m_OldTimeoutPeriod;
109 
110  HandleType m_PortHandle; // com port handle
111 };
112 
113 } // end namespace igstk
114 
115 #endif // __igstkSerialCommunicationForWindows_h
virtual void InternalSleep(int milliseconds)
Sleep for the number of milliseconds specified.
virtual ResultType InternalClosePort(void)
Closes serial port.
virtual ResultType InternalRead(char *data, unsigned int numberOfBytes, unsigned int &bytesRead)
Read data.
This class implements Windows specific methods for 32-bit communication over a Serial Port(RS-232 con...
virtual ResultType InternalSendBreak(void)
Send a serial break.
#define igstkStandardClassTraitsMacro(classname, superclassname)
Convenience macro for traits of a non-templated class.
Definition: igstkMacros.h:275
virtual ResultType InternalOpenPort(void)
Opens serial port for communication;.
virtual void PrintSelf(std::ostream &os, itk::Indent indent) const
Print object information.
HANDLE HandleType
Macro with standard traits declarations.
Communication::ResultType ResultType
virtual ResultType InternalUpdateParameters(void)
Sets up communication on the open port as per the communication parameters.
virtual ResultType InternalWrite(const char *message, unsigned int numberOfBytes)
Write data.
virtual ResultType InternalSetTimeout(unsigned int timeoutPeriod)
Set the timeout.
virtual ResultType InternalPurgeBuffers(void)
Purge the input and output buffers.
virtual ResultType InternalSetRTS(unsigned int signal)
Set the RTS value 0 : Clear the RTS (request-to-send) signal 1 : Sends the RTS signal.
This class implements communication over a serial port via RS-232.