I am trying to receive current time from the PC using Time library. The final code is a result of few sample codes available.
It is pretty simple - ask for "synchronization" using ASCII character for BEL 07. But I get no response from PC.
None of the examples I have checked said anything about how to verify if the BELwas actually received in PC or if I need to run any specific app in PC.
Did missed something?
PS I have included debugging lines in code just to give an idea what I have done so far to analyze this.
Cheers Vaclav
this is currently in setup function
....
setSyncProvider( requestSync); //set function to call when sync required
Serial.println(F("Waiting for sync message"));
lcd.clear();
lcd.print(F("Waiting for sync"));
long lTimeStart, lTimeout = 2000;
lTimeStart = millis();
while(!Serial.available() & (millis() < lTimeout + lTimeStart));
lcd.clear();
lcd.print("timeout ");
lcd.setCursor(0,1);
lcd.print(lTimeStart);
delay(DELAY_LCD);
if(Serial.available() )
{
lcd.clear();
lcd.print("processSyncMessage");
delay(DELAY_LCD);
for(;;);
processSyncMessage();
}
else
{
lcd.clear();
lcd.print(F("NO serial received"));
delay(DELAY_LCD);
for(;;);
}
....
end of code in setup
time_t requestSync()
{
lcd.clear();
lcd.print(TIME_REQUEST);
lcd.setCursor(0,1);
lcd.print(F("requestSync()"));
delay(DELAY_LCD);
int bytesSent = Serial.write(TIME_REQUEST); // ASCII 7 to request time message from PC
delay(2000);
Serial.print(TIME_REQUEST);
if(!bytesSent)
{
// ASSERT(!Serial.write(TIME_REQUEST), "Serial.write(TIME_REQUEST) from PC ")
lcd.clear();
lcd.print(F("failed TIME_REQUEST"));
lcd.setCursor(0,1);
lcd.print(F("requestSync()"));
delay(DELAY_LCD);
}
return 0; // the time will be sent later in response to serial mesg
}