     printTm(Serial, &tm);
     Serial.print("unixtime = ");
     Serial.println(t);
-    /*
-    Serial.println("...............");
-    struct RTCx::tm tm2;
-    RTCx::time_t t2 = 1347750631;
-    Serial.print("unixtime = ");
-    Serial.println(t2);
-    RTCx::gmtime_r(&t2, &tm2);
-    printTm(Serial, &tm2);
-    RTCx::time_t t2a = RTCx::mktime(&tm2);
-    printTm(Serial, &tm2);
-    Serial.print("unixtime = ");
-    Serial.println(t2a);
-    Serial.println("...............");
-    */
-    /*
-    rtc.readClock(tm, RTCx::ALARM0);
-    printTm(Serial, &tm);
-    rtc.readClock(tm, RTCx::ALARM1);
-    printTm(Serial, &tm);
-    */
-    
-    /*
-      rtc.readClock(tm, RTCx::TIME_POWER_FAILED);
-      printTm(Serial, &tm);
-      rtc.readClock(tm, RTCx::TIME_POWER_RESTORED);
-      printTm(Serial, &tm);
-    */
-  
     Serial.println("-----");
   }
 
   while (Serial.available()) {
     char c = Serial.read();
-    if ((c == '\r' || c == '\n')) {
+    if ((c == '\r' || c == '\n' || c == '\0')) {
       if (bufPos <= bufLen && buffer[0] == 'C') {
 	// Check time error
 	buffer[bufPos] = '\0';

/*

 */

#include <Wire.h>

	printTm(Serial, &tm);
	Serial.println("~~~~~");
      }
      if (bufPos <= bufLen && buffer[0] == 'X') {
	// Set calibration value
	buffer[bufPos] = '\0';
	if (rtc.getDevice() == RTCx::MCP7941x) {
	  int8_t oldCal = rtc.getCalibration();
	  char *endptr;
	  long cal = strtol(&(buffer[1]), &endptr, 0);
	  if (cal >= -127 && cal <= 127 && endptr == &buffer[bufPos]) {
	    Serial.print("Previous calibration: ");
	    Serial.println(oldCal, DEC);
	    Serial.print("Calibration: ");
	    Serial.println(cal, DEC);
	      rtc.setCalibration(cal);
	  }
	  else 
	    Serial.println("Bad value for calibration");
	}
	else {
	  Serial.println("Cannot set calibration: not a MCP7941x");
	}
      }
      if (bufPos <= bufLen && buffer[0] == 'M') {
	// Set SQW mode
	buffer[bufPos] = '\0';
	  char *endptr;
	  long mode = strtol(&(buffer[1]), &endptr, 0);
	  if (mode >= RTCx::freq1Hz && mode <= RTCx::freqCalibration
	      && endptr == &buffer[bufPos]) {
	    if (rtc.setSQW((RTCx::freq_t)mode)) { 
	      Serial.print("SQW: ");
	      Serial.println(mode, DEC);
	    }
	    else
	      Serial.println("Could not set SQW");
	  }
	  else 
	    Serial.println("Bad value for SQW");
      }
      bufPos = 0;
    }
    else if (bufPos < bufLen)
