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