🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #14765

Programacion del puerto paralelo

#14765
From: Deivit
Date: Thu, 05 Oct 2000 00:00
99 lines
3678 bytes
Tengo una placa de 8 rel�s conectada al puerto paralelo. Bajo DOS desarroll�
un programa que la hacia funcionar correctamente, pero no tengo ni idea de
como portar eso a Linux (exactamente Debian Woody).

La cuesti�n es la siguiente: Los reles se encienden mandando un byte
hexadec. al puerto paralelo, por ejemplo: BFh = 10111111 mandando eso,
encenderia los reles 1 y 3,4,5,6,7,8. En DOS el programa me funciona bien,
pero no se como hacerlo en Linux pues nunca he programado para este OS y no
se como funcionan las librerias y eso. Adjunto va el codigo que yo escribi,
y si alguien me ayuda a pasarlo a linux se lo agradeceria :)

RELAY.C--------
-----------------------------------
#include <dos.h>

#define LPT1 0x00400008  /* BIOS printer address entries */
#define LPT2 0x0040000a
#define LPT3 0x0040000c
#define LPT4 0x0040000e

int main(int argc, char *argv[])
{
unsigned int port,data;
unsigned int bios_printer_addr;

if (argc>3) exit(1);
  switch(argc)
    {
      case 1:
        exit(1);

      case 2:
        port=*(bios_printer_addr=LPT1);
        if (port==NULL)
          {
            printf("LPT1 does not exist\n");
            exit(1);
          }

        sscanf(argv[1],"%x",&data);
        break;

      case 3:
         if (argv[1][0]=='/')
           switch(argv[1][1])
     {
       case '1':
         port=*(bios_printer_addr=LPT1);
                if (port==NULL)
                  {
                    printf("LPT1 does not exist\n");
                    exit(1);
                  }
                sscanf(argv[2],"%x",&data);
                 break;

       case '2':
         port=*(bios_printer_addr=LPT2);
                if (port==NULL)
                  {
                    printf("LPT2 does not exist\n");
                    exit(1);
                  }

                sscanf(argv[2],"%x",&data);
         break;

              case '3':
                port=*(bios_printer_addr=LPT3);
                if (port==NULL)
                  {
                    printf("LPT3 does not exist\n");
                    exit(1);
                  }

                sscanf(argv[2],"%x",&data);
                break;

              case '4':
                port=*(bios_printer_addr=LPT4);
                if (port==NULL)
                  {
                    printf("LPT4 does not exist\n");
                    exit(1);
                  }

                sscanf(argv[2],"%x",&data);
                break;

       default:
                printf("Invalid printer port!\n");
       exit(1);
     }
 else exit(1);
    }

   outportb(port, (char)data);
   return 0;
}
Technical Details
Message-ID: <1D1D5.4$Ba2.88@telenews.teleline.es>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f9fff,52f70884b47e3bd7,start
X-Google-Attributes: gidf9fff,public
X-Google-Thread: f78ff,52f70884b47e3bd7,start
X-Google-Attributes: gidf78ff,public
X-Google-Thread: f86c8,52f70884b47e3bd7,start
X-Google-Attributes: gidf86c8,public
X-Google-Thread: 10465c,52f70884b47e3bd7,start
X-Google-Attributes: gid10465c,public
From: "Deivit" <iamevil@jazzfree.com>
Subject: Programacion del puerto paralelo
Date: 2000/10/05
Message-ID: <1D1D5.4$Ba2.88@telenews.teleline.es>
X-Deja-AN: 677922554
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
X-Complaints-To: newsmaster@company.com
X-Trace: telenews.teleline.es 970761789 193.153.98.147 (Thu, 05 Oct 2000 18:03:09 MET DST)
Organization: Typhoon Authentication Testing Club
NNTP-Posting-Date: Thu, 05 Oct 2000 18:03:09 MET DST
Newsgroups: es.comp.os.linux.programacion,esp.comp.so.linux.programacion,linux.debian.spanish,linux.debian.user.spanish