From: Jim
Subject: Newbie here
Date: 
Message-ID: <3B96E696.9226B025@optonline.net>
Hi all.

I'm new to lisp. I'm mainly familiar with PC's and VB.

I have a lisp version from TI called muLisp. I have it running on my PC
at home and at work.

I am a technician and have these circuit boards with a 232 port on them
and I want to write a little utility that can run on the PC and poll
these boards  to help me in troubleshooting. They already have something
written in VB for testing purposes, but it's so slow in launching, and
is limited in it's functions.

I know there's a PORTIO function. Is that what I should use to connect
to serial ports? I was looking at the documentation for PORTIO and it
said it can send/receive data from one of 65535 different ports. A PC
has only com1 - 4. And it seems to return only numbers, not characters.
Is it returning the ascii codes?

Any help would be appreciated.

Jim

From: Tim Bradshaw
Subject: Re: Newbie here
Date: 
Message-ID: <ey3n148n1p1.fsf@cley.com>
* mjhts  wrote:
> I have a lisp version from TI called muLisp. I have it running on my PC
> at home and at work.

muLisp is fairly obscure and old, but it may well be quite good  for
the task you have.  There may be other Lisps for the PC which can
easily do serial I/O which might be better - I'm sure someone here
will know if so.

> I know there's a PORTIO function. Is that what I should use to connect
> to serial ports? I was looking at the documentation for PORTIO and it
> said it can send/receive data from one of 65535 different ports. A PC
> has only com1 - 4. And it seems to return only numbers, not characters.
> Is it returning the ascii codes?

No, this function talks to a different sort of IO port...  The x86
(well, the 8086) has a notion of special places - `ports' where IO can
happen, and there are I think 64k of these (16 bits worth of address).
The PORTIO function I think writes to and reads from these.  I don't
know if they are used at all in modern machines.  Someone can probably
give a better description of what this is than me...

Anyway, the point is that this is *not* the fn to use to talk to a
serial port.  There may be other functions, or it might even work to
just open a file called COM1: or something and write to / read from
thast.

Sorry not to be more help.

--tim
From: Greg Menke
Subject: Re: Newbie here
Date: 
Message-ID: <m3bskoplfu.fsf@europa.pienet>
> > I know there's a PORTIO function. Is that what I should use to connect
> > to serial ports? I was looking at the documentation for PORTIO and it
> > said it can send/receive data from one of 65535 different ports. A PC
> > has only com1 - 4. And it seems to return only numbers, not characters.
> > Is it returning the ascii codes?
> 
> No, this function talks to a different sort of IO port...  The x86
> (well, the 8086) has a notion of special places - `ports' where IO can
> happen, and there are I think 64k of these (16 bits worth of address).
> The PORTIO function I think writes to and reads from these.  I don't
> know if they are used at all in modern machines.  Someone can probably
> give a better description of what this is than me...
> 
> Anyway, the point is that this is *not* the fn to use to talk to a
> serial port.  There may be other functions, or it might even work to
> just open a file called COM1: or something and write to / read from
> thast.

On a PC under DOS, the I/O ports let you talk directly to the
hardware.  The bios routines (effectively, the DOS serial port
drivers) are there, but are moderately horrible to use.  PORTIO lets
you access to the serial port's UART, so you can program it directly.
The 8250/16450/16500 class of UARTS are very similar wrt to
programming and only require manipulating a few registers to make them
go.  Datasheets for them are widely available on the Internet.
Unfortunately, you can't get interrupt driven I/O without a serial
port interrupt service routine.  Note that the PC serial ports have
canonical port addresses; com1 starts at 0x3f8, com2 at 0x2f8.  com3
and 4 are often at 0x3e8 and 0x2e8, but can vary.

So, if polled I/O is sufficient, PORTIO will help you "operate" the
UART yourself.  PORTIO is returning integers (and accepting them as
parameters), assuming your Lisp has them, look at the char-int,
char-code family of functions.
http://www.xanalys.com/software_tools/reference/HyperSpec/ 
is a great reference.

If you need interrupt driven serial I/O in DOS (essentially required
for baud rates > 9600 with low inter-char delays on the incoming
stream), a number of free/shareware libraries have been written to do
this; usually for C or assembly.  If you can find one that makes
itself a TSR, and exposes some kind of interface (maybe via some int
or another), then you could most likely talk to that from Lisp.  I'm
assuming your Lisp has some means of invoking x86 interrupts.  Such a
function will still be returning and accepting integers, so the same
char-code, code-char functions will be helpful there.

It also might be the case that the PC bios serial routines will do
enough for your purposes, in which case you'd use whatever Lisp
function lets you call x86 interrupt routines.  It might be possible
to use the file I/O calls to talk right to the DOS serial port
support, via opening "COM1:" then reading/writing, however this just
wraps calls to the pc bios serial routines in a higher level function
call, so it doesn't help very much.

You'll probably also find
http://www.cs.cmu.edu/afs/cs/user/ralf/pub/WWW/files.html
to be helpful.

Gregm