44 #include <visp3/core/vpConfig.h>
45 #include <visp3/core/vpDebug.h>
47 #if defined VISP_HAVE_PARPORT
53 #include <visp3/io/vpParallelPort.h>
54 #include <visp3/io/vpParseArgv.h>
57 #define GETOPTARGS "d:h"
68 void usage(
const char *name,
const char *badparam,
unsigned char &data)
71 Send a data to the parallel port.\n\
74 %s [-d <data>] [-h]\n\
80 Data to send to the parallel port.\n\
81 Value should be in [0:255].\n\
88 fprintf(stderr,
"ERROR: \n" );
89 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
105 bool getOptions(
int argc,
const char **argv,
unsigned char &data)
115 value = atoi(optarg);
116 if ((value < 0) || (value > 255)) {
117 usage(argv[0], optarg, data);
118 std::cerr <<
"ERROR: " << std::endl;
119 std::cerr <<
" Bad value \"-d " << optarg <<
"\""
120 << std::endl << std::endl;
124 data = (
unsigned char) value;
128 case 'h': usage(argv[0], NULL, data);
return false;
break;
131 usage(argv[0], optarg, data);
return false;
break;
135 if ((c == 1) || (c == -1)) {
137 usage(argv[0], NULL, data);
138 std::cerr <<
"ERROR: " << std::endl;
139 std::cerr <<
" Bad argument " << optarg << std::endl << std::endl;
152 main(
int argc,
const char **argv)
155 unsigned char data = 0;
158 if (getOptions(argc, argv, data) ==
false) {
165 printf(
"Send data \"%d\" to the parallel port\n", data);
173 printf(
"Can't open the parallel port\n");
176 printf(
"Can't close the parallel port\n");
181 printf(
"An error occurs...\n");
189 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.