Skip to content
serial-port accessing library for common lisp
Branch: master
Clone or download
Latest commit 191c808 Apr 2, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Fixed miss *default-timeout* => *default-timeout-ms* Apr 2, 2017
.travis.yml
README.markdown Added README. Apr 2, 2017
appveyor.yml add appveyor.yml Feb 17, 2017
cserial-port.asd Removed trivial-timeout Apr 1, 2017

README.markdown

cserial-port

Build Status Build status

Common Lisp library for interacting with serial ports.

Usage

(with-serial (rs1 1)
  (write-serial-byte-vector
    (babel:string-to-octets "Hello")
    rs1))

;; Interacting with 2 serial ports.
(with-serial (rs2 2)
  (with-serial (rs1 1)

    (write-serial-byte-vector
      (babel:string-to-octets "こんにちは。")
      rs1)

    (let ((res (make-array 18 :element-type '(unsigned-byte 8))))
      (read-serial-sequence res rs2))))

;; Using a gray-stream interface
(with-serial (rs1 1)
  (let ((stream (make-serial-stream rs1)))
    ;; Allow to use write/read-sequence.
    (write-sequence
      ;; Sending 'Hi'
      (make-array 2 :element-type '(unsigned-byte 8) :initial-contents '(72 105))
      stream)))

;; Using a timeout
(with-serial (rs1 1)
  (handler-case
      (write-serial-byte-vector
        (babel:string-to-octets "Hello")
        rs1
        :timeout-ms 500)
    (timeout-error ()
      (error "The request timed out."))))

;; Using timeout with gray-stream interface
(with-serial (rs1 1)
  (let ((stream (make-serial-stream rs1)))
    (handler-case
        (with-timeout (500) ;; ms
         ...)
      (timeout-error ()
        (error "The request timed out.")))))
You can’t perform that action at this time.