Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Oct 2002 01:10:33 -0500
From:      Brian Dean <bsd@bsdhome.com>
To:        David Nicholas Kayal <davek@saturn5.com>
Cc:        freebsd-hackers@FreeBSD.org
Subject:   Re: Programming the Parallel Port using ppi.
Message-ID:  <20021028061033.GA65546@neutrino.bsdhome.com>
In-Reply-To: <Pine.BSF.4.44.0210271631090.1093-100000@blackbox.yayproductions.com>
References:  <Pine.BSF.4.44.0210271631090.1093-100000@blackbox.yayproductions.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On Sun, Oct 27, 2002 at 04:31:46PM -0800, David Nicholas Kayal wrote:
> #include <stdio.h>
> #include <dev/ppbus/ppi.h>
> #include <dev/ppbus/ppbconf.h>
> #include <fcntl.h>
> 
> int main()
> {
>   int             fd;
>   u_int8_t        val;
> 
>   fd = open("/dev/ppi0", O_RDWR);
>   val = 0xff;
>   while(1)
>     {
>       ioctl(fd, PPISDATA, &val);
>       ioctl(fd, PPIGCTRL, &val);
>       val |= STROBE;
>       ioctl(fd, PPISCTRL, &val);
>       val &= ~STROBE;
>       ioctl(fd, PPISCTRL, &val);
>     }
> }

You should really check your return values.  The parallel port is not
writeable by default, so unless you've changed it, or are running as
root, your program is most likely failing to even open it, but you're
not noticing because you aren't checking your return codes.

-Brian
-- 
Brian Dean
bsd@FreeBSD.org
bsd@bsdhome.com

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021028061033.GA65546>