I haven't got my hardware interface working yet, so I don't really have a way of testing it.
I did find a library that should make it easier called PARAPIN. It can be compiled as a c library or a kernel module. At the moment, I'm using the C library version, because I know nothing about kernel programming. I've written a small implementation of the program below. The problem is, when I run the new program I've written it eats up the CPU.
Code:
#include <parapin.h>
#include "daemon.h"
int main(int argc, char* argv[])
{
initDaemon();
if(pin_init_user(LPT1))
{
exit(EXIT_FAILURE);
}
while (pin_is_set(LP_PIN11)){
// printf("Pin 11 is %s\n", pin_is_set(LP_PIN11) ? "on" : "off");
}
}
NB I've left out all the daemon initialisation code here. It's in the function initDaemon()
I understand that I'm basically running an infinite loop here, but is there any way to avoid it? I *think* that the kernel module version of PARAPIN might work better here, cause it can handle interrupts, but I don't really understand what they are, or how to compile a kernel module, or pretty much most of the help file...
With regards to the USB idea, it would be easier to code, but far harder to actually implement with respect to the hardware. As I see it, I would need some sort of IC to emit a series of pulses and decode them with the software because the USB protocol works on a series interface rather than parallel. With parallel port interfacing basically all you need to do it short two terminals together.