parint - A linux device driver used to timestamp a TTL signal on the parallel port. parint uses the parport interface.


Description

parint is a linux kernel module that uses the PC's parallel port to timestamp a 
TTL signal via an interrupt.  The driver's Interrupt Service Routine records 
the time an ACK signal occured.  I wrote this driver in order to timestamp 
a shutter TTL output from a camera we have. 

Documentation is mininal.  The driver is very simple, and the testpi user
program illustrates the driver's function. Using very basic 
device driver knowledge, you should be able to take this code and use it.

For novices, there are many tutorials on writing linux device driver 
using the PC's parallel port ... look for parport kernel modules.

Written by Tony Denault.


Making the driver & test code

To compile the driver modules:
   # make

To compile testpi and supporting library:
   > make -f makefile.app


How to load the module

Note, you may need to unload the lp modules so parint can get to the parallel port:
  # rmmod lp 

1. To make a /dev entry for parint:

   # mknod --mode=666 /dev/parint c 67 0

   Make a udev entry for CentOS 4.x:
		# mknod --mode=666 /etc/udev/devices/parint c 67 0
   
2. manual loading:
   # insmod parint.ko

3. manual unloading:
   # rmmod parint


manual installation 

This driver is could use some improvement in how it handles mknod, udev, and install.
But here is what I do:

1. copy parint.ko to /lib/modules//kernel/drivers

   cp parint.ko /lib/modules/`uname -r`/kernel/drivers/char

2. Add to /etc/rc.d/rc.local:

	rmmod lp
	mknod --mode=666 /dev/parint c 67 0
	insmod /lib/modules/`uname -r`/kernel/drivers/char/parint.ko


parint module source code


Makefile - Module makefile 
parint.c - parint.c 
parint.h - parint.h 


testpi


testpi is a user program used to test the driver. testpi demonstrates 
how to use the parint driver function calls. Here is the user code:

makefile.apps - makefile.apps 
parint_nice.c - nice wrapper for parint ioctl calls. 
testpi.c - testpi.c - user application to test parint

m -  command to make the module and testpi.

For testing, I connected pin 10(ACK) to pin 2 (data out). Then ran 2 copies of 
testpi.  testpi #1 used to "get.time", and the other generated pulses ("pulse").

Worst cast sample was 300 microseconds, while most in the 5-15 micorseconds range.
Seem details here: test1/index.html - XXX 


save/ - old versrion of the drvier.

save/101020
   Developed and tested using CentOS 4.6  ( kernel 2.6.9-78.0.17.EL )
   This version used inb()/outb() to talks to 0x378, the hardware register
	of the parallel port directly. Working in 2.6.9, but broken in 2.6.18.
	Seems like we are unable to access the parallel IO addresses in the 
	later kernels.