[Linux-parport] Reading the Data lines directly
j.m.curl at optusnet.com.au
Tue Jan 16 09:49:03 EST 2007
I've been successful at reading the Status Register, writing to the Control
Register and writing to the Data Register using the ioctl() functions PPWDATA,
I'm not using any IEEE modes or negotiation, I'd like to just monitor pins on
the inputs (5 inputs are not enough, which is why I'd also like to monitor the
However, when I use the function:
int ddr = 1;
ioctl(fd, PPDATADIR, &ddr);
it succeeds but it appears that the pins are still driving. Just for sanity, I
tried with ddr=0 and with the same results.
int dataregdir = -1;
handle->pfd = open(device, O_RDWR);
ioctl(handle->pfd, PPDATADIR, &dataregdir);
// Read the data
ioctl(handle->pfd, PPRSTATUS, &statreg);
ioctl(handle->pfd, PPRDATA, &datreg);
In addition I was changing the control lines periodically, and hard wired one of
the control lines to the status register. I could see the inputs on the status
register change as the control register was programmed (as expected).
By connecting the control register line now to the data register pins, I no
longer saw any changes (none either on the status register). It appears the
drive from the D-pin is overriding that of the C-pin (when I expected the D-pin
to be an input, it looks like an output still).
When I use the code to read the control register, it reports the DDR pin is zero
(D register is an output). This confuses me (it reads 0x00 or 0x0F). Writing
0x20 or 0x2f doesn't appear to fix the problem.
Any ideas how I can change the direction for the D-register, or any other
diagnostics to help get the result I want?
More information about the Linux-parport