delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/08/12:11:24

Date: Mon, 8 Dec 1997 19:07:29 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Matthew Mastracci <mmastrac AT acs DOT ucalgary DOT ca>
cc: djgpp AT delorie DOT com
Subject: Re: Compatible Serial Communication
In-Reply-To: <66fme6$edq@ds2.acs.ucalgary.ca>
Message-ID: <Pine.SUN.3.91.971208185917.4989E-100000@is>
MIME-Version: 1.0

On Sun, 7 Dec 1997, Matthew Mastracci wrote:

> What would be the best way to create a (relatively) portable serial
> communications library?  By portable, I mean that I'd like it to run on
> DOS and Linux with as little modification as possible.

I suggest using the DJGPP Filesystem extensions feature.  It works by
hooking low-level libc I/O functions, and when they refer to specific
files/handles, your handler gets to do the actual work before libc calls
DOS for the default thing.  You could then make the files "/dev/pty1" and
such likes to refer to the COM ports. 

And on Linux, just writing to /dev/ptyN would call the Linux async port 
driver.

The actual communications on DOS aould be done with e.g. Bill's BCSERIO 
package (on SimTel.NET, in the v2tk directory). 

The filesystem extensions are documented in the libc.info reference.  If 
you are interested in real-life uses of that wonder, look in the 
v2gnu/fil316s.zip, file gnu/filutil3.16/src/ls-msdos.c (it uses this 
feature to display files with colors by catching stdout writes and 
redirecting them to conio function calls).

- Raw text -


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