Commit 03e8aa2e authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

timeout command line parameter

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 2800
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 03c1bb68
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: DL1direct.cc,v 1.7 2008-12-22 11:54:26 tforb Exp $
* $Id: DL1direct.cc,v 1.8 2009-01-16 22:30:38 tforb Exp $
* \author Thomas Forbriger
* \date 24/11/2008
*
......@@ -30,6 +30,7 @@
*
* REVISIONS and CHANGES
* - 24/11/2008 V1.0 Thomas Forbriger
* - 16/01/2009 V1.1 add timeout commandline parameter
*
* ============================================================================
*/
......@@ -40,9 +41,9 @@
* Execute \code DL1direct -help\endcode to obtain a program description.
*/
#define DL1DIRECT_VERSION \
"DL1DIRECT V1.0 directly send command to DL1 and receive the response"
"DL1DIRECT V1.1 directly send command to DL1 and receive the response"
#define DL1DIRECT_CVSID \
"$Id: DL1direct.cc,v 1.7 2008-12-22 11:54:26 tforb Exp $"
"$Id: DL1direct.cc,v 1.8 2009-01-16 22:30:38 tforb Exp $"
#include <iostream>
#include <string>
......@@ -58,6 +59,7 @@ using std::endl;
struct Options {
bool verbose, debug;
std::string device;
int timeout;
};
int main(int iargc, char* argv[])
......@@ -68,6 +70,7 @@ int main(int iargc, char* argv[])
{
DL1DIRECT_VERSION "\n"
"usage: DL1direct [-v] [-D] [-d device] command [argument]" "\n"
" [-timeout d]" "\n"
" or: DL1direct --help|-h" "\n"
};
......@@ -79,9 +82,10 @@ int main(int iargc, char* argv[])
"This program submits exactly one command to the DL1 data logger" "\n"
"and presents the response on standard output." "\n"
"\n"
"-v verbose mode" "\n"
"-D debug mode" "\n"
"-d dev device file dev" "\n"
"-v verbose mode" "\n"
"-D debug mode" "\n"
"-d dev device file dev" "\n"
"-timeout d set timeout to \"d\" seconds" "\n"
"\n"
"supported commands are:" "\n"
"HH display commands accepted by DL1" "\n"
......@@ -107,9 +111,11 @@ int main(int iargc, char* argv[])
// 1: verbose mode
{"v",arg_no,"-"},
// 2: device file name
{"d",arg_yes,"/dev/ttyS0"},
{"device",arg_yes,"/dev/ttyS0"},
// 3: debug mode
{"D",arg_no,"-"},
// 4: debug mode
{"timeout",arg_yes,"2"},
{NULL}
};
......@@ -135,11 +141,13 @@ int main(int iargc, char* argv[])
opt.verbose=cmdline.optset(1);
opt.device=cmdline.string_arg(2);
opt.debug=cmdline.optset(3);
opt.timeout=cmdline.int_arg(4);
if (opt.verbose) { cout << "open port " << opt.device << endl; }
dl1::DL1 port(opt.device, opt.debug);
int timeout=2;
int timeout=opt.timeout;
if (opt.verbose) { cout << "timeout: " << timeout << "seconds" << endl; }
DL1_assert(cmdline.extra(), "ERROR: missing command");
std::string command=cmdline.next();
......@@ -168,7 +176,7 @@ int main(int iargc, char* argv[])
<< date.timestring() << endl; }
port.sendds(date);
// increase timeout
timeout=20;
timeout=opt.timeout*10;
if (opt.verbose) { cout << "increased timeout value to "
<< timeout << " seconds" << endl; }
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment