Leonardo does not show Serial port after application loaded - reset? SOLVED

Root cause found and fixed .. a word of warning about Leonardo and related tip.

The root cause of the problem seemed to be an error in an interrupt or setup, causing the system to keep re-running setup and hence not showing the port.

Since error handling is not enable on the arduino, I used another trick to catch the error and keep the system from going into loop / dea mode. The details below explain the code change.

Create a variable ..
byte setupRunTimes = 0;

Then in setup .. add this code before any other code, except Serial.begin(), in void setup():

   setupRunTimes++;
   if (setupRunTimes>1){
      return; 
   }

Add this code in the first part of void loop():

  if( setupRunTimes > 1 ){
    Serial.println("error on setup");
    delay(1000);
    return;
  }

Hope that helps someone.