1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/io.h>
#define ADRESSEBASE 0x378
#define TIME_MAX 2000
#define TIME_MIN 1000
#define DEBATEMENT 180
int ioperm();
int main()
{
setuid(0);
printf("demmarage\n");
openLPT();
int i=0;
for (i=0; i < 255; i++)
{
usleep(40000);
printf("signal envoye : %d\n", i);
act(i);
}
closeLPT();
return 0;
}
int act(int broche)
{
outb(broche, ADRESSEBASE);
}
int openLPT()
{
if (ioperm(0x378, 3, 1) < 0)
{
perror("ioperm");
exit (1);
}
else
{
outb( 0x2, ADRESSEBASE+2);
printf("innitialisation Ok\n");
}
int closeLPT()
{
if (ioperm(0x378, 3, 0) < 0)
{
perror("ioperm");
exit (1);
}
return 1;
} |
Partager