Skip to content
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

A small nothing left aside. serialEvent() #752

Closed
fredericplante opened this issue Sep 6, 2015 · 23 comments · Fixed by #7505
Closed

A small nothing left aside. serialEvent() #752

fredericplante opened this issue Sep 6, 2015 · 23 comments · Fixed by #7505
Labels
waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.
Milestone

Comments

@fredericplante
Copy link

fredericplante commented Sep 6, 2015

I, you guys seeem to forgot the serialEvent() trigger, that is required to be fully compatible with the basics example of the Arduino IDE.

I guess we could just program a trigger from within the program, you while you guys are at it, well here is the constructive remark ;)

Thanx :)

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@igrr
Copy link
Member

igrr commented Sep 6, 2015

I never new about it, thanks for pointing this out.
However, reading Arduino website,

serialEvent() is not compatible with the Esplora, Leonardo, or Micro

So it's not even supported by some of the Arduino brand boards.
Still, I will look into this once I add the callback queue and some
scheduling functions.

On Sun, Sep 6, 2015, 22:39 Frédéric Plante [email protected] wrote:

I, you guys seeem to forgot the serialEvent() trigger, that is required to
be fully compatible with the basics example of the Arduino IDE.

I guess we could just program a trigger from within the program, you while
you guys are at it, well here is the constructive remark ;)

Thanx :)


Reply to this email directly or view it on GitHub
#752.

@fredericplante
Copy link
Author

Might as well be more discipline then them. ;)

Esplora, Leonardo, or Micro are basically all Léonardo tech, that is made to become computer interface(mouse, keyboard, SPI and I2c interface that that lack on a computer) using usb. While all the other arduinos of the first génération, the one using an external UART2USB (MEGA and Tiny) are made to be small stand alone computing device, that can totally function without serial port, except for programming, well that is what i deduce of what I get out of the product.

According to me, the emphasis of the SerialEvent() should of been put on the Léonardo class, and less on the stand alone class, but they did not think about it that way. Any ways, according to me both should have it, there is never enough possible internal trigger and external interrupt.

Take care.

@drmpf
Copy link

drmpf commented Sep 7, 2015

Is there any notable library that uses SerialEvent()?
Unless there is a particular need for SerialEvent(), I would vote against it.

I see no advantage over calling a method directly from the loop
Calling a method directly from the loop keeps user focused on what happens when and how long it takes.

Most users, particularly casual users, will never use interrupts (apart form library code) and the SerialEvent() runs like an interrupt with some of the associated problems.

I note even on the boards the support SerialEvent() it is not uniform, Mega does not have it, instead having SerialEvent1(), etc.

@fredericplante
Copy link
Author

Actually, the sérialevent() event is absolutly independant from the Loop() it's never call from there. T'it's actually the library that manage to trigger event by calling SerialEvent(), in the sketch, from the library. pretty much the same way the when you hook a interupt to a function. Actually, i think that it's the Uart on the Arduino that interupt and get the serialevents call.

A couple of the sketch exemple use it, and there are a few library also.

Actually mini, uno, mega128 and mega256, and all the clone, has it. It is the atmega32u that does handle the event. Has for Due and Zero, im not sure.

I think it's important to put it in, to make sure that the new guy that try esp and Adruino ide together get the same look and feel as if it was a real Arduino. Just saying. I look at your work, and I see that you are trying to make it as transparent as possible, well there is a spot there. ;)

@philomatic
Copy link

Anything new on this? I'd be glad to see this coming!

Most users, particularly casual users, will never use interrupts (apart form library code) and the SerialEvent() runs like an interrupt with some of the associated problems.

I disagree. In my experience, almost everyone who programmed an Arduino, AtMega or MSP will use interrupts if available. And these are the users which will use Arduino on ESP8266.
All others will stick to Lua (or similiar HL languages).

Best regards

@tablatronix
Copy link
Contributor

👍

@ArGaspar
Copy link

Hi, is SerialEvent() Available now?. im trying to send information via serial from arduino to esp and back the other way, ESP is acting as a web server so if use serial.read is going to block all the others function. Any suggestions?

Best Regards.

@fredericplante
Copy link
Author

fredericplante commented Nov 27, 2016

I knew this was going to come up. It's not because it seam useless for some that it is for every one. I will take a look at the progress [...]

[...] Well I check at the https://github.com/esp8266/Arduino/blob/master/cores/esp8266/HardwareSerial.h

at line 146 and line 147 the procedure seam to be put in place.
but not the

extern void serialEventRun(void) __attribute__((weak));

part that will call the Serial event from the library in the sketch when the stuff is available, is still missing

This part:

void serialEventRun(void){

#if defined(HAVE_HWSERIAL0)
  if (Serial0_available && serialEvent && Serial0_available()) serialEvent();
#endif

#if defined(HAVE_HWSERIAL1)
  if (Serial1_available && serialEvent1 && Serial1_available()) serialEvent1();
#endif

}

Should be added in the: https://github.com/esp8266/Arduino/blob/master/cores/esp8266/HardwareSerial.cpp

