 
   Serial.print("Sent telegram of ");
   Serial.print(size);
-  Serial.print(" bytes");
+  Serial.println(" bytes");
+
   return true;
 }
 

uint16 readTelegram(byte *buffer, uint16 size) {
  uint16 i;
  byte state = 0;
  for (i = 0; i < size; i++) {
    int b = P1_INPUT.read();
    if (b < 0) {
      Serial.println("Read timed out before telegram end sequence");
      return 0;
    }
    buffer[i] = b;

    // Each telegram ends with a line like this:

        if (b == '\n') state++; else state = 0;
    }

    if (state == 9) {
      readGarbage(true);
      return i;
    }
  }

  Serial.print("Telegram buffer overflow after ");
  Serial.print(size);
  Serial.println(" bytes");

  readGarbage(false);

  return 0;
}

