libserial  0.6.0rc3
SerialStream.h
Go to the documentation of this file.
1 /*
2  * Time-stamp: <2008-11-15 11:16:39 pagey>
3  *
4  * $Id: SerialStream.h,v 1.10 2005-10-01 21:24:21 crayzeewulf Exp $
5  *
6  *
7  */
8 #ifndef _SerialStream_h_
9 #define _SerialStream_h_
10 
11 #include <SerialStreamBuf.h>
12 #include <string>
13 #include <fstream>
14 
15 extern "C++"
16 {
17  namespace LibSerial
18  {
52  class SerialStream : public std::iostream
53  {
54  public:
55  /* ------------------------------------------------------------
56  * Public Static Members
57  * ------------------------------------------------------------
58  */
84  explicit SerialStream( const std::string fileName,
85  std::ios_base::openmode openMode =
86  std::ios::in|std::ios::out) ;
87 
98  SerialStream( const std::string fileName,
102  const short numOfStopBits = SerialStreamBuf::DEFAULT_NO_OF_STOP_BITS,
104 
110  explicit SerialStream() ;
111 
116  virtual ~SerialStream() ;
117 
118  /* -----------------------------------------------------------------
119  * Other Public Methods
120  * -----------------------------------------------------------------
121  */
126  void Open( const std::string fileName,
127  std::ios_base::openmode openMode =
128  std::ios_base::in | std::ios_base::out) ;
129 
134  void Close() ;
135 
139  const bool IsOpen() const ;
140 
145 
158 
163  void SetCharSize(const SerialStreamBuf::CharSizeEnum charSize ) ;
164 
170 
177  void SetNumOfStopBits(short numOfStopBits) ;
178 
183  const short NumOfStopBits() ;
184 
190  void SetParity(const SerialStreamBuf::ParityEnum parityType) ;
191 
198 
202  void
203  SetFlowControl(const SerialStreamBuf::FlowControlEnum flowControlType) ;
204 
209 
213  const short SetVMin( short vtime ) ;
214 
215 
221  const short VMin() ;
222 
226  const short SetVTime( short vtime ) ;
227 
233  const short VTime() ;
234 
235 
236  /* ------------------------------------------------------------
237  * Friends
238  * ------------------------------------------------------------
239  */
240  protected:
241  /* ------------------------------------------------------------
242  * Protected Data Members
243  * ------------------------------------------------------------
244  */
245  /* ------------------------------------------------------------
246  * Protected Methods
247  * ------------------------------------------------------------
248  */
249  private:
250  /* ------------------------------------------------------------
251  * Private Data Members
252  * ------------------------------------------------------------
253  */
254  //
255  // The copy constructor and the assignment operator are declared
256  // but never defined. This allows the compiler to catch any
257  // attempts to copy instances of this class.
258  //
259  SerialStream( const SerialStream& ) ;
260  SerialStream& operator=( const SerialStream& ) ;
261 
267 
268  /* ----------------------------------------------------------------
269  * Private Methods
270  * ----------------------------------------------------------------
271  */
272  /* Set the serial port to ignore the modem status lines. If the
273  specified boolean parameter is false then the meaning of
274  this function is reversed i.e. the serial port will start
275  using the modem status lines.
276 
277  @param ignore If true then the modem status lines will be
278  ignored otherwise they will be used during the
279  communication.
280 
281  */
282  //void IgnoreModemStatusLines(bool ignore=true) ;
283 
284  /* Enable the serial port receiver. This will allow us to read
285  data from the serial port.
286 
287  @param enable If true then the received will be
288  enabled. Otherwise it will be disabled.
289 
290  */
291  //void EnableReceiver(bool enable=true) ;
292 
293  } ; // class SerialStream
294 
295  } // namespace LibSerial
296 } // extern "C++"
297 #endif // #ifndef _SerialStream_h_
FlowControlEnum
The values of the flow control settings for a serial port.
static const ParityEnum DEFAULT_PARITY
The default parity setting.
CharSizeEnum
The allowed values of character sizes that can be used during the serial communication.
void SetBaudRate(SerialStreamBuf::BaudRateEnum baudRate)
Set the baud rate for serial communications.
const short NumOfStopBits()
Get the number of stop bits being used during serial communication.
void Open(const std::string fileName, std::ios_base::openmode openMode=std::ios_base::in|std::ios_base::out)
Open the serial port associated with the specified filename, and the specified mode, mode.
const SerialStreamBuf::BaudRateEnum BaudRate()
Get the current baud rate being used for serial communication.
const short VTime()
Get current timing of character buffer in 10th of a second.
const SerialStreamBuf::FlowControlEnum FlowControl()
Return the current flow control setting.
static const CharSizeEnum DEFAULT_CHAR_SIZE
The default value of the character size used during the serial communication.
static const FlowControlEnum DEFAULT_FLOW_CONTROL
The default flow control setting.
SerialStream & operator=(const SerialStream &)
void SetNumOfStopBits(short numOfStopBits)
Set the number of stop bits used during serial communication.
void SetParity(const SerialStreamBuf::ParityEnum parityType)
Set the parity for serial communication.
const short SetVMin(short vtime)
Set character buffer size.
const SerialStreamBuf::CharSizeEnum CharSize()
Get the character size being used for serial communication.
SerialStreamBuf * mIOBuffer
The SerialStreamBuf object that will be used by the stream to communicate with the serial port...
Definition: SerialStream.h:266
BaudRateEnum
The baud rates currently supported by the SUS-2 general terminal interface specification.
const short SetVTime(short vtime)
Set character buffer timing in 10th of a second.
SerialStream()
Create a new SerialStream object but do not open it.
ParityEnum
The allowed values of the parity associated with the serial port communications.
const SerialStreamBuf::ParityEnum Parity()
Get the current parity setting for the serial port.
A stream class for accessing serial ports on POSIX operating systems.
Definition: SerialStream.h:52
This is the streambuf subclass used by SerialStream.
virtual ~SerialStream()
The destructor.
const bool IsOpen() const
Returns true if the Stream is in a good open state, false otherwise.
const short VMin()
Get current size of character buffer.
void Close()
Close the serial port.
void SetCharSize(const SerialStreamBuf::CharSizeEnum charSize)
Set the character size associated with the serial port.
static const short DEFAULT_NO_OF_STOP_BITS
The default number of stop bits used.
static const BaudRateEnum DEFAULT_BAUD
The default value of the baud rate of the serial port.
void SetFlowControl(const SerialStreamBuf::FlowControlEnum flowControlType)
Use the specified flow control.