I've put the lines for Serial1, but I don't think that it would be really useful, since there is not Rx line on that port. Basically, only Serial0 need to pull an interruption when selected events happen.

@ArGaspar
Copy link

ArGaspar commented Nov 27, 2016

Is it possible to modify that myself? I cant find that file/folder on my pc. (sorry if its a stupid question, Im a noob, barely I understand how library works)

Best Regards.

@fredericplante
Copy link
Author

Yeah! probably, if you know where your arduino platform distribution is, you can change it no problem. But every time you will reinstall, you will loose all, same when they will update.

Best would be to change at the root, but for some reason, some people think that if it's useless for them, it has to be the same for every one. :(

@ArGaspar
Copy link

Hey, I know where it its, but i cant find the file it should be on libraries right???? did you make it work?

@philomatic
Copy link

philomatic commented Mar 3, 2017

I'm also out of luck, can't find the location of the files on my disk.
Any ideas?

Edit: Nvm,, using the git version now.

Best Regards
Patrick

@bertmelis
Copy link

Is there still an idea to reimplement serialEvent?
It's not so much of a deal since it would only add a check on Serial.available() on each loop() and run the serialEvent-routine if necessary.

It is not interrupt driven as in this snippet from main.cpp:

for (;;) {
		loop();
		if (serialEventRun) serialEventRun();
	}

Obviously, it does add some overhead for those who haven't got serialEvent defined.

@rsegecin
Copy link

rsegecin commented Oct 11, 2017

@fredericplante when you added those lines you commented to make the serialEvent to work were you working on ESP8266 Arduino version 2.3? Was it all you added? Could you make a pull request please? I'm asking that because I've made those changes and the serialEvent still not been called.

@devyte
Copy link
Collaborator

devyte commented Oct 20, 2017

@igrr I'm rather confused with this one. Was the HardwareSerial code massively changed? The code references in this thread don't match with the current code for HardwareSerial for me.
What are your thoughts on this request?

@devyte devyte added the waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. label Oct 20, 2017
@laercionit
Copy link
Contributor

Hello, I saw in the post history the adjustment in the Lib to support SerialEvent, it is a function very used in projects.

I would like to know if this improvement will be incorporated or is it more appropriate to use the Ticker to execute Serial.available?

@fredericplante
Copy link
Author

fredericplante commented Jun 12, 2018

Humm good question! rsegecin, what was the actual platform in 2015?

To be honest, I'm back to University and it takes a good part of my life. lol

But it's summer time now, baby :D I will get back to programming, I have a whole lot of modules I received during the winter, many use Serial to communicate. Compulsive buying did not go away, unlike coding, during those long hours of study, ;)

I will give news within the near future.

@bertmelis
Copy link

bertmelis commented Jun 12, 2018

While you could use Ticker to execute Serial.available() I wouldn't do that. Both use interrupts and they don't mix well together. Maybe use schedule.h instead?

Disclaimer: I didn't look into the inner workings of schedule yet. You'll have to reschedule after calling but I don't know if it's possible from within the called function.

@hreintke
Copy link
Contributor

@bertmelis @laercionit
Yes to can call schedule within scheduled function.

This is part of my CommandExecutor class, I use it also with Serial.

void CommandExecutor::getStreamChars(Stream* reqStream)
{
	if (reqStream->available())
	{
		executorReceive(reqStream->read());
	}
	schedule_function(std::bind(&CommandExecutor::getStreamChars,this,reqStream));
}

@HugoML
Copy link

HugoML commented Dec 19, 2018

Arduino 1.8.7 and ESP for Arduino 2.4.0 :
serialEvent() still does not trigger for ESP.
Not sure how to use HardwareSerial ...

@d-a-v
Copy link
Collaborator

d-a-v commented Dec 19, 2018

Not sure how to use HardwareSerial ...

Until we have a real serialEvent();, you can do this in loop() (as stated above):

  if (Serial.available()) {
    serialEvent();
  }

Normola pushed a commit to Normola/Arduino that referenced this issue Feb 19, 2020
@ttkdroid
Copy link

ttkdroid commented Aug 5, 2020

Hi guys, almost 5 years have passed since this issue was reported and looks like it is still not solved. Is there any perspective that this would be resolved any time soon? Don't take me wrong...I understand that there are a lot of voluntary work and people need to accommodate this work with their schedules, but would be nice to have an update on this issue.

@d-a-v d-a-v added this to the 3.0.0 milestone Aug 5, 2020
earlephilhower added a commit to earlephilhower/Arduino that referenced this issue Aug 5, 2020
Match the AVR SerialEvent implicit callback.  Callback is executed
in normal user mode, not IRQ, so standard processing can be uses.

Fixes esp8266#752 after 5 years. :)
@earlephilhower
Copy link
Collaborator

@ttkdroid please report in the PR if it works/fails. It seems pretty trivial and not all that useful, honestly.

devyte pushed a commit that referenced this issue Aug 6, 2020
* Add SerialEvent() callback to loop processing

Match the AVR SerialEvent implicit callback.  Callback is executed
in normal user mode, not IRQ, so standard processing can be uses.

Fixes #752 after 5 years. :)

* Fix style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.