     // If we received a command, the server must be 'RUNNING'.
     if (system_state == CONNECTED) 
     {
+      Serial.println("STATE: RUNNING");
       system_state = RUNNING; 
     }
+    
+    // Update the timestamp of last received command.
+    last_command_time = current_command_time;
   }
   
   // Properly null-terminate the buffer.

  if (!adk.isReady())
  {
    // If not connected to USB, we are 'DISCONNECTED'.
    system_state = DISCONNECTED;
    
    // Wait for USB connection again.
    yield();

  // Create secondary tasks for system.
  Scheduler.startLoop(motorUpdateLoop);
  Scheduler.startLoop(serialConsoleLoop);
  Scheduler.startLoop(winchUpdateLoop);
//  Scheduler.startLoop(winchTestLoop);
//  Scheduler.startLoop(hd5SimLoop);
  
