🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: C,Linux y Puerto Paralelo

#13245
From: SETASETA
Date: Sun, 11 Mar 2001 10:00
81 lines
2690 bytes
"Francisco F. Artese" escribi�:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Holas para todos los fanas de las teclas.
>
> Se puede escribir en el registro 0x3bc en Linux?
> Tengo entendido que no es posible este tipo de accesos solo reservado al
> kernel.
>
> Entonces como puedo hacer para adaptar un  peque�o circuito de control
> que tengo implementado usando la salida del puerto paralelo de un PC y
> programado en DOS.
>
> Salud! y Gracias.
>

Hola
Te mando las rutinas que tengo hechas para manejar puertos.
Ante todo tinenes que pensar que debes ser root para que funcionen, o tener
los permisos de root.
Tambien  debes pensar que te estas saltando todos los principios de
seguridad y filosofia del sistema Linux.
Los programas que he hecho estan en  :  http://www.geocities.com/SETA43

Manejador de puertos y producci�n de sonido beep
/* -------------------------------------------------------- */
unsigned char inportb(unsigned short port)
{
unsigned char z;
 __asm__("
   pushw %%dx\n
   pushw %%ax\n
   movw %1,%%dx\n
   in %%dx,%%al\n
   movb %%al,%0\n
   popw %%ax\n
   popw %%dx"
   : "=g" (z)
   :  "g" (port)
   : "ax","dx"
 );
 return(z);
}

void outportb(unsigned short port, unsigned char value)
{
 __asm__("
   pushw %%dx\n
   pushw %%ax\n
   movw %1,%%dx\n
   movb %0,%%al\n
   out %%al,%%dx\n
   popw %%ax\n
   popw %%dx"
   :
   : "g" (value), "g" (port)
   : "ax","dx"
 );
}

void Sbeep(unsigned short high)
{
unsigned char p,cl,ch;
 cl=high & 0x00FF;
 ch=(high>>8) & 0x00FF;
 p = inportb(0x61);
 if(high)
  {
   outportb(0x61,p|3);
   outportb(0x43,0xb6);
   outportb(0x42,cl);
   outportb(0x42,ch);
  }

  else
  {
   outportb(0x61,p&0xfc);
  }
}
Technical Details
Message-ID: <3AAB4CA8.9057448@santandersupernet.com>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!cyclone-sf.pbi.net!63.208.208.143!feed2.onemain.com!feed1.onemain.com!news-out.cwix.com!newsfeed.cwix.com!newsfeed.bcn.ttd.net!news.bcn.ttd.net!not-for-mail
References: <b91s79.e91.ln@artese.com.ar>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,bbcff2d19a86e9ea
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2001-03-11 12:42:08 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!cyclone-sf.pbi.net!63.208.208.143!feed2.onemain.com!feed1.onemain.com!news-out.cwix.com!newsfeed.cwix.com!newsfeed.bcn.ttd.net!news.bcn.ttd.net!not-for-mail
From: SETASETA@santandersupernet.com
Newsgroups: es.comp.os.linux.programacion
Subject: Re: C,Linux y Puerto Paralelo
Date: Sun, 11 Mar 2001 11:00:08 +0100
Organization: Grupo de Empresas Antakira
Lines: 83
Message-ID: <3AAB4CA8.9057448@santandersupernet.com>
References: <b91s79.e91.ln@artese.com.ar>
NNTP-Posting-Host: 212-170-194-48.uc.nombres.ttd.es
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Mailer: Mozilla 4.75 [es] (X11; U; Linux 2.2.17-21mdk i586)
X-Accept-Language: en