.TH "LibSerial::SerialStream" 3 "Mon Sep 14 2015" "Version 0.6.0rc3" "libserial" \" -*- nroff -*- .ad l .nh .SH NAME LibSerial::SerialStream \- A stream class for accessing serial ports on POSIX operating systems\&. .SH SYNOPSIS .br .PP .PP \fC#include \fP .PP Inherits iostream\&. .SS "Public Member Functions" .in +1c .ti -1c .RI "\fBSerialStream\fP (const std::string fileName, std::ios_base::openmode openMode=std::ios::in|std::ios::out)" .br .RI "\fIThis constructor takes a filename and an openmode to construct a \fBSerialStream\fP object\&. \fP" .ti -1c .RI "\fBSerialStream\fP (const std::string fileName, const \fBSerialStreamBuf::BaudRateEnum\fP baudRate=\fBSerialStreamBuf::DEFAULT_BAUD\fP, const \fBSerialStreamBuf::CharSizeEnum\fP charSize=\fBSerialStreamBuf::DEFAULT_CHAR_SIZE\fP, const \fBSerialStreamBuf::ParityEnum\fP parityType=\fBSerialStreamBuf::DEFAULT_PARITY\fP, const short numOfStopBits=\fBSerialStreamBuf::DEFAULT_NO_OF_STOP_BITS\fP, const \fBSerialStreamBuf::FlowControlEnum\fP flowControlType=\fBSerialStreamBuf::DEFAULT_FLOW_CONTROL\fP)" .br .RI "\fIConstructor that allows one to create a \fBSerialStream\fP instance and also initialize the corresponding serial port with the specified parameters\&. \fP" .ti -1c .RI "\fBSerialStream\fP ()" .br .RI "\fICreate a new \fBSerialStream\fP object but do not open it\&. \fP" .ti -1c .RI "virtual \fB~SerialStream\fP ()" .br .RI "\fIThe destructor\&. \fP" .ti -1c .RI "void \fBOpen\fP (const std::string fileName, std::ios_base::openmode openMode=std::ios_base::in|std::ios_base::out)" .br .RI "\fIOpen the serial port associated with the specified filename, and the specified mode, mode\&. \fP" .ti -1c .RI "void \fBClose\fP ()" .br .RI "\fIClose the serial port\&. \fP" .ti -1c .RI "const bool \fBIsOpen\fP () const " .br .RI "\fIReturns true if the Stream is in a good open state, false otherwise\&. \fP" .ti -1c .RI "void \fBSetBaudRate\fP (\fBSerialStreamBuf::BaudRateEnum\fP baudRate)" .br .RI "\fISet the baud rate for serial communications\&. \fP" .ti -1c .RI "const \fBSerialStreamBuf::BaudRateEnum\fP \fBBaudRate\fP ()" .br .RI "\fIGet the current baud rate being used for serial communication\&. \fP" .ti -1c .RI "void \fBSetCharSize\fP (const \fBSerialStreamBuf::CharSizeEnum\fP charSize)" .br .RI "\fISet the character size associated with the serial port\&. \fP" .ti -1c .RI "const \fBSerialStreamBuf::CharSizeEnum\fP \fBCharSize\fP ()" .br .RI "\fIGet the character size being used for serial communication\&. \fP" .ti -1c .RI "void \fBSetNumOfStopBits\fP (short numOfStopBits)" .br .RI "\fISet the number of stop bits used during serial communication\&. \fP" .ti -1c .RI "const short \fBNumOfStopBits\fP ()" .br .RI "\fIGet the number of stop bits being used during serial communication\&. \fP" .ti -1c .RI "void \fBSetParity\fP (const \fBSerialStreamBuf::ParityEnum\fP parityType)" .br .RI "\fISet the parity for serial communication\&. \fP" .ti -1c .RI "const \fBSerialStreamBuf::ParityEnum\fP \fBParity\fP ()" .br .RI "\fIGet the current parity setting for the serial port\&. \fP" .ti -1c .RI "void \fBSetFlowControl\fP (const \fBSerialStreamBuf::FlowControlEnum\fP flowControlType)" .br .RI "\fIUse the specified flow control\&. \fP" .ti -1c .RI "const \fBSerialStreamBuf::FlowControlEnum\fP \fBFlowControl\fP ()" .br .RI "\fIReturn the current flow control setting\&. \fP" .ti -1c .RI "const short \fBSetVMin\fP (short vtime)" .br .RI "\fISet character buffer size\&. \fP" .ti -1c .RI "const short \fBVMin\fP ()" .br .RI "\fIGet current size of character buffer\&. \fP" .ti -1c .RI "const short \fBSetVTime\fP (short vtime)" .br .RI "\fISet character buffer timing in 10th of a second\&. \fP" .ti -1c .RI "const short \fBVTime\fP ()" .br .RI "\fIGet current timing of character buffer in 10th of a second\&. \fP" .in -1c .SS "Private Member Functions" .in +1c .ti -1c .RI "\fBSerialStream\fP (const \fBSerialStream\fP &)" .br .ti -1c .RI "\fBSerialStream\fP & \fBoperator=\fP (const \fBSerialStream\fP &)" .br .in -1c .SS "Private Attributes" .in +1c .ti -1c .RI "\fBSerialStreamBuf\fP * \fBmIOBuffer\fP" .br .RI "\fIThe \fBSerialStreamBuf\fP object that will be used by the stream to communicate with the serial port\&. \fP" .in -1c .SH "Detailed Description" .PP A stream class for accessing serial ports on POSIX operating systems\&. A lot of the functionality of this class has been obtained by looking at the code of libserial package by Linas Vepstas (linas@linas.org) and the excellent document on serial programming by Michael R\&. Sweet\&. This document can be found at \fChttp://www\&.easysw\&.com/~mike/serial/serial\&.html\fP\&. The libserial package can be found at \fChttp://www\&.linas\&.org/serial/\fP\&. This class allows one to set various parameters of a serial port and then access it like a simple fstream\&. In fact, that is exactly what it does\&. It sets the parameters of the serial port by maintaining a file descriptor for the port and uses the basic_fstream functions for the IO\&. We have not implemented any file locking yet but it will be added soon\&. .PP Make sure you read the documentation of the standard fstream template before using this class because most of the functionality is inherited from fstream\&. Also a lot of information about the various system calls used in the implementation can also be found in the Single Unix Specification (Version 2)\&. A copy of this document can be obtained from \fChttp://www\&.UNIX-systems\&.org/\fP\&. We will refer to this document as SUS-2\&. .PP \fBAuthor:\fP .RS 4 .RE .PP \fBAuthor\fP .RS 4 crayzeewulf .RE .PP \fCManish P\&. Pagey\fP .PP \fBVersion:\fP .RS 4 $Id: \fBSerialStream\&.h\fP,v 1\&.5 2004/05/06 18:32:02 crayzeewulf .RE .PP .PP Definition at line 52 of file SerialStream\&.h\&. .SH "Constructor & Destructor Documentation" .PP .SS "LibSerial::SerialStream::SerialStream (const std::string fileName, std::ios_base::openmode openMode = \fCstd::ios::in|std::ios::out\fP)\fC [explicit]\fP" .PP This constructor takes a filename and an openmode to construct a \fBSerialStream\fP object\&. This results in a call to basic_fstream::open(s,mode)\&. This is the only way to contruct an object of this class\&. We have to enforce this instead of providing a default constructor because we want to get a file descriptor whenever the basic_fstream::open() function is called\&. However, this function is not made virtual in the STL hence it is probably not very safe to overload it\&. We may decide to overload it later but the users of this class will have to make sure that this class is not used as an fstream class\&. The \fBSerialStream\fP will be in the 'open' state (same state as after calling the \fBOpen()\fP method) after calling this constructor\&. .PP If the constructor has problems opening the serial port or getting the file-descriptor for the port, it will set the failbit for the stream\&. So, one must make sure that the stream is in a good state before using it for any further I/O operations\&. .PP \fBParameters:\fP .RS 4 \fIfileName\fP The filename of the serial port\&. .br \fIopenMode\fP The openmode for the serial port file\&. .RE .PP .SS "LibSerial::SerialStream::SerialStream (const std::string fileName, const \fBSerialStreamBuf::BaudRateEnum\fP baudRate = \fC\fBSerialStreamBuf::DEFAULT_BAUD\fP\fP, const \fBSerialStreamBuf::CharSizeEnum\fP charSize = \fC\fBSerialStreamBuf::DEFAULT_CHAR_SIZE\fP\fP, const \fBSerialStreamBuf::ParityEnum\fP parityType = \fC\fBSerialStreamBuf::DEFAULT_PARITY\fP\fP, const short numOfStopBits = \fC\fBSerialStreamBuf::DEFAULT_NO_OF_STOP_BITS\fP\fP, const \fBSerialStreamBuf::FlowControlEnum\fP flowControlType = \fC\fBSerialStreamBuf::DEFAULT_FLOW_CONTROL\fP\fP)" .PP Constructor that allows one to create a \fBSerialStream\fP instance and also initialize the corresponding serial port with the specified parameters\&. This was suggested by Witek Adamus (wit3k)\&. .PP See https://sourceforge.net/tracker/index.php?func=detail&aid=2137885&group_id=9432&atid=359432 .PP :TODO: Add documentation for all parameters here\&. .SS "LibSerial::SerialStream::SerialStream ()\fC [explicit]\fP" .PP Create a new \fBSerialStream\fP object but do not open it\&. The \fBOpen()\fP method will need to be called explicitly on the object to communicate with the serial port\&. .SS "virtual LibSerial::SerialStream::~SerialStream ()\fC [virtual]\fP" .PP The destructor\&. It closes the stream associated with mFileDescriptor\&. The rest is done by the fstream destructor\&. .SS "LibSerial::SerialStream::SerialStream (const \fBSerialStream\fP &)\fC [private]\fP" .SH "Member Function Documentation" .PP .SS "const \fBSerialStreamBuf::BaudRateEnum\fP LibSerial::SerialStream::BaudRate ()" .PP Get the current baud rate being used for serial communication\&. This routine queries the serial port for its current settings and returns the baud rate that is being used by the serial port\&. .PP \fBReturns:\fP .RS 4 The current baud rate for the serial port\&. Note: this is not a constant function because it checks to see that it is dealing with a \fBSerialStream\fP with a non-null buffer\&. If the buffer is null, it attempts to set the state of the stream accordingly\&. .RE .PP .SS "const \fBSerialStreamBuf::CharSizeEnum\fP LibSerial::SerialStream::CharSize ()" .PP Get the character size being used for serial communication\&. .PP \fBReturns:\fP .RS 4 The current character size\&. .RE .PP .SS "void LibSerial::SerialStream::Close ()" .PP Close the serial port\&. No communications can occur with the serial port after calling this routine\&. .SS "const \fBSerialStreamBuf::FlowControlEnum\fP LibSerial::SerialStream::FlowControl ()" .PP Return the current flow control setting\&. .SS "const bool LibSerial::SerialStream::IsOpen () const" .PP Returns true if the Stream is in a good open state, false otherwise\&. .SS "const short LibSerial::SerialStream::NumOfStopBits ()" .PP Get the number of stop bits being used during serial communication\&. .PP \fBReturns:\fP .RS 4 The number of stop bits\&. .RE .PP .SS "void LibSerial::SerialStream::Open (const std::string fileName, std::ios_base::openmode openMode = \fCstd::ios_base::in|std::ios_base::out\fP)" .PP Open the serial port associated with the specified filename, and the specified mode, mode\&. .SS "\fBSerialStream\fP& LibSerial::SerialStream::operator= (const \fBSerialStream\fP &)\fC [private]\fP" .SS "const \fBSerialStreamBuf::ParityEnum\fP LibSerial::SerialStream::Parity ()" .PP Get the current parity setting for the serial port\&. .PP \fBReturns:\fP .RS 4 The parity setting for the serial port\&. .RE .PP .SS "void LibSerial::SerialStream::SetBaudRate (\fBSerialStreamBuf::BaudRateEnum\fP baudRate)" .PP Set the baud rate for serial communications\&. .SS "void LibSerial::SerialStream::SetCharSize (const \fBSerialStreamBuf::CharSizeEnum\fP charSize)" .PP Set the character size associated with the serial port\&. .PP \fBParameters:\fP .RS 4 \fIsize\fP The character size will be set to this value\&. .RE .PP .SS "void LibSerial::SerialStream::SetFlowControl (const \fBSerialStreamBuf::FlowControlEnum\fP flowControlType)" .PP Use the specified flow control\&. .SS "void LibSerial::SerialStream::SetNumOfStopBits (short numOfStopBits)" .PP Set the number of stop bits used during serial communication\&. The only valid values are 1 and 2\&. .PP \fBParameters:\fP .RS 4 \fIstop_bits\fP The number of stop bits\&. (1 or 2)\&. .RE .PP .SS "void LibSerial::SerialStream::SetParity (const \fBSerialStreamBuf::ParityEnum\fP parityType)" .PP Set the parity for serial communication\&. .PP \fBParameters:\fP .RS 4 \fIparity\fP The parity value\&. .RE .PP .SS "const short LibSerial::SerialStream::SetVMin (short vtime)" .PP Set character buffer size\&. .SS "const short LibSerial::SerialStream::SetVTime (short vtime)" .PP Set character buffer timing in 10th of a second\&. .SS "const short LibSerial::SerialStream::VMin ()" .PP Get current size of character buffer\&. Look \fChere\fP for more documentation about VTIME and VMIN\&. .SS "const short LibSerial::SerialStream::VTime ()" .PP Get current timing of character buffer in 10th of a second\&. Look \fChere\fP for more documentation about VTIME and VMIN\&. .SH "Member Data Documentation" .PP .SS "\fBSerialStreamBuf\fP* LibSerial::SerialStream::mIOBuffer\fC [private]\fP" .PP The \fBSerialStreamBuf\fP object that will be used by the stream to communicate with the serial port\&. .PP Definition at line 266 of file SerialStream\&.h\&. .SH "Author" .PP Generated automatically by Doxygen for libserial from the source code\&.