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:     (setq *wdt-reset* t)
      (format t "wdt reset found~%")))
  
  (defun bootfinish-callback (serial str result fail-result)
    (format t "Machine shell start~%")
    (serial-run serial "su" "shell@gladiator:/ #" "shell@gladiator:/ $" 60)
    (serial-run serial "getprop | grep dev.bootcomplete" result fail-result 60)
    (format t "Now do reboot machine~%")
    (serial-run-wait serial "svc power shutdown" "" "shell@gladiator:/ #"))
  
  (defun mboot-callback (serial str result fail-result)
    (serial-force-output serial "reset"))
  
  (defvar *list-command*
    (list
     (cons (list "Power down" "Power down" nil) 'power-callback)
     (cons (list "<< MStar >>#" "<< MStar >>#" nil) 'mboot-callback)
     (cons (list "Booting Linux" "Booting Linux" nil) 'startup-callback)
     (cons (list "wdt_reset = "  "wdt_reset = 0" "wdt_reset = 1") 'wdt-detect)
     (cons (list "shell@gladiator:/ " "[dev.bootcomplete]: [1]" "1|shell@gladiator:/ #") 'bootfinish-callback)
     ))
  
  ;; (setq *list-command* (list
  ;;    (cons (list "Power down" "Power down" nil) 'power-callback)
  ;;    (cons (list "<< MStar >>#" "<< MStar >>#" nil) 'mboot-callback)
  ;;    (cons (list "Booting Linux" "Booting Linux" nil) 'startup-callback)
  ;;    (cons (list "wdt_reset = "  "wdt_reset = 0" "wdt_reset = 1") 'wdt-detect)
  ;;    (cons (list "shell@gladiator:/ " "[dev.bootcomplete]: [1]" "1|shell@gladiator:/ #") 'bootfinish-callback)
  ;;    ))
  (defvar *list-string*
    (list "<< MStar >>#" "Emergency Remount" "Restarting system" "Power down" "Booting Linux" "wdt_reset = " "shell@gladiator:/ $"
           "shell@gladiator:/ #" "[dev.bootcomplete]: [1]" "1|shell@gladiator:/ #"))
  
  ;; (setq *list-string* (list "<< MStar >>#" "Emergency Remount" "Restarting system" "Power down" "Booting Linux" "wdt_reset = " "shell@gladiator:/ $"
  ;;          "shell@gladiator:/ #" "[dev.bootcomplete]: [1]" "1|shell@gladiator:/ #"))
  
  (defvar *filter-string*
    (list "su" "getprop" "grep" "svc power"))
  
  (defun serial-loop (serial)
    (let ((str (serial-log-get -1)))
  
negative.code:   (sleep 1)
    (wait-shell *serial* "" 60)
    (loop (serial-loop *serial*)))
  
  ;;;;;TEST
  (serial-force-output *serial* "")
  (top-activity *serial*)
  