RE: reading from parallel port

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



What exactly you want to do with this, as far as I understood from your mail, you just want to read the status register of parallel port whenever there is some change in it. If this is a problem, you can do the following thing. Take a small temporary buffer in driver, keep the last read status byte in this temporary buffer, so that you can compare it with the currently read status register contents.

On every read execute the following logic:

read_device(){
read the parallel port status register
if(content of status register == temporary buffer){
	put the process to sleep on a driver specific waiting queue
	read the parallel port status register once again
}
temporary buffer = contents of status register
return;
}


Interrupt handler will be something like following:

device_interrupt(){
if(content of status register != temporary buffer){
	wakeup sleeping processes from driver specific waiting queue
}
}

If I understood your problem properly, I think this should solve it.
Anybody if finds any problem with this logic, please come up. I would like to hear from experienced guys.

Regards,
Gaurav

 

-----Original Message-----
From: kernelnewbies-bounce@xxxxxxxxxxxx [mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf Of Hinko Kocevar
Sent: Tuesday, September 07, 2004 1:23 AM
To: kernelnewbies@xxxxxxxxxxxx
Subject: reading from parallel port

Hi,

I'm trying to reuse 'short' sample driver found in ldd2 that handles 
read/write on parallel port for my small app.

I've connected opto encoder to two status pins (select and paperOUT) on 
lpt port. With small & dumb userland app I'm able to select() and read() 
value from status port by opening /dev/short1 and reading one byte. What 
happens is that select() returns immediately giving me status register 
contents as fast as it can, producing big overhead. What I would like to 
see is that select() returns _only_ upon register content change 
(impacted by turning encoder knob).

Doing this kind of checking in userland hogs my cpu on 100%, so I guess 
solution lies in my drivers read() function.

Is this doable by simply checking new read value against one just read, 
and ignoring it if its the same, or is there some other 
mechanism/procedure that can be used?

thanx,
h

-- 
hinko <dot> kocevar <at> iskramedical <dot> si
Hinko Kocevar, developer
Iskra Medical d.o.o., Stegne 23, 1k LJ, SLO-EU

	"Aì rén"	|	[Analects XII:22]

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux