Subject: [clisp-list] Serial port access with CLisp and Windows

From: "Joseph Driscoll" <[email-masked]>
Date: Sun Feb 22 11:15:04 2004

Hello,

Has anyone successfully been able to use the serial (COM) ports of a Windows
machine under CLisp (or some other free Lisp)? I'd need both input and
output modes. Is there sample code available?

Here's a transcript of what I was trying before. I open and close the
stream, just to see if that works. Then I open it again, print a character
to it, then try to read from it. But this hangs, and I have to ctrl-c out of
it. I'm not certain if the character I sent out is even being sent. I'm
pretty sure that the port is really opened, since a separate terminal
program (hyperterminal) can't access the port until the "close" instruction
is used in CLisp. Note that everything (input and output) works fine if I
just use Hyperterminal, so I'm fairly sure that the hardware is working.

[9]> (setf sers (open "COM1" :direction :io))
#<IO UNBUFFERED FILE-STREAM CHARACTER #P"COM1" @1>
[10]> (close sers)
T
[11]> (setf sers (open "COM1" :direction :io))
#<IO UNBUFFERED FILE-STREAM CHARACTER #P"COM1" @1>
[12]> (print 'e sers)
E
[13]> (read sers)

*** - READ: Ctrl-C: User break
Break 1 [14]>

I posted this question to comp.lang.lisp, and I have received several
suggestions. Unfortunately, none of these worked: they always result
hanging. I have tried:

(let ((v (make-array 10 :fill-pointer 0 :adjustable t :element-type
'character))) (loop :while (listen serial) :do (vector-push-extend
(read-char serial) v)) v)

(with-output-to-string (s) (loop :while (listen serial) :do (write-char
(read-char serial) s)))

(with-output-to-string (s) (loop :for c = (read-char-no-hang serial) :while
c :do (write-char c s)))

Thanks to Sam Steingold, who has sent several replies on this topic, and
suggested that I post here.

Thanks,
Joe

---

From: Sam Steingold <[email-masked]>
Date: Sun Feb 22 11:51:01 2004

> * Joseph Driscoll <[email-masked]> [2004-02-22 13:07:04 -0600]:
>

somehow I missed this.
CLISP thinks that this is an ordinary text file while this is a special
device which should be accessed with specialized functions.
I don't know how to make this work.
Do you have sample C code?

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
Old Age Comes at a Bad Time.

---

From: "Joseph Driscoll" <[email-masked]>
Date: Sun Feb 22 12:45:01 2004

I've been using hyperterminal (rather than c code) to send/receive info from
the device, so I don't have any working code.

Someone developed a way to do this in Lisp, and makes available a fasl file.
The problem is that it seems to only work with Allegro CL (maybe it uses
built-in Allegro support for serial communications, etc.).

The problem with just using Allegro is that the free version prohibits its
use for university research (that's my goal), so I turned to CLisp since
it's much less expensive than Allegro.

I do have access to a linux box (Red Hat 9.0, I believe). Would a linux
CLisp environment be better for serial communications?

Thanks,
Joe

----- Original Message ----- 
From: "Sam Steingold" <[email-masked]>
To: <[email-masked]>; "Joseph Driscoll"
<[email-masked]>
Sent: Sunday, February 22, 2004 1:42 PM
Subject: [clisp-list] Re: Serial port access with CLisp and Windows

> -------------------------------------------------------
> SF.Net is sponsored by: Speed Start Your Linux Apps Now.
> Build and deploy apps & Web services for Linux with
> a free DVD software kit from IBM. Click Now!
> http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
> _______________________________________________
> clisp-list mailing list
> [email-masked]
> https://lists.sourceforge.net/lists/listinfo/clisp-list
>

---

From: Sam Steingold <[email-masked]>
Date: Sun Feb 22 12:58:01 2004

> * Joseph Driscoll <[email-masked]> [2004-02-22 14:36:27 -0600]:
>

dunno.  why don't you try it?

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
Cannot handle the fatal error due to a fatal error in the fatal error handler.