From owner-freebsd-hackers Mon Nov 4 3:50:37 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 09AD337B401 for ; Mon, 4 Nov 2002 03:50:34 -0800 (PST) Received: from outside.albsmeier.net (outside.albsmeier.net [212.125.105.28]) by mx1.FreeBSD.org (Postfix) with ESMTP id 89C0F43E4A for ; Mon, 4 Nov 2002 03:50:32 -0800 (PST) (envelope-from andre@albsmeier.net) Received: from outside.albsmeier.net (uucp@localhost [127.0.0.1]) by outside.albsmeier.net (8.12.6/8.12.6) with ESMTP id gA4BoBxn099299; Mon, 4 Nov 2002 12:50:15 +0100 (CET) (envelope-from andre@albsmeier.net) Received: from schlappy.albsmeier.net (uucp@localhost) by outside.albsmeier.net (8.12.6/8.12.6/Submit) with ESMTP id gA4Bo79B099298; Mon, 4 Nov 2002 12:50:08 +0100 (CET) (envelope-from andre@albsmeier.net) Received: from schlappy.albsmeier.net (schlappy.albsmeier.net [127.0.0.1]) by schlappy.albsmeier.net (8.12.6/8.12.6) with ESMTP id gA3DWwdr001153; Sun, 3 Nov 2002 14:32:58 +0100 (CET) (envelope-from andre@schlappy.albsmeier.net) Received: (from andre@localhost) by schlappy.albsmeier.net (8.12.6/8.12.6/Submit) id gA3DWwpE001152; Sun, 3 Nov 2002 14:32:58 +0100 (CET) (envelope-from andre) Date: Sun, 3 Nov 2002 14:32:58 +0100 From: Andre Albsmeier To: David Nicholas Kayal Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: i am looking for a 5 volt signal Message-ID: <20021103143258.A1092@schlappy.albsmeier.net> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="G4iJoqBmSsgzjUCe" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: ; from davek@saturn5.com on Sun, Oct 27, 2002 at 09:12:33AM -0800 X-Echelon: Uzi, chain reaction, Pretoria, interception, Submarine Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --G4iJoqBmSsgzjUCe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 > #include > #include > > 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 --G4iJoqBmSsgzjUCe Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ppi.c" #include #include #include #include #include #include #include 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 ); } --G4iJoqBmSsgzjUCe-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message