45 #include <visp3/core/vpConfig.h> 46 #include <visp3/core/vpDebug.h> 48 #if defined VISP_HAVE_PARPORT 54 #include <visp3/io/vpParallelPort.h> 55 #include <visp3/io/vpParseArgv.h> 58 #define GETOPTARGS "d:h" 69 void usage(
const char *name,
const char *badparam,
unsigned char &data)
72 Send a data to the parallel port.\n\ 75 %s [-d <data>] [-h]\n\ 81 Data to send to the parallel port.\n\ 82 Value should be in [0:255].\n\ 85 Print the help.\n\n", data);
88 fprintf(stderr,
"ERROR: \n");
89 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
104 bool getOptions(
int argc,
const char **argv,
unsigned char &data)
114 value = atoi(optarg);
115 if ((value < 0) || (value > 255)) {
116 usage(argv[0], optarg, data);
117 std::cerr <<
"ERROR: " << std::endl;
118 std::cerr <<
" Bad value \"-d " << optarg <<
"\"" << std::endl << std::endl;
121 data = (
unsigned char)value;
126 usage(argv[0], NULL, data);
131 usage(argv[0], optarg, data);
137 if ((c == 1) || (c == -1)) {
139 usage(argv[0], NULL, data);
140 std::cerr <<
"ERROR: " << std::endl;
141 std::cerr <<
" Bad argument " << optarg << std::endl << std::endl;
153 int main(
int argc,
const char **argv)
156 unsigned char data = 0;
159 if (getOptions(argc, argv, data) ==
false) {
166 printf(
"Send data \"%d\" to the parallel port\n", data);
172 printf(
"Can't open the parallel port\n");
175 printf(
"Can't close the parallel port\n");
179 std::cout <<
"An error occurs: " << e.
getMessage() << std::endl;
186 std::cout <<
"vpParallelPort class works only on unix..." << std::endl;
int getCode(void)
Send the object code.
error that can be emited by ViSP classes.
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
const char * getMessage(void) const
void sendData(unsigned char &data)
Error that can be emited by the vpParallelPort class and its derivates.
Parallel port management under unix.