   // Initialize debugging serial console.
   Serial.begin(115200);
   
+  // Start the system in the disconnected state
+  system_state = DISCONNECTED;
+  
   // Make the ADK buffers into null terminated string.
   debug_buffer[INPUT_BUFFER_SIZE] = '\0';
   input_buffer[INPUT_BUFFER_SIZE] = '\0';

 */
void motorUpdateLoop()
{
  // Only run while connected via USB.
  if (!adk.isReady()) {
    yield();
    return;
  }
  
  // Wait for a fixed time period.
  delay(100);
  
  // Decay all motors exponentially towards zero speed.
  //for (size_t motor_idx = 0; motor_idx < NUM_MOTORS; ++motor_idx) {
  //  motor[motor_idx]->velocity(motor[motor_idx]->velocity() * 0.8);
  //}
  
  // TODO: move this to another location (e.g. Motor)
  // Send motor status update over USB
  snprintf(output_buffer, OUTPUT_BUFFER_SIZE,
    "{"
      "\"m0\":{"
        "\"v\":%f,"
        "\"c\":%f"
      "},"
      "\"m1\":{"
        "\"v\":%f,"
        "\"c\":%f"
      "}"
    "}",
    motor[0]->velocity(), motor[0]->current(),
    motor[1]->velocity(), motor[1]->current()
  );
  send(output_buffer);
  
  // TODO: Remove this hack
  // Send encoder status update over USB
  long pos = ((platypus::Winch*)sensor[2])->position();
  snprintf(output_buffer, OUTPUT_BUFFER_SIZE,
    "{"
      "\"s2\":{"
        "\"type\":\"winch\","
        "\"depth\":%ld"
      "}"
    "}",
    pos
  );
  send(output_buffer);
}

/**


void loop() 
{
  // Keep track of how many reads we haven't made so far.
  size_t response_counter;
  
  // Number of bytes received from USB.
  uint32_t bytes_read = 0;
  
  // Do USB bookkeeping.
  Usb.Task();
  
  // Report system as shutdown if not connected to USB.
  if (!adk.isReady())
  {
    // If not connected to USB, we are 'DISCONNECTED'.
    system_state = DISCONNECTED;
    
    // Wait for USB connection again.
    yield();
    return;
  } 
  else 
  {  
    // If connected to USB, we are now 'CONNECTED'!
    if (system_state == DISCONNECTED)
    {
      system_state = CONNECTED; 
    }
  }
        
  // Attempt to read command from USB.
  adk.read(&bytes_read, INPUT_BUFFER_SIZE, (uint8_t*)input_buffer);
  if (bytes_read <= 0) 
  {
    // If we haven't received a response in a long time, maybe 
    // we are 'CONNECTED' but the server is not running.
    ++response_counter;
    if (response_counter > RESPONSE_TIMEOUT)
    {
      system_state = CONNECTED; 
    }
    
    // Wait for more USB data again.
    yield();
    return;
  } 
  else 
  {
    // If we received a command, the server must be 'RUNNING'.
    if (system_state == CONNECTED) 
    {
      system_state = RUNNING; 
    }
  }
  
  // Properly null-terminate the buffer.
