Sophie

Sophie

distrib > Mandriva > current > i586 > by-pkgid > ed376d6842ea322c25405e7c23b3bc12 > files > 625

libcommoncpp-devel-1.8.0-5.1mdv2010.1.i586.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++: 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&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>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 &lt;garym@canada.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="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="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 &lt;&lt; <span class="stringliteral">&quot;Creating SerialEcho&quot;</span> &lt;&lt; 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 &lt;&lt; <span class="stringliteral">&quot;modem ready&quot;</span> &lt;&lt; endl;
  }

  interactive(<span class="keyword">false</span>);

  <span class="keywordflow">if</span> (setSpeed(38400)) cout &lt;&lt; getErrorString() &lt;&lt; endl;
  <span class="keywordflow">if</span> (setCharBits(8)) cout &lt;&lt; getErrorString() &lt;&lt; endl;
  <span class="keywordflow">if</span> (setParity(Serial::parityNone)) cout &lt;&lt; getErrorString() &lt;&lt; endl;
  <span class="keywordflow">if</span> (setStopBits(1)) cout &lt;&lt; getErrorString() &lt;&lt; endl;
  <span class="keywordflow">if</span> (setFlowControl(Serial::flowHard)) cout &lt;&lt; getErrorString() &lt;&lt; endl;

  cout &lt;&lt; <span class="stringliteral">&quot;config done&quot;</span> &lt;&lt; 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 &lt;&lt; <span class="stringliteral">&quot;start monitor&quot;</span> &lt;&lt; endl;

  <span class="keywordflow">while</span> (s[0] != <span class="charliteral">&#39;X&#39;</span>) {
        <span class="keywordflow">while</span> (isPending(Serial::pendingInput)) {
          cout.put( TTYStream::get() );
                }
        sleep(500);
  }

  cout &lt;&lt; <span class="stringliteral">&quot;end of monitor&quot;</span> &lt;&lt; endl;

  <span class="keyword">delete</span> [] s;

  exit();
}

</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&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>