Sophie

Sophie

distrib > Mandriva > 2007.0 > i586 > by-pkgid > ad1ba1135a9c9eeffc2e538163e00373 > files > 867

libCommonC++2_1.4-devel-1.4.1-1mdv2007.0.i586.rpm

\section{serialmain.cpp}


\footnotesize\begin{verbatim}1 /**********************************************************************
2  * C/C++ Source: main.cc
3  *
4  * Test harness for the serialecho class
5  *
6  * @author:  Gary Lawrence Murphy <garym@teledyn.com>
7  * Copyright:  2000 TeleDynamics Communications Inc (www.teledyn.com)
8  ********************************************************************
9 */
10 // Copyright (C) 1999-2000 Teledynamics Communications Inc.
11 //  
12 // This program is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation; either version 2 of the License, or
15 // (at your option) any later version.
16 // 
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 // GNU General Public License for more details.
21 // 
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software 
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 //
26 // Created 2000/10/14 10:56:35 EDT by garym@teledyn.com
27 
28 #include "serialecho.h"
29 
30 int main(int argc, char **argv)
31 {
32   cout << "Serial Echo to TCP Sessions" << endl;
33   SerialEcho *modem = NULL;
34   try {
35     modem = new SerialEcho("/dev/modem2");
36   } catch (SerialEcho::xError *e) {
37     cout << "Modem Error; aborting" << endl;
38     ::exit(1);
39   } catch (Serial *e) {
40     cout << "Serial Error: " 
41          << modem->getErrorString() 
42          << "; aborting" 
43          << endl;
44     ::exit(1);
45   }
46 
47   char* b = new char[modem->getBufferSize()];
48 
49   cout << "Modem code:" << modem->start() << endl;
50 
51   while (cin >> b, b[0]) {
52 
53     *modem << b << "\r" << endl;
54 
55     cout << "sent: " << b << endl;
56     memset( b, 0, sizeof(b));
57 
58   }
59   cout << "fin" << endl;
60 
61   delete [] b;
62 
63   return 0;
64 }
65 
\end{verbatim}
\normalsize