Port Open fails with T3.5, works with T3.2

Status
Not open for further replies.

paynterf

Well-known member
Hi,

I have a simple two-line program

HTML:
void setup()
{
	Serial.begin(115200);
	Serial.println("Starting Teensy");
  /* add setup code here */

}

This compiles and works fine with a T3.2, but when I compile this same program for a T3.5 & upload, I get a 'Port failed to open' error. I have tried this trick with two different T3.5's with the same result.

I have verified that the Tools->Serial option is set for 'Serial', and I have tried using the reset button to make sure the 3.5 is in programming mode - no luck.

Am I missing something here?

TIA,

Frank
 
T3.5 is probably too fast and starts Serial.println(whatever) before the other side is ready to receive data after just having been initialized with Serial.begin().

Add a delay(100) after Serial.begin() and check if this helps. Adapt the delay time if needed.
 
To add to what Theremingenieur says, in my latest project (on T3.6) I've had to add a delay(2000) after Serial.begin. Anything less hasn't worked! Your situation may be different.
 
If you want to see first Serial prints something like this is best. Results also vary with choice of SerMon The startup time will be changing with next beta #4 and release of TD 1.42 - this will still work. In TD_1.42 PJRC is including a teensy_sermon smarter alternative to the IDE SerMon that will show under 'Tools / Ports'.

Code:
  Serial.begin(115200);
  while (!Serial && millis() < 3000 ) ;
  Serial.print( "Teensy Online @ millis=" );
  Serial.println( millis() );

This will wait up to 3 seconds for Serial to appear - and after that connected to USB or not - it will continue
 
Thanks for the quick replies, but it's still not working for me. I added a couple of lines in loop() to blink the built-in LED, so I know the program is actually uploading and running OK. If I change the delay time around the loop and reupload, the built-in LED behavior changes appropriately. However, even with the code suggested by defragster (and even with the time in the 'while' statement increased to 13000) I still don't get any printout.

Interestingly though, the 'while' statement clearly falls through to loop() after about 6 seconds, even with the timeout value set to 13000. So it appears that the '!Serial' portion of the AND statement goes FALSE before the 13000 millisec timeout elapses, but I still don't get any prints.

I also changed the baud rate around a bit, but that doesn't effect anything.

Of course, this all works fine on the T3.2 - here's the code

HTML:
const int LED_PIN = 13;


void setup()
{
	Serial.begin(115200);
	while (!Serial && millis() < 13000);
	Serial.print("Teensy Online @ millis=");
	Serial.println(millis());
	Serial.println("Starting Teensy");

	pinMode(LED_BUILTIN, OUTPUT);

  /* add setup code here */

}

void loop()
{
	bool status = digitalRead(LED_BUILTIN);
	digitalWrite(LED_BUILTIN, !status);
	delay(1250);
	Serial.println("blink");

  /* add main program code here */

}

and here's the printout from the T3.2

HTML:
Opening port
Port open
Teensy Online @ millis=3412
Starting Teensy
blink
blink
blink
blink
blink
blink
blink

Port closed

Frank
 
That is ODD - even on the T_3.2 - I've seen it take 2000 or 2500 millis with IDE SerMon - but not anything over 3400?

Try TyCommander - it is what I use and it works much better in general.

Or update to TD_1.42 Beta 3 - it has the improved teensy_sermon in early debug state and it might give feedback Paul can use to help.

And as KurtE notes below - I've not seen any trouble on T_3.5 or T_3.6
 
Works fine on one of my T3.5s... I am currently running current beta plus TyCommander...

Code:
Teensy Online @ millis=388
Starting Teensy
blink
blink
blink
blink
blink
blink
blink
blink
blink
blink
blink
 
Status
Not open for further replies.
Back
Top