anchor.diff:          (return-from run nil)))))
   
   (defun serial-run (serial comm result fail-result repeat)
  -  (loop while (>= repeat 0)
  -        do
  -           (serial-log-clear)
  -           (let ((r (serial-run-program serial comm result fail-result)))
  -             (if r
  -                 (progn
  -                   (serial-log-clear)
  -                   (return r)))
  -             (setq repeat (- repeat 1)))
  -        ))
  -
  -(defun serial-run-wait (serial comm result fail-result)
  +  (format t "run command: ~a ~%" comm)
  +  (when (wait-shell serial "" 10)
  +    (loop while (>= repeat 0)
  +          do
  +             (serial-log-clear)
  +             (let ((r (serial-run-program serial comm result fail-result)))
  +               (if r
  +                   (progn
  +                     (sleep 1)
  +                     (serial-log-clear)
  +                     (return r)))
  +               (setq repeat (- repeat 1)))
  +          )))
  +
  +(defun serial-run-wait (serial comm result fail-result &key error collect)
  +  ;;success return result
  +  ;;failed will rerun the command
  +  ;;error handle used work error happen,ensure need redo comm
  +  (format t "run command: ~a ~%" comm)
     (when (wait-shell serial "" 10)
       (serial-log-clear)
       (serial-force-output serial comm)
  
positive.code:   (sleep 1)
    (wait-shell *serial* "" 60)
    (loop (serial-loop *serial*)))
  
negative.code:     (loop while t
            do
               (let ((s (serial-log-search result))
                     (f (if fail-result (serial-log-search fail-result) nil))
                     (cont t))
                 (if (and f fail-result)
                     (progn
                       (when error
                         (setq cont (funcall error f)))
                       (if cont
                           (progn
                             (format t "failed,run retry~%")
                             (wait-shell serial "" 10)
                             (serial-log-clear)
                             (serial-force-output serial comm)
                             (sleep 2))
                           (progn
                             (serial-log-clear)
                             (return f)))
                       )
                     (if s
                         (progn
                           (format t "wait ~a result ~a success~%" comm result)
                           (when collect
                             (setq s (funcall collect *serial-log*)))
                           (serial-log-clear)
                           (return s))))
                 )
            )))
  