00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "serialecho.h"
00027
00028 using namespace std;
00029
00030 SerialEcho::SerialEcho(const char *device,
00031 int priority, int stacksize) :
00032 TTYSession( device, priority, stacksize ) {
00033
00034 cout << "Creating SerialEcho" << endl;
00035
00036 if (!(*this)) {
00037 throw xError();
00038 ::exit(1);
00039 } else {
00040 cout << "modem ready" << endl;
00041 }
00042
00043 interactive(false);
00044
00045 if (setSpeed(38400)) cout << getErrorString() << endl;
00046 if (setCharBits(8)) cout << getErrorString() << endl;
00047 if (setParity(Serial::parityNone)) cout << getErrorString() << endl;
00048 if (setStopBits(1)) cout << getErrorString() << endl;
00049 if (setFlowControl(Serial::flowHard)) cout << getErrorString() << endl;
00050
00051 cout << "config done" << endl;
00052 }
00053
00054 void SerialEcho::run() {
00055 char* s = new char[getBufferSize()];
00056
00057 cout << "start monitor" << endl;
00058
00059 while (s[0] != 'X') {
00060 while (isPending(Serial::pendingInput)) {
00061 cout.put( TTYStream::get() );
00062 }
00063 sleep(500);
00064 }
00065
00066 cout << "end of monitor" << endl;
00067
00068 delete [] s;
00069
00070 exit();
00071 }
00072