Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > media > main-updates > by-pkgid > f36f42783f75191f5f2d47f1e8c5504e > files > 626

lib64commoncpp-devel-1.8.0-5.1mdv2010.1.x86_64.rpm

<!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&nbsp;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 &lt;garym@teledyn.com&gt;</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 &quot;serialecho.h&quot;</span>
<span class="preprocessor">#ifndef WIN32</span>
<span class="preprocessor"></span><span class="preprocessor">#include &lt;cstdlib&gt;</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 &lt;&lt; <span class="stringliteral">&quot;Serial Echo to TCP Sessions&quot;</span> &lt;&lt; endl;
  SerialEcho *modem = NULL;
  <span class="keywordflow">try</span> {
        modem = <span class="keyword">new</span> SerialEcho(<span class="stringliteral">&quot;/dev/modem2&quot;</span>);
  } <span class="keywordflow">catch</span> (SerialEcho::xError *e) {
        cout &lt;&lt; <span class="stringliteral">&quot;Modem Error; aborting&quot;</span> &lt;&lt; endl;
        ::exit(1);
  } <span class="keywordflow">catch</span> (Serial *e) {
        cout &lt;&lt; <span class="stringliteral">&quot;Serial Error: &quot;</span>
                 &lt;&lt; modem-&gt;getErrorString()
                 &lt;&lt; <span class="stringliteral">&quot;; aborting&quot;</span>
                 &lt;&lt; endl;
        ::exit(1);
  }

  <span class="keywordtype">char</span>* b = <span class="keyword">new</span> <span class="keywordtype">char</span>[modem-&gt;getBufferSize()];

  cout &lt;&lt; <span class="stringliteral">&quot;Modem code:&quot;</span> &lt;&lt; modem-&gt;start() &lt;&lt; endl;

  <span class="keywordflow">while</span> (cin &gt;&gt; b, b[0]) {

        *modem &lt;&lt; b &lt;&lt; <span class="stringliteral">&quot;\r&quot;</span> &lt;&lt; endl;

        cout &lt;&lt; <span class="stringliteral">&quot;sent: &quot;</span> &lt;&lt; b &lt;&lt; endl;
        memset( b, 0, <span class="keyword">sizeof</span>(b));

  }
  cout &lt;&lt; <span class="stringliteral">&quot;fin&quot;</span> &lt;&lt; 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:57:38 2010 for GNU CommonC++ by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>