From owner-freebsd-questions Sat Feb 24 17:12:10 2001 Delivered-To: freebsd-questions@freebsd.org Received: from hormann.tzo.cc (cvg-65-27-148-213.cinci.rr.com [65.27.148.213]) by hub.freebsd.org (Postfix) with ESMTP id DDFF237B401 for ; Sat, 24 Feb 2001 17:12:07 -0800 (PST) (envelope-from ghormann@ns.kconline.com) Received: from localhost (ghormann@localhost) by hormann.tzo.cc (8.11.1/8.11.1) with ESMTP id f1P1G5v26743; Sat, 24 Feb 2001 20:16:05 -0500 (EST) (envelope-from ghormann@ns.kconline.com) X-Authentication-Warning: hormann.tzo.cc: ghormann owned process doing -bs Date: Sat, 24 Feb 2001 20:14:42 -0500 (EST) From: Greg Hormann X-Sender: ghormann@hormann.tzo.cc To: Lucas Bergman Cc: questions@freebsd.org Subject: Re: Direct Access to Parallel Port In-Reply-To: <20010223115544.B28130@billygoat.slb.to> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Fri, 23 Feb 2001, Lucas Bergman wrote: > > I need to control some solid state relays (SSRs) from my old P75. > > In the past, I've used dos, Qbasic, and Parallel port to control up > > to 8 SSRs. (Just by sending 0-255 to the correct I/O address, I can > > turn on/off pins 2-9.) > > > > Anyway, I'd like to convert this DOS box over to FreeBSD so that I > > can make changes remotely. How difficult would it be to send a byte > > out to the I/O address of the parallel Port on a FreeBSD box? > > Not difficult, if you know C. The "official" (and more Unixly > correct) way to do this is through the existing ppi interface; see > ppi(4). Be warned, though, that ioctl()'s are slow. If this is a > problem, you can always do stuff like Based on ppi(4), am I to assume the the fd passed to ioctl isn't used. If that is the case, how would multiple ports (lpt1, lpt2, lpt3) be controlled with this interface? > > void > port_out_byte(unsigned port, unsigned char byte) > { > asm volatile("outb %0,%1" : : "a"(byte), "id"((unsigned short)(port))); > } > > from a C program. Then `port_out_byte(0x378,0xa5)' would send the > byte 0xa5 to port 0x378. This seems like a simple solution except that my code resides in usermode (not kernel mode). Running this in user mode produces a Bus Error. Am I correct in assuming this would take a lot of work to build some type of kernel mode interface? Greg. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message