Serial Communications Trigger

Just a quick update. I wrote a simple routine that sends out a ctl-E and if there is a response I continue with sending the serial data.

The serial data in my program takes 70ms to execute.
The routine that checks for a terminal response takes about 1ms to execute (serial port at 115,000)

So, it looks like I can save 69ms each program cycle by using a routine that checks for a terminal response. Below is a copy of the code in the event it is useful to someone else.

unsigned long start, finished;      // Timer variables
void setup()
{
Serial.begin(115200);
}

void loop() 
{
 start=millis();                    // Start timer
  Serial.write(5);                  // ^E enquiry character
  //delay (50);                     // No delay was necessary, but initially had it in the code to test it out
  if (Serial.available() > 0)       // Check for serial data response
  {  
   finished=millis();               // Stop timer
    Serial.print(finished-start);   // Print program execution time to terminal window
    Serial.println(" ms ");
  }
}