From: Eric Dedieu
Subject: Opening a serial port as a stream
Date: 
Message-ID: <1448@dione.imag.fr>
Hello,

I wish to use the Sun serial port for reading/sending data. I can
open a stream with e.g. (open "/dev/ttyb" :direction :input), but
since transmission doesn't work, I guess the port configuration
is not good (I need 9600 baud, 2 stop bits, 8 bit bytes & no parity check).

I see two possibilities, neither of which seems directly available from the
manuals of either Lisp or Unix:

1) Configuring it from Lisp, or setting system defaults (via environment variables ?)
for opening serial ports;

2) Calling a C function using "ioctl" to modify a C "termios" structure
describing the port (a solution I would like).

The latter would require to pass a stream as argument (as a type *FILE, I think),
and it seems quite hard using the described foreign function interface. How can I make
the translation, if anyone has already had this problem ?

Thanks,

Eric Dedieu
From: Barry Margolin
Subject: Re: Opening a serial port as a stream
Date: 
Message-ID: <1991Sep3.213704.29692@Think.COM>
In article <····@dione.imag.fr> ······@lifia.imag.fr (Eric Dedieu) writes:
>I wish to use the Sun serial port for reading/sending data. I can
>open a stream with e.g. (open "/dev/ttyb" :direction :input), but
>since transmission doesn't work, I guess the port configuration
>is not good (I need 9600 baud, 2 stop bits, 8 bit bytes & no parity check).
...
>2) Calling a C function using "ioctl" to modify a C "termios" structure
>describing the port (a solution I would like).
>
>The latter would require to pass a stream as argument (as a type *FILE, I think),
>and it seems quite hard using the described foreign function interface. How can I make
>the translation, if anyone has already had this problem ?

ioctl() doesn't want a FILE*, it wants a file descriptor, which is just an
integer.  Lucid makes the file descriptor associated with a Lisp stream
available using the EXTRACT-STREAM-HANDLE function.

You'll still have to use the foreign structure interface to build the
"termios" structure, and use the foreign function interface to call
ioctl().  Alternatively, you could write a simple C function that does the
ioctl() call, and call that from Lisp using the foreign function interface.
-- 
Barry Margolin, Thinking Machines Corp.

······@think.com
{uunet,harvard}!think!barmar