Hi, I'm putting together a power monitoring system
using the parallel port to select input channels
using the control pins and read in data through the
data pins. I need a little help understanding the
parallel port modes:
I've tried various modes, but I'm having problems
with the control pins. The SelectIn pin seems to
stay low in all modes I've tried except
IEEE1284_MODE_COMPAT. (I've lost the notes of the
modes I tried, but it includes PARPORT_MODE_PCSPP
PARPORT_MODE_TRISTATE and both PARPORT_MODE_ECP and
EPP. This is on RedHat 9 with the 2.4.20-19.9
kernel. Can anyone explain why this is, and what
modes I should use if I want to access control pin
directly?
At the same time the system I'm using to write
the software [1] will happily read from the data
pins in IEEE1284_MODE_COMPAT, but the machine it
will be run on [2] will not. Having said that,
it's running the 2.4.20-8 kernel, and so far I've
only tried using the executable compiled on the
development machine.
[1] Gigabyte GA-7DXP motherboard with on-board
parallel port.
[2] Old Pentium PCChips motherboard with onboard
parallel port. BIOS choice of Standard, EPP or
ECP.
This is the relevant bit of code for the control
pin problem. I've left out the error checking on
open () and ioctl () for clarity. device is
/dev/parport0 and permissions are set correctly.
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/ppdev.h>
#include <linux/parport.h>
int start_port ( char *device, int *fd_pnt ) {
int fd, mode, WRITE = 0, READ = 1;
*fd_pnt = open ( device, O_RDWR );
fd = *fd_pnt;
ioctl ( fd, PPCLAIM );
mode = IEEE1284_MODE_COMPAT;
ioctl ( fd, PPSETMODE, &mode );
ioctl ( fd, PPDATADIR, &READ );
return 0;
}
// Called immediately after start port, and given the
// returned fd.
int set_control ( int fd, int i ) {
int invert, output;
invert = (PARPORT_CONTROL_STROBE | PARPORT_CONTROL_AUTOFD
| PARPORT_CONTROL_SELECT );
output = ( invert ^ I );
ioctl ( fd, PPWCONTROL, &output )
return 0;
}
-- You have viruses, but I have resistance, and I am alive, and you-- --are dead - Ken MacLeod, The Star Fraction-- To unsubscribe, send mail to: linux-parport-request@torque.net -- -- with the single word "unsubscribe" in the body of the message. --
This archive was generated by hypermail 2b29 : Sat Aug 30 2003 - 21:45:11 EDT