00001 /********************************************************************** 00002 * C/C++ Source: main.cc 00003 * 00004 * Test harness for the serialecho class 00005 * 00006 * @author: Gary Lawrence Murphy <garym@teledyn.com> 00007 * Copyright: 2000 TeleDynamics Communications Inc (www.teledyn.com) 00008 ******************************************************************** 00009 */ 00010 // Copyright (C) 1999-2000 Teledynamics Communications Inc. 00011 // 00012 // This program is free software; you can redistribute it and/or modify 00013 // it under the terms of the GNU General Public License as published by 00014 // the Free Software Foundation; either version 2 of the License, or 00015 // (at your option) any later version. 00016 // 00017 // This program is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 // GNU General Public License for more details. 00021 // 00022 // You should have received a copy of the GNU General Public License 00023 // along with this program; if not, write to the Free Software 00024 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00025 // 00026 // Created 2000/10/14 10:56:35 EDT by garym@teledyn.com 00027 00028 #include "serialecho.h" 00029 00030 int main(int argc, char **argv) 00031 { 00032 cout << "Serial Echo to TCP Sessions" << endl; 00033 SerialEcho *modem = NULL; 00034 try { 00035 modem = new SerialEcho("/dev/modem2"); 00036 } catch (SerialEcho::xError *e) { 00037 cout << "Modem Error; aborting" << endl; 00038 ::exit(1); 00039 } catch (Serial *e) { 00040 cout << "Serial Error: " 00041 << modem->getErrorString() 00042 << "; aborting" 00043 << endl; 00044 ::exit(1); 00045 } 00046 00047 char* b = new char[modem->getBufferSize()]; 00048 00049 cout << "Modem code:" << modem->start() << endl; 00050 00051 while (cin >> b, b[0]) { 00052 00053 *modem << b << "\r" << endl; 00054 00055 cout << "sent: " << b << endl; 00056 memset( b, 0, sizeof(b)); 00057 00058 } 00059 cout << "fin" << endl; 00060 00061 delete [] b; 00062 00063 return 0; 00064 } 00065