anchor.diff:    (setf (aref vector location) (ldb (byte 8 0) value))
     (setf (aref vector (1+ location)) (ldb (byte 8 8) value)))
   
  -(defun make-command (command-id &rest args)
  -  "Creates a nxt command of type indicated by `command-id'.
  -All the arguments are keyword value pairs.  These should
  -be matched in the command struct for the command.
  -
  -So for example:
  - 
  -  (make-command 'find-first :file-name \"*.*\")
  -
  -creates a valid command."
  -  (let* ((command-data (command-data-for-id command-id))
  -	 (command-length (second command-data))
  -	 (result (make-array command-length 
  -			     :element-type 'unsigned-byte
  -			     :initial-element 0)))
  -    ;; First write first few bytes.
  -    (write-uword-to-command result (first command-data) 0)
  -
  -    ;; Now fill in the rest.
  -    (loop :for (key value . rest) :on args :by #'cddr 
  -       :for key-datum = (getf command-data key) :do
  -       (progn
  -	 (unless key-datum (error "Can not find key: ~S back in data for command." key))
  -	 (case (first key-datum)
  -	   ('byte (write-byte-to-command result value (second key-datum)))
  -	   ('string (write-string-to-command result value (second key-datum) (third key-datum)))
  -	   ('uword (write-uword-to-command result value (second key-datum))))))
  -    result))
  -
  +
  +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  +;;; CONNECTION
  +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   (defvar *connection* nil)
   
   (defun open-connection (&optional (dev-name "/dev/tty.NXT-DevB-1"))
  
positive.code:   (def-nxt-command 'message-read         #x00 #x13 
  		   :remote-inbox '(byte 2) :local-inbox '(byte 3) :remove '(byte 4)))
  
  
  (defun command-data-for-id (command-id)
    (let ((result (cdr (assoc command-id *command-table*))))
      (unless result (error "No command found for id: ~S~%" command-id))
      result))
  
  (defun def-nxt-command (command-id command-type code &rest rest)
    (setf *command-table* (remove command-id *command-table* :key #'car))
    (setf *command-table* (push
  			 (cons  command-id 
  				(loop :for (key value . ignored) :on rest :by #'cddr
  				   :maximize 
  				   (case (car value)
  				     ('uword  (1+ (second value)))
  				     (t (apply #'max (cdr value)))) :into max-length
  				   :finally (return 
  					      (cons (+ command-type (* 256 code))
  						    (cons (max 2 (1+ max-length)) rest)))))
  			 *command-table*)))
  
  (defun write-byte-to-command (vector value location)
    (assert (arrayp vector) (vector) "First argument should be a vector!")
    (setf (aref vector location) value))
  
negative.code:        (setf (aref result i) (read-from-nxt-byte)))
      result))
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;; LEFT OVER FROM OLD CODE
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (defun send-to-nxt (command)
    "Write command to nxt and read reply if a reply is expected."
    (write-to-nxt command)
    (when (reply-expected command)
      (read-nxt-reply)))
  
  (defun reply-expected (command)
    "Returns T if a reply is expected.
  A reply is expected if the bit in position 7 (MSB) is 0"
    (eql 0 (ldb (byte 1 7) (aref command 0))))
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;; PARSING OUTPUT ???
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  (defun dump-message (message)
    (loop :for x :across message 
       :for i :from 0  :do
       (format t "~2D: ~3D ~16R~%" i x x)))
  
  (defun status (reply)
    (aref reply 2))
  
  (defun handle (reply)
    (aref reply 3))
  