added with-serial-streams macro for multiple streams; fix misprint in readme.

Nikolay V. Razbegaev [2009-12-17 19:02]
added with-serial-streams macro for multiple streams; fix misprint in readme.
Filename
README
pkgdcl.lisp
streams.lisp
diff --git a/README b/README
index 06ba739..1cd748f 100644
--- a/README
+++ b/README
@@ -28,16 +28,16 @@ values before reading/writing.

 Usage of `with-serial-stream' macro is recommended. Syntax is like
 `with-open-file':
- (with-raw-serial (stream path &key
- 		   (speed :b115200)
-		   (parity n)
-		   (byte-size 8)
-		   hardware-flow-control
-		   software-flow-control
-		   (flag (logior o-rdwr o-nonblock o-noctty))
-                   (mode *default-open-mode*)
-                   (external-format :default)
-		   timeout read-timeout write-timeout)
+ (with-serial-stream (stream path &key
+ 	               (speed :b115200)
+		       (parity :n)
+		       (byte-size 8)
+		       hardware-flow-control
+		       software-flow-control
+		       (flag (logior o-rdwr o-nonblock o-noctty))
+                       (mode *default-open-mode*)
+                       (external-format :default)
+		       timeout read-timeout write-timeout)
     &body body)

 I.e. only serial device pathname is necessary parameter.  You can
@@ -46,7 +46,8 @@ byte/character size and parity checking mode. Also you can turn on
 hardware/software flow control and specify additional stream
 parameters. Note, that this macro will allways set `raw` mode, so if
 you prefer `canonical` mode you should use `with-open-stream` and
-`stty` (see below) instead.
+`stty` (see below) instead. There is variant for multiple strams:
+`with-serial-streams`.

 `stty` function is like `stty' shell utility:
   (stty fd :b115200 :raw t :hupcl nil)
diff --git a/pkgdcl.lisp b/pkgdcl.lisp
index 2e6a107..ebcdd97 100644
--- a/pkgdcl.lisp
+++ b/pkgdcl.lisp
@@ -44,6 +44,7 @@
    ;; serila stream manipulation
    #:open-serial-stream
    #:with-serial-stream
+   #:with-serial-streams
    ;; List of all open serial streams. Can be used in signal handlers.
    #:*open-serial-streams*))            ;</ defpackage>
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
diff --git a/streams.lisp b/streams.lisp
index d385dd0..6d9dd85 100644
--- a/streams.lisp
+++ b/streams.lisp
@@ -151,3 +151,11 @@
             `(setf (write-timeout ,stream) ,write-timeout))
      ,@body))
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(defmacro with-serial-streams (binds &body body)
+  "Multiple `with-serial-streams` variant"
+  (if binds
+      `(with-serial-stream ,(car binds)
+         (with-serial-streams ,(cdr binds)
+           ,@body))
+      `(progn ,@body)))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ViewGit