         min_index = i;
       }
     }
-    if (times_buffer[i] != 0)
-      level++;
   }
   
-  // compute baudrate
-  baud = 2 * (1e6 / min_step);
-   
-  // count start bit
-  for (byte i = 0; i < 60; i++) {
-    // count start bit
-    if (times_buffer[i] > (min_step * 15)) {
-      start_bit++;
-    }
-  }
-}
-
-numvar printRAW(void) {  
+  // compute auto baudrate
+  auto_baud = 2 * (1e6 / min_step);
+}
+
+numvar printRaw(void) {  
   // display array
-  /*
-  for (byte i = 0; i < 60; i++) {
-    Serial.print(times_buffer[i]);
-    Serial.print(" ");
-  }
-  Serial.println();*/
-      
+  // banner
+  printf_P(PSTR("Index | Time (ms) | Hex  | Dec | ASCII\r\n"));    
+  // datas
+  for (byte i = 0; i < ROW_COUNT(rx_bytes); i++) {
+    printf_P(PSTR("%03d   | %6lu    | 0x%02x | %03d | %c  \r\n"), i, rx_bytes[i].time, rx_bytes[i].value, rx_bytes[i].value, rx_bytes[i].value);    
+  }
+  printf_P(PSTR("\r\n"));
+  return 0;
+}
+
+numvar printStat(void) {       
   // display min_step time and compute baudrate
-  printf_P(PSTR("start bit : %5d\r\n"), start_bit);
   printf_P(PSTR("min step  : %5d us\r\n"), min_step/2);
   printf_P(PSTR("max step  : %5d us\r\n"), max_step/2);
-  printf_P(PSTR("level     : %5d\r\n"), level);
-
-  return 0;
-}
-
+  return 0;
+}
+
+numvar setBaud(void) {
+  uart_baud = getarg(1);
+  Serial1.begin(uart_baud);
+  return 0;
+}
+
+// return true if theoric baudrate and measure baudrate are 10% accuracy
 bool is_baud(long theoric, long measure) {
   return (measure > (theoric - theoric * 0.1)) and (measure < (theoric + theoric *0.1));
 }
 
-numvar printBaud(void) {
-  printf_P(PSTR("baud measured  : %6lu bps\r\n"), baud);
-  // convert measured baud to estimated baud
+// convert "baud" (like 305) to normalized baud (like 300 or 9600)
+unsigned long norm_baud(unsigned long baud) {
   long estim_baud = 0;
-  
   if (is_baud(300, baud))
     estim_baud = 300;
   else if (is_baud(600, baud))

    estim_baud = 57600;  
  else if (is_baud(115200, baud))
    estim_baud = 115200;  
  
  printf_P(PSTR("baud estimated : %6lu bps\r\n"), estim_baud);
  return 0;  
}


  // search minimal/maximal time step
  max_step = 0;
  min_step = 0xFFFF;

  for (byte i = 0; i < 60; i++) {
    // skip special values
