   eeprom.setType(eepromType);
 }
 
+
+/**  */
+void loop() {
+
+#ifdef TEST
+  testCode();
+#endif // TEST
+
+#if (INTERACTIVE != 0)
+  loopInteractive();
+#else
+  loopNonInteractive();
+#endif // INTERACTIVE
+}
+
+#if (INTERACTIVE == 0)
+ // Calculated based on max input size expected for one command
+ #define INPUT_SIZE   64
+ // Maximum number of options expected
+ #define MAX_OPTIONS   3
+
+char inputLine[INPUT_SIZE+1] = { 0 };
+int lineLength = 0;
+bool lineComplete = false;
+
+/** loop() function for the non-interactive version. */
+void loopNonInteractive() {
+
+  // read characters from serial interface and put them in input buffer until EOL
+  int ch = Serial.read();
+
+  if ( ch == -1 ) return;
+  
+  // check for LF or add character to inputLine
+  if ( ch == 0x0a || ch == 0x0d ) {
+    lineComplete = true;
+  }
+  else {
+    // Add the final 0 to end the C string
+    inputLine[lineLength++] = ch;
+    inputLine[lineLength] = 0;
+  
+    // too many chars entered? clear line buffer and issue warning
+    if ( lineLength == INPUT_SIZE ) {
+      lineLength = 0;
+      inputLine[lineLength] = 0;
+      Serial << F("ERR: max. line length exceeded!") << endl;
+    }
+  }
+
+  //
+  // valid commands:
+  // 't ?' - get E(E)PROM type
+  // 't <t>' - set E(E)PROM type
+  // 'r <addr> <len>' - read <len> bytes starting from address <addr>
+  // 'w <addr> <bytes>' - write <bytes> (in IHEX format) to address <addr> 
+  //
+  if ( lineComplete ) {
+    
+    Serial << strlen(inputLine) << " '" << inputLine << "'" << endl;
+
+    char *command = NULL;
+    int nopts = 0;
+    char* token = strtok(inputLine, " ");
+    char *option[MAX_OPTIONS];
+    bool err = false;
+
+    while ( token && !err ) {
+      
+      // 'command' token must have length of 1
+      if ( strlen(token) == 1 && !command ) {
+        command = token;
+      }
+      // 'command' token found, now check for options
+      else if ( command ) {
+        if ( nopts == MAX_OPTIONS ) {
+          err = true;
+          Serial << F("ERR: maximum number of options exceeded") << endl;
+        }
+        option[nopts++] = token;
+      }
+      else if ( !command ) {
+        Serial << F("ERR: no command found!") << endl;
+        err = true;
+      }
+
+      // find next token
+      token = strtok(0, " ");
+    }
+
+    // final control output after tokenisation
+    if ( command && !err ) {
+      Serial << F("command= '") << command << "'" << endl;
+      for ( int i=0; i<nopts; ++i )
+        Serial << F("option[") << i << F("]= '") << option[i] << "'" << endl;
+    }
+
+    if ( !err ) {
+      switch ( command[0] ) {
+        case 't': break;
+        case 'r': break;
+        case 'w': break;
+        case '?': break;
+        default:
+          Serial << F("ERR: unknown command entered!") << endl;
+          err = true;
+      }
+    }
+
+    if ( !err ) {
+      Serial << F("OK") << endl;
+    }
+
+    lineLength = 0;
+    inputLine[lineLength] = 0;
+    
+    lineComplete = false;
+  }
+}
+#endif // INTERACTIVE
+
 #if (INTERACTIVE != 0)
 //
 // flash strings for the main menu

        "t    - set EPROM <t>ype\n"
        "h, ? - display this <h>elp\n"
      /*  "Ctrl-] - leave miniterm.py\n" */ );
#endif // INTERACTIVE

#if (INTERACTIVE == 0)
 // Calculate based on max input size expected for one command
 #define INPUT_SIZE 64

char inputLine[INPUT_SIZE+1] = { 0 };
int lineLength = 0;
bool lineComplete = false;
#endif // INTERACTIVE

/**  */
void loop() {

  static bool first = true;
#if (INTERACTIVE == 0)
  static byte output_format = 1;
#else
  static byte output_format = 0;
#endif // INTERACTIVE

#if (INTERACTIVE == 0)
  
  int ch = Serial.read();

  if ( ch == -1 ) return;
  
  // check for LF or add character to inputLine
  if ( ch == 0x0a || ch == 0x0d ) {
    lineComplete = true;
  }
  else {
    // Add the final 0 to end the C string
    inputLine[lineLength++] = ch;
    inputLine[lineLength] = 0;
  
    // too many chars entered? clear line buffer and issue warning
    if ( lineLength == INPUT_SIZE ) {
      lineLength = 0;
      inputLine[lineLength] = 0;
      Serial << F("ERR: max. line length exceeded!") << endl;
    }
  }
#endif // INTERACTIVE

#ifdef TEST
  testCode();
#endif // TEST

#if (INTERACTIVE != 0)
  uint32_t total_length = 64;
  uint32_t i, len, nBytes;
  

            len -= nBytes;
            
            eeprom.read(eepromAddr, eepromData, nBytes);
            if ( output_format == 0 )
              dumpHex(eepromData, nBytes, eepromAddr);
            else
              writeIhexData(Serial, eepromData, nBytes, eepromAddr);
