Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/snmsts/cserial-port
serial-port accessing library for common lisp
https://github.com/snmsts/cserial-port
common-lisp
Last synced: 3 days ago
JSON representation
serial-port accessing library for common lisp
- Host: GitHub
- URL: https://github.com/snmsts/cserial-port
- Owner: snmsts
- Created: 2014-01-13T14:28:34.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-07-31T16:23:22.000Z (over 1 year ago)
- Last Synced: 2024-12-05T15:24:37.072Z (2 months ago)
- Topics: common-lisp
- Language: Common Lisp
- Size: 58.6 KB
- Stars: 28
- Watchers: 9
- Forks: 13
- Open Issues: 5
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
# cserial-port
[![Build Status](https://travis-ci.org/snmsts/cserial-port.svg?branch=master)](https://travis-ci.org/snmsts/cserial-port)
[![Build status](https://ci.appveyor.com/api/projects/status/nq0k756e7baeh5gy?svg=true)](https://ci.appveyor.com/project/snmsts/cserial-port)Common Lisp library for interacting with serial ports.
## Usage
```common-lisp
(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.")))))
```