From: Henner Bartels

Subject: Re: Serial ports and ACLWIN 3

Date: 1998-10-20 8:34

>I'm trying to talk to a PC's serial (COM) port from ACLWIN 3. Has anybody >managed to achieve this that you know of? And if so, I'd really like to >know how...
<- snipp ->
>Regards, Stuart > >========================================== >Stuart Watt >Lecturer in Knowledge Media and Psychology >Open University, Walton Hall, Milton Keynes. MK7 6AA. UK. >WWW: http://suilven.open.ac.uk/stuart/ >Tel: +44 1908 654513; Fax: +44 1908 653169
This is something I have tried (without full success) before. The following is a reply from Franz I received for my inquiry (PCSPR3533).
>> Has anyone written a Lisp interface to serial ports for ACL/Win? >> >> I haven't given much thought to what the interface should look like. I
would
>> like to use whatever is out there. I'm just getting started with Allegro
CL
>> for Windows version 3.0. I took a look in osidoc.txt and I noticed that
the
>> CreateFile() Win32 API function does not seem to be in there. Is this
just
>> because Franz didn't get around to adding all of the FFIs for the Win32
API?
> > Thanks for your question. While a large chunk of the Win32 API is > available as lisp functions and constants named by symbols in the > windows package, not all of the the Win32 API were pre-built into the > lisp. One can still use ffi, though, to access the remaining API > routines by using ct:defun-dll. You have to be aware, though, that > for certain API such as CreateFile() which take string arguments, > there is an "Ansi" and a "Wide" version of these functions. These are > named in the dlls as CreateFileA() and CreateFileW(). So, to define > and use the Ansi CreateFile() in aclwin, you'd have to do something > like the following: > > (ct:defun-dll createfile (..arguments..) > :entry-name "CreateFileA" > :return-type ... > :library-name "shell32.dll") > > As for the serial ports, one can open a COM port using > > (open "com2" :direction :output) > > and then use the usual lisp functions for writing to a stream. > > Charley > --- > Charles A. Cox, Franz Inc. 1995 University Avenue, Suite 275 > Internet: <franz.com at cox> Berkeley, CA 94704 > WWW: http://www.franz.com/ Phone: (510) 548-3600; FAX: (510)
548-8253 Using the (open "com2" :direction :output) call indeed lets you write to the strream (and thus to COM2), however you can't use it for input (whether or not changing :output to :input or :io). I am not aware if Franz fixed this within 3.01 or 5.0 (though I hope they have). I have never tried the FFI way suggested by Charles earlier on but maybe someone else did. I'd like to here more about this. Best regards, Henner