     
     // execute current state
     update_machine();      
+}
+
+
+void get_command (int num_command) {
+  byte cmd_buffer;
+
+  while (Wire.available()) {
+    cmd_buffer = Wire.read();
+    execute_command(cmd_buffer);
   }
 }
 


void loop() {
  delay (100);
}

void process_command (int num_command) {
  byte cmd_buffer;

  while (Wire.available()) {
  
    cmd_buffer = Wire.read();
    
    if (!state.ready) {
      if (read_command (cmd_buffer, GM_CMD_READY)) {
	      state.ready = true;
	      update_machine();
      }
      continue;
    }

    if (GM_DEBUG) {

  state.motor_w = pin_init (MOTOR_W_PIN, OUTPUT, LOW);

  Wire.begin (GM_MACHINE_ADDRESS);
  Wire.onReceive (get_command);

 
  if (GM_DEBUG) {
     Serial.begin (115200);
     Serial.println("Machine Idle");
  } else {
  Serial.begin(19200);
  }
}

