delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/06/15/09:46:37

From: benjamin DOT ross AT gmx DOT net (Benjamin Ross)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: how to access print port
Date: 15 Jun 2003 15:40:00 +0100
Lines: 40
Message-ID: <8nuxOu10WfB@benjamin.ross>
References: <20030613080225 DOT 58485 DOT qmail AT web41504 DOT mail DOT yahoo DOT com>
NNTP-Posting-Host: p5083b183.dip.t-dialin.net (80.131.177.131)
Mime-Version: 1.0
X-Trace: fu-berlin.de 1055684459 20193766 80.131.177.131 (16 [148775])
User-Agent: OpenXP/32 v3.8.7pl8 (Win32) beta @ 2003-01-03-1554f
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

johnerzhou AT yahoo DOT com wrote->
> Hi,
> I want to use parallel port(print port) on PC, want to
> write/read byte to/from it. I have installed DJGPP,
> which library or function should use to open the  ort
> and read/write byte via it. Where can I get it?
> Thanks a lot.
> Best regards,
> Tony ZHOU

if you need direct hardware access because it's a special kind of hardware that
you want to access, you can use inportxx() or outportxx() from libpc or
use assembler or whatever.
some simple things can more easily be done with the usual file-i/o
functions. to access port n you only gotta open the file LPTn.

------------
#include <fcntl.h>


int main(void)
{
 FILE *port;

 port=fopen("LPT1","rb");

 fputs("hello world",port);
 /*
   i don't know wheter you can read back something with these functions,
    but you can try...*/
 fclose(port);
}
-----------------

you could also code your own DOS device driver which could be accessed in  
a similar way. links:
http://www.nondot.org/sabre/os/files/Executables/SYS.txt
http://www.bsdg.org/swag/DOS/0091.PAS.html
http://www.clipx.net/ng/dos5/ng2ca0f.php

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019