[Linux-parport] libieee1284: can open parport but can't claim it

Klaas Hartmann kha59 at student.canterbury.ac.nz
Sat Oct 7 09:01:34 EDT 2006


Hi there,

I'm quite new to the world of parallel ports and linux. I'm making a logic 
analyser using the parallel port and my web searches seem to suggest that 
libieee1284 is a convenient way of accessing the pins on the parallel port 
directly.

I have however run into some trouble, I can successfully open the port using 
ieee1284_open but can't perform any operations on it (they all fail with 
E1284_INVALIDPORT). Subsequently I tried to use ieee1284_claim instead and 
this also fails with E1284_INVALIDPORT. (judging by the ieee1284 source

I have attempted to ensure that nothing else is using 0x378. I have done rmmod 
lp.  The permissions on /dev/parport0 are set to rw.  I have also tried 
disabling various combinations of parport_pc and ppdev and parport but to no 
avail. I know the parallel port works because I've been using it to program 
pic18fs. Can anyone suggest something I may have missed?

I am running Suse 10.0, the test program that comes with ieee1284 gives:

parport0: 0x378
/dev/parport0
  RAW NIBBLE BYTE COMPAT ECPSWE EPP IRQ

and now for some dodgy source code that gives an idea of what I am initially 
trying to do:

#include <stdio.h>
#include <ieee1284.h>

int main (void)
{
	int cap;
	int state;
	int i;
	int output;

	struct parport_list pl;
	struct parport *myport;

	ieee1284_find_ports (&pl, 0);

	myport = 0;
	for (i = 0; i < pl.portc; i++)
	{
		if (pl.portv[i]->base_addr == 0x378)
			myport = pl.portv[i];
	}

	if (myport == 0)
	{
		printf("Could not find port\n");
		return -1;
	}

//Check it picks the right port (it does)
printf("|%s|,|%#lx|,|%#lx|,|%s|\n",myport->name,myport->base_addr,myport->hiba
se_addr,myport->filename);

//the open returns without an error
//	state = ieee1284_open(myport,0,&cap);
//claim gives a E1284_INVALIDPORT error
	state = ieee1284_claim(myport);

	if (state)
	{
		printf("Could not open port\n");
		return -1;
	}

//We only get to here if we used open, in which case the following two ieee 
callse both give E1284_INVALIDPORT
	state = ieee1284_data_dir(myport,255);
	printf("State: |%d|\n", state);

	output = ieee1284_read_data(myport);
	printf("Data: |%d|\n", output);


	ieee1284_release(myport);

	if (state)
	{
		printf("Could not close port\n");
		return -1;
	}

	printf("Success\n");
	return 0;
}

Thanks a lot for your time !!!!!





More information about the Linux-parport mailing list