1 /******************************************************************************
2 * to emulate the serial input and output of an 8051 controller *
3 * main.cc - the main stuff *
4 ******************************************************************************/
17 #if defined(HAVE_GETOPT_H)
22 #include "frontend.hh"
23 #include "posix_signal.hh"
30 void HandleSig(int info)
37 void PrintUsage(char *progname)
39 std::cout << "Usage: " << progname << " [-i <filename>] [-o <filename>] [-h]\n";
40 std::cout << "-i <filename>\t<filename> is the pipe to the controllers' serial input\n";
41 std::cout << "-o <filename>\t<filename> is the pipe to the controllers' serial output\n";
42 std::cout << "-h\t\tshow the help\n";
43 std::cout << "\nTim Hurman - t.hurman@virgin.net\n";
49 int main(int argc, char **argv)
51 char *string = new char[MAX_SIZ];
55 char *infile = DEF_INFILE;
56 char *outfile = DEF_OUTFILE;
58 // sort out any command line params
59 while ((c = getopt(argc, argv, "i:o:h")) != EOF)
71 std::cerr << "Invalid or unknown switch\n";
76 // was there a problem
80 // the main objects needed
81 FileIO *fobj = new FileIO(infile, outfile);
82 Viewer *view = new Viewer();
83 SigHandler *sig = new SigHandler();
85 // add a signal handler for ^C
86 sig->SetSignal(SIGINT, HandleSig);
88 // set the timeout for waiting for a char
91 string[0] = view->GetChInWin();
96 fobj->SendByte(string[0]);
98 if(fobj->RecvStr(string) > 0)
99 view->AddStrOutWin(string);