Skip to content

Leonardo: constructor with delay knocks out serial port #6277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Koepel opened this issue May 11, 2017 · 3 comments
Closed

Leonardo: constructor with delay knocks out serial port #6277

Koepel opened this issue May 11, 2017 · 3 comments
Labels
Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) Type: Bug USB: CDC serial Serial interface used by MCUs with native USB (e.g. Leonardo) to communicate with the computer

Comments

@Koepel
Copy link

Koepel commented May 11, 2017

In a forum in the Netherlands, someone encountered a possible bug: http://arduinoforum.nl/viewtopic.php?f=13&t=2533.
I can replicate the problem in Windows 10 and Ubuntu linux 17.04 with Arduino IDE 1.8.1 and 1.8.2 and with the Leonardo bootloader that came with version 1.6.8 and 1.8.2.

Below is a test sketch. After uploading, the serial port disappears and uploading once more is not possible. The delay() is needed and the parameter for the constructor is needed.

There is a workaround to be able to upload a sketch. I turn on the verbose output for upload in the preferences and when the Arduino IDE tries to upload then I press the reset button on the Arduino board.

class myLibT
{
  public:
    myLibT( char a);
};

myLibT::myLibT( char a) 
{
  delay(10);     // This delay together with the parameter kills the usb-serial.
}

myLibT serialwrecker( 0);   // the parameter is needed

void setup() 
{
}

void loop() 
{
}
@facchinm facchinm added Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) Type: Bug USB: CDC serial Serial interface used by MCUs with native USB (e.g. Leonardo) to communicate with the computer labels May 12, 2017
@facchinm
Copy link
Member

I think it is related with #5592 . In fact, since the static initializers are executed before init(), the timer responsible for delay() doesn't fire yet and the board simply hangs.
I'm launching @ArduinoBot on that PR so you can test the produced build and check if the problem disappears.

@Koepel
Copy link
Author

Koepel commented May 19, 2017

Tested with "arduino-PR-5592-BUILD-691-linux64.tar.xz" and the problem is gone. Thank you!

@sandeepmistry
Copy link
Contributor

Based on the last comment this is fixed now, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) Type: Bug USB: CDC serial Serial interface used by MCUs with native USB (e.g. Leonardo) to communicate with the computer
Projects
None yet
Development

No branches or pull requests

3 participants