Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 Jul 2003 13:08:01 GMT
From:      Mark <admin@asarian-host.net>
To:        "Malcolm Kay" <malcolm.kay@internode.on.net>, "Daan Vreeken [PA4DAN]" <Danovitsch@Vitsch.net>
Cc:        FreeBSD-questions@freebsd.org
Subject:   SOLVED! Re: Writing to parallel port
Message-ID:  <200307271307.H6RD7JGZ031242@asarian-host.net>
References:  <200307251722.H6PHMFRS032800@asarian-host.net> <200307251942.54397.Danovitsch@Vitsch.net> <200307261241.54059.malcolm.kay@internode.on.net>

next in thread | previous in thread | raw e-mail | index | archive | help
----- Original Message ----- 
From: "Malcolm Kay" <malcolm.kay@internode.on.net>
To: "Daan Vreeken [PA4DAN]" <Danovitsch@Vitsch.net>; "Mark"
<admin@asarian-host.net>
Cc: <FreeBSD-questions@freebsd.org>
Sent: Saturday, July 26, 2003 5:12 AM
Subject: Re: Writing to parallel port


> > On Friday 25 July 2003 19:22, Mark wrote:
> > Hello,
> >
> > Has anyone an idea how to set/unset a bit on a parallel port in freebsd
> > 4.7? I installed Device::ParallelPort from CPAN (Perl 5.8.0), but that
> > does nothing (seems made for linux).
>
> Basically you need to open /dev/io to get io read/write permission, after
> that you are free to bang all IO-ports you want.

> Generally you still need to be root or have root privilege to do this;
> but might vary with different FreeBSD releases.
>
> An alternative that may or may not suit your needs is ppi device access
> to parallel ports eg /dev/ppi0; try:
# man ppi


Thanks, Malcolm!

Using /dev/ppi0 solved it. :) And I am back in securelevel 2 (accessing the
raw device directly, via /dev/io, though it worked like a charm, would not
go from securelevel 1 and up). Feeling a lot better now. :)

- Mark


P.S. In case someone wondered, this is what I did:

-----------------------------------------------
#include <stdio.h>
#include <dev/ppbus/ppi.h>
#include <dev/ppbus/ppbconf.h>
#include <fcntl.h>

int main (void)
{
  int             fd;
  u_int8_t        val;

  fd = open ("/dev/ppi0", O_RDWR);
  val = 0x01;

  ioctl (fd, PPISDATA, &val);
  ioctl (fd, PPIGCTRL, &val);
  val |= STROBE;
  ioctl (fd, PPISCTRL, &val);
  val &= ~STROBE;
  ioctl (fd, PPISCTRL, &val);

}
-----------------------------------------------



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