./lptloop Couldn't get the port at 378
./lptloop Couldn't get the port at 378
I am building a simple circuit I trying to control from the
parallel port using linux gcc.
I get the following error. I don't understand what I need to
do to get my code to work from a non root user.
Any hint would be appreciated.
./lptloop Couldn't get the port at 378
[code]
// lptloop
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/io.h>
//#include </usr/include/sys/io.h>
#define base 0x378 /* printer port base address */
#define value 255 /* numeric value to send to printer port */
#define value0 0 /* numeric value to send to printer port */
#define value1 1 /* numeric value to send to printer port */
#define value2 2 /* numeric value to send to printer port */
#define value3 4 /* numeric value to send to printer port */
#define value4 8 /* numeric value to send to printer port */
#define value5 16 /* numeric value to send to printer port */
#define value6 32 /* numeric value to send to printer port */
#define value7 64 /* numeric value to send to printer port */
#define value8 128 /* numeric value to send to printer port */
main(int argc, char **argv)
{
int i,p;
if (ioperm(base,1,1))
fprintf(stderr, "Couldn't get the port at %x\n", base), exit(1);
outb(value0, base);//clear printer port
for (p = 0;p < 1000;p++){
outb(value0, base);
sleep(1);
outb(value1, base);
sleep(1);
outb(value2, base);
sleep(1);
outb(value3, base);
sleep(1);
outb(value4, base);
sleep(1);
outb(value5, base);
sleep(1);
outb(value6, base);
sleep(1);
outb(value7, base);
sleep(1);
outb(value8, base);
sleep(1);
}
//outb(value0, base);
}
|