Portál AbcLinuxu, 10. května 2025 06:20
#include<stdio.h< #include<sys/io.h< #include<unistd.h< #include<sys/perm.h< #include<stdlib.h< #include<stdio.h< #include<errno.h< #include<time.h< #include<string.h< #include<error.h< #define BASEPORT 0x378 void openio() { int r; r = iopl(3); if (r){ printf("iopl() error %d (%s)\n", errno, strerror(errno)); exit(-1); } } int main(int argc, char **argv) { openio(); while (1) { outb(255, BASEPORT); printf ("dioda sviti\n"); sleep(1); outb(0, BASEPORT); printf ("dioda nesviti\n"); sleep(1); } return 0; }... ale má své velké nevýhody. Proces musí běžet jako root a vůbec technika přímého přístupu na porty je velmi ošemetná a "nesystémová". Předtím musíš dát z jádra pryč moduly, které již paralelní port obsluhují.
#include<stdio.h> #include<sys/io.h> #include<unistd.h> #include<sys/perm.h> #include<stdlib.h> #include<stdio.h> #include<errno.h> #include<time.h> #include<string.h> #include<error.h> #define BASEPORT 0x378 void openio() { int r; r = iopl(3); if (r){ printf("iopl() error %d (%s)\n", errno, strerror(errno)); exit(-1); } } int main(int argc, char **argv) { openio(); while (1) { outb(255, BASEPORT); printf ("dioda sviti\n"); sleep(1); outb(0, BASEPORT); printf ("dioda nesviti\n"); sleep(1); } return 0; }
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.