blob: e39bcd845addd0c3be013336b09b61d67d2867ef [file] [log] [blame]
Emeric Vigier2f625822012-08-06 11:09:52 -04001/**********************************************************************
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#ifndef WIN32
30#include <cstdlib>
31#endif
32
33int main(int argc, char **argv)
34{
35 cout << "Serial Echo to TCP Sessions" << endl;
36 SerialEcho *modem = NULL;
37 try {
38 modem = new SerialEcho("/dev/modem2");
39 } catch (SerialEcho::xError *e) {
40 cout << "Modem Error; aborting" << endl;
41 ::exit(1);
42 } catch (Serial *e) {
43 cout << "Serial Error: "
44 << modem->getErrorString()
45 << "; aborting"
46 << endl;
47 ::exit(1);
48 }
49
50 char* b = new char[modem->getBufferSize()];
51
52 cout << "Modem code:" << modem->start() << endl;
53
54 while (cin >> b, b[0]) {
55
56 *modem << b << "\r" << endl;
57
58 cout << "sent: " << b << endl;
59 memset( b, 0, sizeof(b));
60
61 }
62 cout << "fin" << endl;
63
64 delete [] b;
65
66 return 0;
67}
68
69/** 2000 by TeleDynamics Communications Inc - teledynamics@canada.com*/
70