how to talk to the serial and parallel ports through a C
Guillaume
amyfoub at videotron.ca
Wed Jun 11 15:45:47 PDT 2003
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:
---------------------------------------
#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 = "/dev/io";
fd = open(filename, O_RDWR);
if (fd < 0)
{
printf("Erreur d'accès à %s\n", filename);
exit(1);
}
outb(porta, 0xFF);
sleep(1);
outb(porta, 0x00);
sleep(1);
data = (inb(portb));
printf("data = %x\n", data);
close(fd);
exit(0);
}
---------------------------------------------
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 at peritek.com>
> > Subject: how to talk to the serial and parallel ports through a C
> > program
> > To: freebsd-questions at freebsd.org
> > Message-ID: <5.1.0.14.2.20030609093752.00a69d20 at pop3.peritek.com>
> > Content-Type: text/plain; charset="us-ascii"; format=flowed
> >
> > 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 at peritek.com
> > Oakland, CA 94619
> >
> > ------------------------------
More information about the freebsd-questions
mailing list