Skip to content

serialEvent does not work with Leonardo (USB CDC Serial) [imported] #206

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
cmaglie opened this issue Nov 15, 2012 · 15 comments
Closed

serialEvent does not work with Leonardo (USB CDC Serial) [imported] #206

cmaglie opened this issue Nov 15, 2012 · 15 comments
Assignees

Comments

@cmaglie
Copy link
Member

cmaglie commented Nov 15, 2012

This is Issue 1031 moved from a Google Code project.
Added by 2012-09-03T19:30:50.000Z by pilot...@gmail.com.
Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Defect, Priority-High, Component-ATmega32U4

Original description

What steps will reproduce the problem?

  1. Load Examples ... 04. Communcations... SerialEvent example
  2. Add while (!Serial) ; after Serial.begin() in setup
  3. Upload to a Leonardo board, type stuff in the serial monitor

What is the expected output? What do you see instead?

Expected: Get back what I typed
Actual: Got nothing back

What version of the Arduino software are you using? On what operating
system? Which Arduino board are you using?

Arduino 1.0.1 on MacOS X 10.7.4 with a Leonardo R3 board

Please provide any additional information below.

I believe serialEvent is never called. I tried renaming it to serialEvent1 and serialEvent2 without any effect.

@moonpyk
Copy link

moonpyk commented Jan 25, 2013

I have this issue with Arduino 1.0.3 on Windows, using a Leonardo R3 Board.

@KaiKrause
Copy link

Same here. Arduino 1.0.3 Windows, orig. Leonardo R3

@mwsh
Copy link

mwsh commented Jun 29, 2014

Are there any news about that bug?

@matthijskooijman
Copy link
Collaborator

It seems this simply not implemented. Looking at the 1.5.x branch (but I think it's the same for 1.0.x), this feature is implemented by serialEventRun which is called by main()

It should be fairly easy to add this, though. Only thing that might be tricky is to detect inside main.cpp wether CDC is available, but we could always use a weak reference to detect it at runtime.

@WiredWonder
Copy link

No progress on this bug in ~4 years?

@SIRprise
Copy link

I described a fix ~4 years ago, but nobody seemed to be interested in: http://forum.arduino.cc/index.php?topic=152479.0

@NicoHood
Copy link
Contributor

I think we dont need a fix and just remove this feature, as serialevent is just soo useless, as it is called inside the loop.

cmaglie referenced this issue in arduino/Arduino Jul 6, 2017
s0ren referenced this issue in STU-IT/arduino17-18 Dec 6, 2017
@sandeepmistry sandeepmistry transferred this issue from arduino/Arduino Sep 16, 2019
@facchinm
Copy link
Member

Fixed (or, better, documented) by arduino/Arduino@e180b70 .
Anyway, serialEvent is due to deprecation, so no fixes will be applied to code not working today.

@PaulStoffregen
Copy link
Contributor

If serialEvent is depreciated, maybe users could be advised not to use it on these pages?

https://www.arduino.cc/en/Tutorial/SerialEvent

https://www.arduino.cc/en/Reference.SerialEvent

@JoakimCh
Copy link

JoakimCh commented Nov 10, 2020

I happened to spend (waste) several hours now just to figure this out... I see no logical reason for it to work with some Arduinos and not this one, hence it not being implemented was very confusing. But I guess this is to be expected with the low quality of most of the standard Arduino libraries...

@PaulStoffregen
Copy link
Contributor

PaulStoffregen commented Nov 11, 2020

Not sure I agree with your general code quality assessment. But I do believe designing public APIs with weak linking of function names is a poor practice. The really hard thing about public APIs is once you've published to a wide audience and people write code on top of those APIs, removing them hurts a lot of people even if you later realize a better way.

Looks like Arduino did update the primary documentation.

sc

@PaulStoffregen
Copy link
Contributor

However, this old tutorial page could really use an update to mention which boards do and don't support serialEvent.

https://www.arduino.cc/en/Tutorial/BuiltInExamples/SerialEvent

If it really is going to be depreciated, might be good to update the reference and tutorial to recommend against using serialEvent?

@per1234 - How do we request documentation updates these days?

@per1234
Copy link
Contributor

per1234 commented Nov 11, 2020

@PaulStoffregen the arduino/Arduino repository's issue tracker seems to serve as the catch-all for issues for which there isn't a more appropriate public issue tracker.

If someone submits specific recommendations for improving/correcting the Tutorials pages (with the exception of the "Hacking" section as I don't have access to the source of that content), I'll submit a PR to implement those changes if I'm in agreement and am able to personally verify the information is accurate.

I'm not the one to make decisions regarding deprecation though.

@PaulStoffregen
Copy link
Contributor

I would recommend 2 specific changes to that tutorial page.

1: Add "serialEvent() is not compatible with the Esplora, Leonardo, or Micro" somewhere on the page.

2: In the first sentence, change "SerialEvent()" to "serialEvent()". It should not be capitalized.

@per1234
Copy link
Contributor

per1234 commented Nov 16, 2020

Thanks for your recommendations @PaulStoffregen!

1: Add "serialEvent() is not compatible with the Esplora, Leonardo, or Micro" somewhere on the page.

I did a survey of the situation and decided that the best approach is to completely document serialEvent() support for all official boards in a single place, then link to that from the tutorial. This will make it easier/more likely to keep the information updated.

As the first step, I have submitted a PR to fully document the situation on the Arduino Language Reference's serialEvent() page:
arduino/reference-en#800
I would welcome any reviews or feedback on that PR.

Once I have received an approval on arduino/reference-en#800, I will then submit a PR to add a link to that information to both the serialEvent() tutorial page and the comment in the built-in "SerialEvent" example sketch associated with that tutorial.

2: In the first sentence, change "SerialEvent()" to "serialEvent()". It should not be capitalized.

I have submitted a PR to correct this. (UPDATE: it has now been merged!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests