Mail Archives: djgpp/1997/12/08/12:11:24
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 -