Hi
 Thanks for all answers.I write a sample programe that do the job i
want.The program is test on OpenBSD 3.9 .The source can be doanload
from
http://www.betstrikes.com/OpenBSD/outb.c

/*
 * You need to have the machdep.allowaperture sysctl set to >=1 if
running at securelevel 1 or above.
 * syscrl -w machdep.allowaperture=2
 * thanks to
http://marc.theaimsgroup.com/?l=openbsd-tech&m=101984806101040&w=2
 *
 * To compile use:
 * gcc -O -li386 outb.c -o outb
 *
*/


#include <stdio.h>
#include <stdlib.h>

#include <sys/types.h>
#include <sys/syscall.h>
#include <machine/sysarch.h>
#include <machine/pio.h>

#define base 0x378           /* printer port base address */

int
main(int argc, char *argv[]) {
        int value;
        int port;
        u_long iomap[32];
        extern char *__progname;

        if (argc!=3) {
                fprintf(stderr, "Usage: %s [value]\n", __progname);
                exit(1);
        }

        if (sscanf(argv[1],"%i",&value)!=1)
                fprintf(stderr, "Error: Parameter is not a number.\n"),
exit(1);

        if ((value<0) || (value>255))
                fprintf(stderr, "Error: Invalid numeric value. Enter
value between 0 and 255\n"), exit(1);


        /* Enable access to the port */
        port = base;

        struct i386_set_ioperm_args ioperm;

        ioperm.iomap = iomap;
        syscall(SYS_sysarch, I386_GET_IOPERM, (char *) &ioperm);
        iomap[port >> 5] &= ~(1 << (port & 0x1f));
        syscall(SYS_sysarch, I386_SET_IOPERM, (char *) &ioperm);

        outb(port, value);         /* Set the output register   */

        return 0;
}

Any suggestions and comments are wellcome.

Best regards
Tihomir 

--- Nick Guenther <[EMAIL PROTECTED]> wrote:

> On 5/5/06, Tihomir Koychev <[EMAIL PROTECTED]> wrote:
> > Hi
> >  Can someone suggest simple application which can send data to
> parallel
> > port.I want to send 0,1 on pin2 to control relay.
> >
> > best regards
> > Tihomir
> >
> 
> Start here:
> http://marc.theaimsgroup.com/?l=openbsd-tech&m=101984806101040&w=2
> 


www.BetStrikes.com - futbolni prognozi Tsrankmh opncmngh

Reply via email to