<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>GNU CommonC++: serialecho.cpp</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.3 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul> </div> </div> <div class="contents"> <h1>serialecho.cpp</h1><div class="fragment"><pre class="fragment"><span class="comment">/**********************************************************************</span> <span class="comment"> * C/C++ Source: serialecho.cc</span> <span class="comment"> *</span> <span class="comment"> * Defines the methods for the SerialEcho class</span> <span class="comment"> *</span> <span class="comment"> * @author: Gary Lawrence Murphy <garym@canada.com></span> <span class="comment"> * Copyright: 2000 TeleDynamics Communications Inc (www.teledyn.com)</span> <span class="comment"> ********************************************************************</span> <span class="comment"> */</span> <span class="comment">// Copyright (C) 1999-2000 Teledynamics Communications Inc.</span> <span class="comment">//</span> <span class="comment">// This program is free software; you can redistribute it and/or modify</span> <span class="comment">// it under the terms of the GNU General Public License as published by</span> <span class="comment">// the Free Software Foundation; either version 2 of the License, or</span> <span class="comment">// (at your option) any later version.</span> <span class="comment">//</span> <span class="comment">// This program is distributed in the hope that it will be useful,</span> <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span> <span class="comment">// GNU General Public License for more details.</span> <span class="comment">//</span> <span class="comment">// You should have received a copy of the GNU General Public License</span> <span class="comment">// along with this program; if not, write to the Free Software</span> <span class="comment">// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.</span> <span class="preprocessor">#include "serialecho.h"</span> <span class="preprocessor">#ifndef WIN32</span> <span class="preprocessor"></span><span class="preprocessor">#include <cstdlib></span> <span class="preprocessor">#endif</span> <span class="preprocessor"></span> <span class="keyword">using namespace </span>std; SerialEcho::SerialEcho(<span class="keyword">const</span> <span class="keywordtype">char</span> *device, <span class="keywordtype">int</span> priority, <span class="keywordtype">int</span> stacksize) : TTYSession( device, priority, stacksize ) { cout << <span class="stringliteral">"Creating SerialEcho"</span> << endl; <span class="keywordflow">if</span> (!(*<span class="keyword">this</span>)) { <span class="keywordflow">throw</span> xError(); ::exit(1); } <span class="keywordflow">else</span> { cout << <span class="stringliteral">"modem ready"</span> << endl; } interactive(<span class="keyword">false</span>); <span class="keywordflow">if</span> (setSpeed(38400)) cout << getErrorString() << endl; <span class="keywordflow">if</span> (setCharBits(8)) cout << getErrorString() << endl; <span class="keywordflow">if</span> (setParity(Serial::parityNone)) cout << getErrorString() << endl; <span class="keywordflow">if</span> (setStopBits(1)) cout << getErrorString() << endl; <span class="keywordflow">if</span> (setFlowControl(Serial::flowHard)) cout << getErrorString() << endl; cout << <span class="stringliteral">"config done"</span> << endl; } <span class="keywordtype">void</span> SerialEcho::run() { <span class="keywordtype">char</span>* s = <span class="keyword">new</span> <span class="keywordtype">char</span>[getBufferSize()]; cout << <span class="stringliteral">"start monitor"</span> << endl; <span class="keywordflow">while</span> (s[0] != <span class="charliteral">'X'</span>) { <span class="keywordflow">while</span> (isPending(Serial::pendingInput)) { cout.put( TTYStream::get() ); } sleep(500); } cout << <span class="stringliteral">"end of monitor"</span> << endl; <span class="keyword">delete</span> [] s; exit(); } </pre></div> </div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Fri Mar 12 10:07:38 2010 for GNU CommonC++ by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> </body> </html>