 void loop() {
   while(Serial.available() > 0) {
     char x = Serial.read();
-    if (x != '\n' && x != '\r') messageBuffer[index++] = x;
-    if (index == 6) process();
+    if (x == '!') index = 0;      // start
+    else if (x == '.') process(); // end
+    else messageBuffer[index++] = x;
   }
 }
 

  } else if (strcmp(cmd, "02") == 0) {
      dr(pin, val);
  } else {
    Serial.println(-1);
  }
}


/*
 * Digital read
 */
void dr(char *pin, char *val) {}

