X-Git-Url: http://git.jankratochvil.net/?p=lptgpib.git;a=blobdiff_plain;f=lptgpib.c;h=591d32ddb945762a3e3fec02f0e216d88d4bef51;hp=2a9f2445dfb4d0432bbb050466c0ceda97b58997;hb=1a6a6ca06d257752394dc9e3b82f2453f3f1aaaf;hpb=e5d37585de9699dbcf203ba49b5ff8a8e5c89ff8 diff --git a/lptgpib.c b/lptgpib.c index 2a9f244..591d32d 100644 --- a/lptgpib.c +++ b/lptgpib.c @@ -11,7 +11,7 @@ #include #include -#define DEBUG 3 /* 4 - all, 3 - data, */ +#define DEBUG 4 /* 4 - all, 3 - data, */ #if DEBUG > 3 #define DBG_low(...) { fprintf(stderr,__VA_ARGS__); fflush(stderr); } @@ -84,7 +84,10 @@ void sig_handler(int sig){ void lptgpib_init(int base){ lpt_base = base; - ioperm(lpt_base, 4, 1); + if (ioperm(lpt_base, 4, 1) != 0) { + fprintf(stderr,"Nejsou prava na port - musis byt root: %m\n"); + exit(1); + } /* set realtime priority and lock us in memory */ struct sched_param scp; @@ -143,7 +146,7 @@ void lptgpib_write_byte(char value, char flags){ BUSYWAIT(( tmp = get_control(), !(tmp & NDAC) || (tmp & NRFD) )) DBG_low("rfd+ndac, "); - put_data(value & ~(flags & EOI) ); /* put data */ + put_data(value | (flags & EOI) ); /* put data */ put_control( (flags & ATN) ); /* clear TRI */ put_control( DAV | (flags & ATN) ); /* set DAV*/ DBG_low("dav, ");