1 /******************************************************************************
2 * to emulate the serial input and output of an 8051 controller *
3 * main.cc - the main stuff *
4 ******************************************************************************/
15 #include "frontend.hh"
16 #include "posix_signal.hh"
23 void HandleSig(int info)
30 void PrintUsage(char *progname)
32 cout << "Usage: " << progname << " [-i <filename>] [-o <filename>] [-h]\n";
33 cout << "-i <filename>\t<filename> is the pipe to the controllers' serial input\n";
34 cout << "-o <filename>\t<filename> is the pipe to the controllers' serial output\n";
35 cout << "-h\t\tshow the help\n";
36 cout << "\nTim Hurman - t.hurman@virgin.net\n";
42 int main(int argc, char **argv)
44 char *string = new char[MAX_SIZ];
48 char *infile = DEF_INFILE;
49 char *outfile = DEF_OUTFILE;
51 // sort out any command line params
52 while ((c = getopt(argc, argv, "i:o:h")) != EOF)
64 cerr << "Invalid or unknown switch\n";
69 // was there a problem
73 // the main objects needed
74 FileIO *fobj = new FileIO(infile, outfile);
75 Viewer *view = new Viewer();
76 SigHandler *sig = new SigHandler();
78 // add a signal handler for ^C
79 sig->SetSignal(SIGINT, HandleSig);
81 // set the timeout for waiting for a char
84 string[0] = view->GetChInWin();
89 fobj->SendByte(string[0]);
91 if(fobj->RecvStr(string) > 0)
92 view->AddStrOutWin(string);