[Linux-parport] ppdev apps compiled on 2.4 fail under 2.6
rtwas
rtwas at comcast.net
Fri Feb 24 06:00:14 EST 2006
Ajay Kumar wrote:
> Hi Robert,
>
> I have used 2.6.13 ppdev back some time. Had written a driver to
> support vendor card with one of the ports being pp and used the
> printing apps available.
>
> Currently i dont have the code or pointers to help you out but is
> there any issue with the driver u r using !!
>
> If struck at any specific point with parport, let me know. My
> knowledge too is limited :-) Will try to help u, if in my reach.
>
Thank you.
I've included the code I had been using successfully under 2.4 (rh9.0).
I've looked at "drv_generic_parport.c"
provided as a reference by Michael Reinelt. At first glance, I can't see
anything different, except the use of
signals. I'll also point out that my code fails under at least two
different distros:
Fedora 4
SuSE 10.0
So I don't think it's a config issue. I took a closer look at my code
operating under SuSE 10.0 thinking maybe
there was a conflicting demon like *CUPS* or something. I tried doing an
"PPEXCL" (a mode to the code listed here) and found I could'nt get a
"PPCLAIM" after that. I killed the CUPS demon and then was able to get a
an exclusive claim on the port. This did'nt change the result however,
-no io on the port-. Although I did notice what seemed to be some input
activity. It seems to behave as if buffered. Nothing conclusive though,
as I
could not get a repeatable behavior on multible bits of the *status*
register. I'll also point out these tests have
been carried out on multiple machines which *had* been runing rh9.0 and
which had seen successful operation
of the code included in this post.
Thanks for taking a look...
Robert W.
#include <linux/parport.h>
#include <linux/ppdev.h>
#include <fcntl.h>
//.............................................
// control:
// 7 6 5 4 3 2 1 0
// STROBE: -c0 x
// AUTOFD: -c1 x
// INIT: c2 x
// SELECT: -c3 x
// (irq en): x
// (dir): x
//
//.............................................
int fd; // file descriptor
//******************************************************************************
// initialize sppa system
//******************************************************************************
int
sppa_init()
{
extern int fd;
fd = open("/dev/parport0",O_RDWR);
if (fd == -1)
{
perror("open");
return(-1);
}
if (ioctl(fd,PPCLAIM))
{
perror("PPCLAIM");
close(fd);
return(-2);
}
return(0);
}
//******************************************************************************
//******************************************************************************
// write to out-port
//******************************************************************************
int
sppa_wport
(
unsigned char data
)
{
extern int fd;
unsigned char control;
control = 0x0f & (data ^ 0x0b);
if (ioctl(fd,PPWCONTROL, &control)) return(-1);
return(0);
}
//******************************************************************************
//******************************************************************************
// read from in-port
//******************************************************************************
int
sppa_rport
(
unsigned char * data
)
{
extern int fd;
unsigned char control;
if (ioctl(fd,PPRSTATUS, &control)) return(-1);;
// *data = 0xf & (control ^ 0x0b);
*data = 0xf & (control >> 3); // 112005
return(0);
}
//******************************************************************************
//******************************************************************************
//******************************************************************************
int
sppa_close()
{
extern int fd;
ioctl (fd, PPRELEASE);
close(fd);
return(0);
}
//******************************************************************************
More information about the Linux-parport
mailing list