<!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++: serialmain.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>serialmain.cpp</h1><div class="fragment"><pre class="fragment"><span class="comment">/**********************************************************************</span> <span class="comment"> * C/C++ Source: main.cc</span> <span class="comment"> *</span> <span class="comment"> * Test harness for the serialecho class</span> <span class="comment"> *</span> <span class="comment"> * @author: Gary Lawrence Murphy <garym@teledyn.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="comment">//</span> <span class="comment">// Created 2000/10/14 10:56:35 EDT by garym@teledyn.com</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="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv) { cout << <span class="stringliteral">"Serial Echo to TCP Sessions"</span> << endl; SerialEcho *modem = NULL; <span class="keywordflow">try</span> { modem = <span class="keyword">new</span> SerialEcho(<span class="stringliteral">"/dev/modem2"</span>); } <span class="keywordflow">catch</span> (SerialEcho::xError *e) { cout << <span class="stringliteral">"Modem Error; aborting"</span> << endl; ::exit(1); } <span class="keywordflow">catch</span> (Serial *e) { cout << <span class="stringliteral">"Serial Error: "</span> << modem->getErrorString() << <span class="stringliteral">"; aborting"</span> << endl; ::exit(1); } <span class="keywordtype">char</span>* b = <span class="keyword">new</span> <span class="keywordtype">char</span>[modem->getBufferSize()]; cout << <span class="stringliteral">"Modem code:"</span> << modem->start() << endl; <span class="keywordflow">while</span> (cin >> b, b[0]) { *modem << b << <span class="stringliteral">"\r"</span> << endl; cout << <span class="stringliteral">"sent: "</span> << b << endl; memset( b, 0, <span class="keyword">sizeof</span>(b)); } cout << <span class="stringliteral">"fin"</span> << endl; <span class="keyword">delete</span> [] b; <span class="keywordflow">return</span> 0; } </pre></div> </div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Fri Nov 12 09:55:46 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>