Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Change in new Teensyduino version breaks existing code

  1. #1
    Senior Member
    Join Date
    May 2015
    Posts
    115

    Change in new Teensyduino version breaks existing code

    Hello Paul

    In Teensyduino 1.85 you made a change which breaks exsiting sketch code.
    In previous TeensyDuino versions the function Keyboard.send_now() had a bool return value and I wrote in my sketch:

    Code:
    if (!Keyboard.send_now())
    {
         Serial.println("Error pressing USB key");
         return false;
    }
    This results in a compiler error now because you changed

    Code:
    bool send_now(void) { return usb_keyboard_send(); }
    into

    Code:
    void send_now(void) { usb_keyboard_send(); }
    You also changed usb_keyboard_send() so that it returns integer 0 and -1 instead of true and false as before.

    But I cannot see any reason why this return value is not passed through in send_now().

    Please think that with this kind of changes you will always break existing code unnecessarily.

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,416
    Hi Elmue

    Which board are you compiling for? A Teensy 3.x, LC or 2?

    If for a 3.x or LC, I could be wrong, but if you look at github at the file in blame mode:
    https://github.com/PaulStoffregen/co...usb_keyboard.h

    It looks like that line has been that way for 5 years...

  3. #3
    Senior Member
    Join Date
    May 2015
    Posts
    115
    Hello

    Maybe that this has been changed a longer time before 1.85.
    I noticed it recently when I updated Teensyduino from an older version.

    But the fact stays that this change is unnecessary and breaks existing code.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,554
    There is no Teensyduino version 1.85. At the rate we're going, currently 1.41 released and 1.42 in beta and about 5 releases per year, we ought to get there around 2026. Well, except for some major ideas I've had on the back burner for years, which would become version 2.0, if I ever get the time....

    There is Arduino 1.8.5. But that's only the IDE, not Teensy's support.

  5. #5
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,416
    Quote Originally Posted by Elmue View Post
    Hello

    Maybe that this has been changed a longer time before 1.85.
    I noticed it recently when I updated Teensyduino from an older version.

    But the fact stays that this change is unnecessary and breaks existing code.
    The question is which change? It looks like it has not changed in 5 years in either the T3x or
    T2x (https://github.com/PaulStoffregen/co...rial/usb_api.h) versions? Maybe you edited your earlier version to your own liking?

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,554
    FWIW, I do try to maintain backwards compatibility. There have been some exceptions, like the recent updates to USB MIDI support, but those are only done when there's a very compelling reason.

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,554
    I just looked in my very old backups. The very first version of cores/teensy3/usb_keyboard.h came in Teensyduino 1.10. Keyboard.send_now() returned void in that very first version.

    That installer supported Arduino versions 0022, 0023, 1.0, 1.0.1 and 1.0.2 (the most recent at the time). The timestamp on the files says that was Nov 6, 2012.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •