# HG changeset patch # User František Kučera # Date 1496581062 -7200 # Node ID 896eca3d40d8a53cf5c1d130ae718a7d9e3f542c # Parent b54d76467040d3f537403d6bb13569daee85d5f5 lpt-signal-generator: první verze diff -r b54d76467040 -r 896eca3d40d8 c++/lpt-signal-generator/lpt.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c++/lpt-signal-generator/lpt.cpp Sun Jun 04 14:57:42 2017 +0200 @@ -0,0 +1,57 @@ +/** + * LPT signal generator + * Copyright © 2017 František Kučera (frantovo.cz) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include + +using namespace std; + +// g++ lpt.cpp && ./a.out + +int main() { + cout << "LPT!" << endl; + + //int addr = 0x378; // parport0 + + int addr = 0xe400; // parport1 + + //int addr = 0x278; + + //int addr = 0xc800; + + + if (ioperm(addr,1,1)) { fprintf(stderr, "Access denied to %x\n", addr), exit(1); } + + + for (int i = 0; i < 30; i++) { + cout << "cyklus" << endl; + usleep(100*1000); + outb(0b11111111, addr); + usleep(10*1000); + outb(0b00000000, addr); + } + + + cout << "hotovo" << endl; + + +}