[nxtlisp-cvs] r3 - nxtlisp
mcermak at common-lisp.net
mcermak at common-lisp.net
Mon Aug 20 20:44:41 UTC 2007
Author: mcermak
Date: Mon Aug 20 16:44:41 2007
New Revision: 3
Modified:
nxtlisp/remote-commands.lisp
Log:
sensor function bugfixing and minor update
Modified: nxtlisp/remote-commands.lisp
==============================================================================
--- nxtlisp/remote-commands.lisp (original)
+++ nxtlisp/remote-commands.lisp Mon Aug 20 16:44:41 2007
@@ -201,6 +201,8 @@
;; TODO: should the type/mode handling be this way? rethink
+;; document and add asserts to type and mode arguments
+;; if type is temperature
(defun sensor (port &optional (type :raw type-supplied-p)
(mode :raw mode-supplied-p) (stream *standard-nxt-io*))
"Retrieves values from the sensor plugged in <port> port."
@@ -209,10 +211,14 @@
;; in last call to set-sensor-state
(sensor-type (if type-supplied-p
type
- (extract-type port)))
+ (if (eql (extract-type port) nil)
+ :raw
+ (extract-type port))))
(sensor-mode (if mode-supplied-p
mode
- (extract-mode port))))
+ (if (eql (extract-mode port) nil)
+ :raw
+ (extract-type port)))))
;; let's decode the packet according to type/mode
(if (not (aref raw-packet 1))
(warn "sensor: Packet marked as not valid."))
@@ -225,6 +231,9 @@
:light-inactive) (extract-number (aref raw-packet 7)
(aref raw-packet 8)
:uword))
+ (:temperature (extract-number (aref raw-packet 9) ; the same as :celsius/:fahrenheit
+ (aref raw-packet 10)
+ :sword))
(t (case sensor-mode
((or :boolean :transition-cnt :period-counter
:celsius :fahrenheit) (extract-number (aref raw-packet 9)
More information about the Nxtlisp-cvs
mailing list