 int16_t sync_get_int() {
   uint8_t readpos = 0;
   uint8_t c;
+
   do {
     c = sync_blocking_read();
     if (c == SYNC_DELIMITER) break;

}

void sync_abort(char *msg) {
  Serial.print("SYNC aborted:");
  Serial.println(msg);
}

int8_t sync_blocking_read() {
  int8_t c;
  uint16_t startt = millis();

  do {
    c = Serial.read();
    if (millis() - startt > SYNC_SERIAL_TIMEOUT) {
      sync_abort("communication timed out");
      Sync.abort = 1;
      break;
    }


    CHECK_ABORT();

    watch_set_time(hours, minutes, seconds);

    uint16_t year = sync_get_int();
    uint8_t month = sync_get_int();
    uint8_t day = sync_get_int();
    uint8_t isleapyear = sync_get_int();

    CHECK_ABORT();

    watch_set_date(year, month, day, isleapyear);
    Serial.println("OK");
  }
}
