[C][PPDEV] read parallel port status
From: yvespiel (yvespielusenet_at_free.fr)
Date: 11/23/05
- Previous message: Eric: "Re: Request for Recomandation: Looking for a simple web based costumer relation software"
- Next in thread: yvespiel: "Re: [C][PPDEV] read parallel port status"
- Reply: yvespiel: "Re: [C][PPDEV] read parallel port status"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 23 Nov 2005 12:57:03 +0100
Hello,
I'm programming a library in C language in order to read parallel port
status.
I use the kernel module ppdev which allow this in userland.
This library is to be linked with Java through JNI.
Doc about PPDEV :
http://people.redhat.com/twaugh/parport/html/ppdev.html
http://people.redhat.com/twaugh/parport/html/x623.html
In ppdev programming interface, there is a IOCTL parameter, PPCLAIM.
IOCTL must be called with this parameter before I can use PPRSTATUS
which do what I want. With PPCLAIM, I must use PPRELEASE to release the
port.
My problem Is that I call PPCLAIM when I open the /dev/parportX ppdev
device file, and I call PPRELEASE just before I close it. But I see that
between the PPCLAIM call and the PPRELEASE one, I can send data to /dev/lpX.
So, now I use PPCLAIM and PPRELEASE just before and after each PPRSTATUS
call.
So I wonder if it good to CLAIM and RELEASE the port so often times (I
read the port status each 100ms) :
-----------------------------------------------------
// CLAIM the port
p.ioct = ioctl(p.fd , PPCLAIM);
if(p.ioct != 0){
printf("Erreur lors de la réclamation du port parallèle avant
l'écoute.\nioctl renvoie '%d'\n", p.ioct);
}
// READ the status
p.ioct = ioctl(p.fd, PPRSTATUS, &p.status);
if(p.ioct != 0){
printf("Erreur lors de la récupération du status du port
parallèle.\nioctl renvoie '%d'\n", p.ioct);
p.status = 0;
}
// RELEASE the port
p.ioct = ioctl(p.fd, PPRELEASE);
if(p.ioct != 0){
printf("Erreur lors de la libération du port parallèle après
l'écoute.\nioctl renvoie '%d'\n", p.ioct);
}
---------------------------------------------------------------
is it a good way (it solves my problem since I can send data now while
I'm listening port) CLAIM and RELEASE port so often ?
thanks :)
- Previous message: Eric: "Re: Request for Recomandation: Looking for a simple web based costumer relation software"
- Next in thread: yvespiel: "Re: [C][PPDEV] read parallel port status"
- Reply: yvespiel: "Re: [C][PPDEV] read parallel port status"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|