1 /******************************************************************************
2 * to emulate the serial input and output of an 8051 controller *
3 * main.cc - the main stuff *
4 ******************************************************************************/
15 #if defined(HAVE_GETOPT_H)
20 #include "frontend.hh"
21 #include "posix_signal.hh"
28 void HandleSig(int info)
35 void PrintUsage(char *progname)
37 std::cout << "Usage: " << progname << " [-i <filename>] [-o <filename>] [-h]\n";
38 std::cout << "-i <filename>\t<filename> is the pipe to the controllers' serial input\n";
39 std::cout << "-o <filename>\t<filename> is the pipe to the controllers' serial output\n";
40 std::cout << "-h\t\tshow the help\n";
41 std::cout << "\nTim Hurman - t.hurman@virgin.net\n";
47 int main(int argc, char **argv)
49 char *string = new char[MAX_SIZ];
53 char *infile = DEF_INFILE;
54 char *outfile = DEF_OUTFILE;
56 // sort out any command line params
57 while ((c = getopt(argc, argv, "i:o:h")) != EOF)
69 std::cerr << "Invalid or unknown switch\n";
74 // was there a problem
78 // the main objects needed
79 FileIO *fobj = new FileIO(infile, outfile);
80 Viewer *view = new Viewer();
81 SigHandler *sig = new SigHandler();
83 // add a signal handler for ^C
84 sig->SetSignal(SIGINT, HandleSig);
86 // set the timeout for waiting for a char
89 string[0] = view->GetChInWin();
94 fobj->SendByte(string[0]);
96 if(fobj->RecvStr(string) > 0)
97 view->AddStrOutWin(string);