   {
     char c = SerialUSB.read();
 
-    if (c == '\n' || c == '\r')
-    {
-      serialcomplete = true;
+    if (c == '\n' || c == '\r' || c == 'X')
+    {
+      if (input != "")
+      {
+        serialcomplete = true;
+      }
       break;
     }
     input += c;


  if (serialcomplete)
  {
    switch (input.charAt(0))
    {
    case 'W':
      break;
    case 'R':
      break;
    case 'D':
      break;
    case 'E':
      break;
    default:
      SerialUSB.write("Invalid serial command.");
    }
  }
}


      // Wait atleast 40ns (P5A)
      delayMicroseconds(1);
      //SerialUSB.write("Sent 4 command bits and 16 data payload bits\r\n");

      return true;
    }
