Trastabuga <·········@gmail.com> writes:
> I am looking for some information on how can I use Lisp (CLisp on
> Windows) to communicate with serial ports.
I would do:
(with-open-file (port "COM1:" :direction :io :element-type '(unsigned-byte 8))
(write-sequence #.(ext:convert-string-to-bytes "ATZ" charset:ascii) port)
(write-sequence #(13 10) port)
(let ((buffer (make-array 80 :element-type '(unsigned-byte 8) :initial-element 0
:fill-pointer 0))
(set (fill-pointer buffer) (read-sequence buffer port))
buffer)))
Or something like that. If you're using clisp on cygwin on windows,
rather use "/dev/ttyS0" instead of "COM1:".
Now, if you need to set special attributes (speed, parity, etc), you
can use SOCKET:STREAM-HANDLES to get the file descriptor and use
ioctl(2) or the equivalent MS-Windows with FFI to set them.
--
__Pascal Bourguignon__ http://www.informatimago.com/
NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.