16 #include <dev/ppbus/ppi.h>
17 #include <dev/ppbus/ppbconf.h>
38 std::cerr <<
"parallel_read:" << std::endl;
39 std::cerr <<
" read data and/or status lines from the parallel port and write them to the standard output" << std::endl;
40 std::cerr <<
"syntax: parallel_read [-?|-h|--help] [-s|--status|-d|--data] > std_output" << std::endl;
41 std::cerr <<
" -d: return data line [default]" << std::endl;
42 std::cerr <<
" -s: return status line" << std::endl;
43 std::cerr <<
" example: a returned value of '1101'" << std::endl;
44 std::cerr <<
" means that data1, data3 and data4 are set to '1'" << std::endl;
45 std::cerr <<
"author: P.Smars, 2008-9" << std::endl;
46 std::cerr <<
"version: 2009-05-11" << std::endl;
61 int main(
int argc,
char *argv[] )
73 else if (args.OptionId() ==
OPT_DATA)
78 std::cerr <<
"Invalid argument: " << args.OptionText() << std::endl;
79 return error(args.LastError());
82 if (args.FileCount() != 0)
return error(-2);
83 int fd = open (
"/dev/ppi0", O_RDWR);
87 ioctl(
fd, PPIGDATA, &data );
96 ioctl(
fd, PPIGSTATUS, &status );
97 if (status & SELECT) std::cout << 1;
else std::cout << 0;
98 if (status & PERROR) std::cout << 1;
else std::cout << 0;
99 if (status & nBUSY) std::cout << 0;
else std::cout << 1;
100 if (status & nACK) std::cout << 1;
else std::cout << 0;
101 if (status & nFAULT) std::cout << 1;
else std::cout << 0;
103 std::cout << std::endl;
A cross-platform command line library which can parse almost any of the standard command line formats...
#define SO_END_OF_OPTIONS
this option definition must be the last entry in the table
#define CSimpleOpt
TCHAR version dependent on if _UNICODE is defined.
int main(int argc, char *argv[])
CSimpleOpt::SOption g_rgOptions[]