Date: Wed, 11 Jun 2003 18:45:41 -0400 From: Guillaume <amyfoub@videotron.ca> To: Bernard Dugas <bernard.dugas@is-production.com>, freebsd-questions@freebsd.org Subject: Re: how to talk to the serial and parallel ports through a C Message-ID: <200306111845.41486.amyfoub@videotron.ca> In-Reply-To: <3EE65F83.9A1890FA@is-production.com> References: <20030609175804.043AA37B405@hub.freebsd.org> <3EE65F83.9A1890FA@is-production.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 10 June 2003 18:45, Bernard Dugas wrote:
> Hi,
>
> I also did some programming on serial port to control pins with a c
> program under linux, but I didn't found any simple way to port it
> under freebsd. Any hint ?
>
> For instance, I need the equivalent of :
> inb(adr)
> outb(val,adr)
> iopl(n)
> ioperm(adr)
>
> from <sys/io.h> and <stdio.h> in linux.
Try that:
=2D--------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <machine/cpufunc.h>
#define porta 0x378
#define portb 0x379
const char *filename;
int main(void) {
int fd, data;
filename =3D "/dev/io";
fd =3D open(filename, O_RDWR);
if (fd < 0)
{
printf("Erreur d'acc=E8s =E0 %s\n", filename);
exit(1);
}
outb(porta, 0xFF);
sleep(1);
outb(porta, 0x00);
sleep(1);
data =3D (inb(portb));
printf("data =3D %x\n", data);
close(fd);
exit(0);
}
=2D--------------------------------------------
Works with FreeBSD 5.x, I don't know with 4.x
Guillaume
>
> Best regard,
> Bernard Dugas
>
> > ------------------------------
> >
> > Message: 32
> > Date: Mon, 09 Jun 2003 09:44:28 -0700
> > From: Dan Malaby <dan@peritek.com>
> > Subject: how to talk to the serial and parallel ports through a C
> > program
> > To: freebsd-questions@freebsd.org
> > Message-ID: <5.1.0.14.2.20030609093752.00a69d20@pop3.peritek.com>
> > Content-Type: text/plain; charset=3D"us-ascii"; format=3Dflowed
> >
> > I was wondering if there was a good place to go to get programing
> > examples on how to
> > talk to the serial and parallel ports. I have looked in the
> > developers handbook but have not
> > any luck finding what I want.
> >
> > Any pointers would be appreciated
> >
> > Thanks
> >
> > Daniel Malaby voice:(510) 531-6500
> > Peritek Corp. fax: (510) 530-8563
> > 5550 Redwood Road email: dan@peritek.com
> > Oakland, CA 94619
> >
> > ------------------------------
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200306111845.41486.amyfoub>
