Questing using requestSync() in the Time library

I’m trying to use the TimeSerial example in the Time library examples to understand getting
a unix time serial value. I’ve loaded the TimeSerial example and it compiles fine (Using
Arduino 1.0.5-r2) When I run the sketch and open the serial monitor, I get the following
message, “Waiting for sync message”. It will sit there until I enter a unix time serial.
If I enter “T1357041600” and click SEND, it will start posting the time represented
by this unix time serial. So, I would like to use this sketch to programmatically
retrieve a unix time serial of the current PC time and make it available to breakdown
into a human readable form.

Question is, how do I submit a time serial to the
serial port without using the keyboard? I’ve tried Serial.print(“T1357041600”) and
Serial.write(“T1357041600”). Neither of these will trigger a response from the requestSync()
function. The TimeSerial sketch code is reproduced here:

/* 
 * TimeSerial.pde
 * example code illustrating Time library set through serial port messages.
 *
 * Messages consist of the letter T followed by ten digit time (as seconds since Jan 1 1970)
 * you can send the text on the next line using Serial Monitor to set the clock to noon Jan 1 2013
 T1357041600  
 *
 * A Processing example sketch to automatically send the messages is inclided in the download
 * On Linux, you can use "date +T%s > /dev/ttyACM0" (UTC time zone)
 */ 
 
#include <Time.h>  

#define TIME_HEADER  "T"   // Header tag for serial time sync message
#define TIME_REQUEST  7    // ASCII bell character requests a time sync message 

void setup()  {
  Serial.begin(9600);
  while (!Serial) ; // Needed for Leonardo only
  pinMode(13, OUTPUT);
  setSyncProvider( requestSync);  //set function to call when sync required
  Serial.println("Waiting for sync message");
}

void loop(){    
  if (Serial.available()) {
    processSyncMessage();
  }
  if (timeStatus()!= timeNotSet) {
    digitalClockDisplay();  
  }
  if (timeStatus() == timeSet) {
    digitalWrite(13, HIGH); // LED on if synced
  } else {
    digitalWrite(13, LOW);  // LED off if needs refresh
  }
  delay(1000);
}

void digitalClockDisplay(){
  // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year()); 
  Serial.println(); 
}

void printDigits(int digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}


void processSyncMessage() {
  unsigned long pctime;
  const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013

  if(Serial.find(TIME_HEADER)) {
     pctime = Serial.parseInt();
     if( pctime >= DEFAULT_TIME) { // check the integer is a valid time (greater than Jan 1 2013)
       setTime(pctime); // Sync Arduino clock to the time received on the serial port
     }
  }
}

time_t requestSync()
{
  Serial.write(TIME_REQUEST);  
  return 0; // the time will be sent later in response to serial mesg
}

So, I would like to use this sketch to programmatically retrieve a unix time serial of the current PC time and make it available to breakdown into a human readable form.

Retrieve it from where? There has to be something on the PC side listening to the serial port, understanding the Arduino request, and generating an appropriate response.

I've tried Serial.print("T1357041600") and Serial.write("T1357041600"). Neither of these will trigger a response from the requestSync() function.

You can't expect the Arduino to read what you wrote to the serial port.

Thanks for responding. Two very good and valid points. It looks like I need the "Processing" sketch running to enable the PC to "listen".