48 #include <visp/vpConfig.h>
49 #include <visp/vpDebug.h>
51 #if defined VISP_HAVE_PARPORT
57 #include <visp/vpParallelPort.h>
58 #include <visp/vpParseArgv.h>
61 #define GETOPTARGS "d:h"
72 void usage(
const char *name,
const char *badparam,
unsigned char &data)
75 Send a data to the parallel port.\n\
78 %s [-d <data>] [-h]\n\
84 Data to send to the parallel port.\n\
85 Value should be in [0:255].\n\
92 fprintf(stderr,
"ERROR: \n" );
93 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
109 bool getOptions(
int argc,
const char **argv,
unsigned char &data)
119 value = atoi(optarg);
120 if ((value < 0) || (value > 255)) {
121 usage(argv[0], optarg, data);
122 std::cerr <<
"ERROR: " << std::endl;
123 std::cerr <<
" Bad value \"-d " << optarg <<
"\""
124 << std::endl << std::endl;
128 data = (
unsigned char) value;
132 case 'h': usage(argv[0], NULL, data);
return false;
break;
135 usage(argv[0], optarg, data);
return false;
break;
139 if ((c == 1) || (c == -1)) {
141 usage(argv[0], NULL, data);
142 std::cerr <<
"ERROR: " << std::endl;
143 std::cerr <<
" Bad argument " << optarg << std::endl << std::endl;
156 main(
int argc,
const char **argv)
159 unsigned char data = 0;
162 if (getOptions(argc, argv, data) ==
false) {
169 printf(
"Send data \"%d\" to the parallel port\n", data);
177 printf(
"Can't open the parallel port\n");
180 printf(
"Can't close the parallel port\n");
185 printf(
"An error occurs...\n");
193 vpTRACE(
"Sorry, for the moment, vpParallelPort class works only on unix...");
int getCode(void)
send the object code
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
void sendData(unsigned char &data)
Error that can be emited by the vpParallelPort class and its derivates.
Parallel port management under unix.