1 /******************************************************************************
2 * to emulate the serial input and output of an 8051 controller *
3 * main.cc - the main stuff *
4 ******************************************************************************/
15 #ifdef HAVE_GETOPT_H // fix of bug #533274
19 #include "frontend.hh"
20 #include "posix_signal.hh"
27 void HandleSig(int info)
34 void PrintUsage(char *progname)
36 cout << "Usage: " << progname << " [-i <filename>] [-o <filename>] [-h]\n";
37 cout << "-i <filename>\t<filename> is the pipe to the controllers' serial input\n";
38 cout << "-o <filename>\t<filename> is the pipe to the controllers' serial output\n";
39 cout << "-h\t\tshow the help\n";
40 cout << "\nTim Hurman - t.hurman@virgin.net\n";
46 int main(int argc, char **argv)
48 char *string = new char[MAX_SIZ];
52 char *infile = DEF_INFILE;
53 char *outfile = DEF_OUTFILE;
55 // sort out any command line params
56 while ((c = getopt(argc, argv, "i:o:h")) != EOF)
68 cerr << "Invalid or unknown switch\n";
73 // was there a problem
77 // the main objects needed
78 FileIO *fobj = new FileIO(infile, outfile);
79 Viewer *view = new Viewer();
80 SigHandler *sig = new SigHandler();
82 // add a signal handler for ^C
83 sig->SetSignal(SIGINT, HandleSig);
85 // set the timeout for waiting for a char
88 string[0] = view->GetChInWin();
93 fobj->SendByte(string[0]);
95 if(fobj->RecvStr(string) > 0)
96 view->AddStrOutWin(string);