Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Feb 2001 20:14:42 -0500 (EST)
From:      Greg Hormann <ghormann@ns.kconline.com>
To:        Lucas Bergman <lucas@slb.to>
Cc:        questions@freebsd.org
Subject:   Re: Direct Access to Parallel Port
Message-ID:  <Pine.BSF.4.05.10102242006010.26696-100000@hormann.tzo.cc>
In-Reply-To: <20010223115544.B28130@billygoat.slb.to>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.10102242006010.26696-100000>