On Sun, 27-Oct-2002 at 09:12:33 -0800, David Nicholas Kayal wrote: > I'm looking for a 5 volt signal. > > I have wires plugged into pins 2 and 25 of the parallel port. > > I have written a small program: > > #include <stdio.h> > #include <dev/ppbus/ppi.h> > #include <dev/ppbus/ppbconf.h> > > int main() > { > int fd; > while(1) > { > ioctl(fd, PPISDATA, 255); > } > } >
I had at least one machine where I had to drive the STROBE signal to actually get the data appear on the bus. The program attached below did the trick. It does a little bit more so here is a quick explanation: I wanted to physically push the RESET button of another machine (running Windoze, btw. :-)). To make things a bit more robust I used all 8 lines of data which are attached to a HC 688 (iirc) whose second 8 bit input is hardwired to the value 0x5A. Its output drives an optocoupler whose output is connected to the RESET connector of the Windoze box. The power was supplied by all output capable lines of the parallel port (8 data, strobe, some control lines) which are all connected via diodes and a resistor to a capacitor. The program first drives the 8 databits high to charge the capacitor for 5 seconds. It then puts the 0x5A word on the wire for one second. This is when the HC 688's output goes high and drives the optocoupler to reset the windoze box. If you look at the program you'll find that every dataoutput is surrounded by the apprpropriate STROBE action. Hth, -Andre
#include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <err.h> #include <sysexits.h> #include <dev/ppbus/ppi.h> #include <dev/ppbus/ppbconf.h> int Fd; void send( u_int8_t byte ) { u_int8_t myc, tmp; printf( "Sending %02X\n", byte ); if( ioctl( Fd, PPIGCTRL, &myc ) == -1 ) // save old control err( EX_IOERR, "save control" ); myc &= ~STROBE & ~PCD; // strobe high tmp = myc; if( ioctl( Fd, PPISCTRL, &tmp )== -1 ) err( EX_IOERR, "set control" ); if( ioctl( Fd, PPISDATA, &byte ) == 1 ) // set my code err( EX_IOERR, "set data" ); tmp = myc | STROBE; // strobe low if( ioctl( Fd, PPISCTRL, &tmp )== -1 ) err( EX_IOERR, "set control" ); tmp = myc; if( ioctl( Fd, PPISCTRL, &tmp )== -1 ) // strobe high err( EX_IOERR, "set control" ); } int main( int argc, const char* argv[] ) { if( (Fd = open( "/dev/ppi0", O_RDWR)) <= 0 ) err( EX_IOERR, "open /dev/ppi0" ); send( 0xFF ); // charge C sleep( 5 ); send( 0x5A ); // send code sleep( 1 ); send( 0xFF ); // disable code return( 0 ); }