 // Standard Arduino loop() function.
 //----------------------------------------
 
+char * do_external_cmd(char *cmd, int index)
+{
+  char end_char = cmd[index];
+  static char message[128];
+
+  // ensure everything is uppercase
+  str2upper(cmd);
+
+  // if command too long it's illegal
+  if (end_char != COMMAND_END_CHAR)
+  {
+    strcpy(message, "Ignored illegal command: '");
+    strcat(message, cmd);
+    strcat(message, "'");
+    return message;
+  }
+
+  // process the command
+  strcpy(message, "Would execute '");
+  strcat(message, cmd);
+  strcat(message, "'  command");
+  return message;
+}
+
 void loop(void)
 {
+  // gather any commands from controller
+  while (Serial.available()) 
+  {
+    char ch = Serial.read();
+    
+    if (CommandIndex < MAX_COMMAND_LEN)
+    { 
+      CommandBuffer[CommandIndex++] = ch;
+    }
+    
+    if (ch == COMMAND_END_CHAR)   // if end of command, execute it
+    {
+      CommandBuffer[CommandIndex] = '\0';
+      Serial.printf(F("%s\n"), do_external_cmd(CommandBuffer, CommandIndex-1));
+      CommandIndex = 0;
+    }
+  }
+  
   // handle all events in the queue
   while (event_pending() > 0)
   {

  }

  return "UNKNOWN MODE";
}



// Digital VFO program name & version
const char *ProgramName = "DigitalVFO";
const char *Version = "1.1";
const char *MinorVersion = ".2";
const char *Callsign = "vk4fawr";

// display constants - below is for ubiquitous small HD44780 16x2 display
