Serial Server: No events without a networkclient connected

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
elfrinjo
Normal user
Posts: 11
Joined: 25 May 2022, 23:53

Serial Server: No events without a networkclient connected

#1 Post by elfrinjo » 26 May 2022, 00:06

Good evening!

I am currently trying to make a serial sensor smart.

So far, I have the sensor connected to the RX pins of a wemos d1 mini running ESP_Easy_mega_20220427_normal_ESP8266_4M1M
While a telnet client is connected to the serverport, I do get the characters from my sensor on the client and esp-easy generates events I can work with in rules.
However, with the client disconnected esp-easy does not generate the events anymore.

Is there a way around this? I only need to process the events.


Cheers, elfrinjo

TD-er
Core team member
Posts: 8607
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Serial Server: No events without a networkclient connected

#2 Post by TD-er » 26 May 2022, 10:04

Have to look into the source code, but I think this one might have a check in there for network connectivity.
Given your use case that should be made either optional or removed.
Maybe Ton can also have a look at it, as I'm busy today.

User avatar
Ath
Normal user
Posts: 3386
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Serial Server: No events without a networkclient connected

#3 Post by Ath » 26 May 2022, 10:25

There is indeed an explicit check when handling data. I'll add an option to make that optional.
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3386
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Serial Server: No events without a networkclient connected

#4 Post by Ath » 26 May 2022, 11:26

elfrinjo wrote: 26 May 2022, 00:06 However, with the client disconnected esp-easy does not generate the events anymore.
I've added a config setting to enable event processing even when no network client is connected, please try this test-build:

(Improved version below)

Configuration option looks like this:
Screenshot - 26-05-2022 , 11_21_24.png
Screenshot - 26-05-2022 , 11_21_24.png (6.29 KiB) Viewed 5418 times
Last edited by Ath on 26 May 2022, 13:24, edited 1 time in total.
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3386
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Serial Server: No events without a networkclient connected

#5 Post by Ath » 26 May 2022, 11:44

I've created a PR #4076 for this feature request.
/Ton (PayPal.me)

elfrinjo
Normal user
Posts: 11
Joined: 25 May 2022, 23:53

Re: Serial Server: No events without a networkclient connected

#6 Post by elfrinjo » 26 May 2022, 12:07

Wow, you guys are amazing. Thank you very much!!

TD-er
Core team member
Posts: 8607
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Serial Server: No events without a networkclient connected

#7 Post by TD-er » 26 May 2022, 12:12

Please let us know if it is working as expected (no side effects), so we can merge the code.

elfrinjo
Normal user
Posts: 11
Joined: 25 May 2022, 23:53

Re: Serial Server: No events without a networkclient connected

#8 Post by elfrinjo » 26 May 2022, 12:21

I'll do!

However, at the moment the UI does not seem to save the checkbox when submitting.

/ Cheers, elfrinjo

TD-er
Core team member
Posts: 8607
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Serial Server: No events without a networkclient connected

#9 Post by TD-er » 26 May 2022, 12:30

Yep, that's indeed plausible.
The plugin now needs some changes in the PLUGIN_WEB_SAVE part too.

User avatar
Ath
Normal user
Posts: 3386
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Serial Server: No events without a networkclient connected

#10 Post by Ath » 26 May 2022, 12:41

That is tested, and worked here :o
I'll have a look.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8607
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Serial Server: No events without a networkclient connected

#11 Post by TD-er » 26 May 2022, 12:53

And I need a new coffee as it was indeed implemented, so no idea why it may not be working...

User avatar
Ath
Normal user
Posts: 3386
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Serial Server: No events without a networkclient connected

#12 Post by Ath » 26 May 2022, 13:23

Something to do with the bool not being understood correctly, somewhere. Worked fine on ESP32 when tested, had not explicitly tested on ESP8266, only uploaded on ESP8266 and it showed up as intended :roll:

New upload: (has the same filename, so you may need to clear the browser cache)
ESP_Easy_mega_20220526_normal_ESP8266_4M1M.zip
(619.22 KiB) Downloaded 103 times
/Ton (PayPal.me)

elfrinjo
Normal user
Posts: 11
Joined: 25 May 2022, 23:53

Re: Serial Server: No events without a networkclient connected

#13 Post by elfrinjo » 26 May 2022, 13:42

This version works for me!

I'll test it over the weekend and provide feedback.

/ Cheers, elfrinjo

User avatar
Ath
Normal user
Posts: 3386
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Serial Server: No events without a networkclient connected

#14 Post by Ath » 26 May 2022, 13:44

Great, TIA
/Ton (PayPal.me)

elfrinjo
Normal user
Posts: 11
Joined: 25 May 2022, 23:53

Re: Serial Server: No events without a networkclient connected

#15 Post by elfrinjo » 28 May 2022, 17:08

Hi,

so far, I did not find weird side-effects on the serial rx.

What I did find is an issue with event-generation when cr/lfs (or maybe just crs) are present:
An event is generated for the string before the first cr/lf only. The rest seems to be discarded from the events but is transferred to the network client.



Cheers, elfrinjo

TD-er
Core team member
Posts: 8607
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Serial Server: No events without a networkclient connected

#16 Post by TD-er » 28 May 2022, 17:25

OK, I guess that would make sense to generate events on every part.
Just consider each received text upto CR/LF as a seperate text.
It doesn't make sense to make it dependent on how fast data is being processed (thus if there is still something in the buffer)

User avatar
Ath
Normal user
Posts: 3386
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Serial Server: No events without a networkclient connected

#17 Post by Ath » 28 May 2022, 18:21

That should then also be optional, as the current behavior should stay unchanged for those that expect it that way.

I'll add a setting for that.
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3386
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Serial Server: No events without a networkclient connected

#18 Post by Ath » 28 May 2022, 19:52

I've done a first attempt to implement multi line processing, can you test, please? Has to be enabled in the Serial Server task settings.

(removed, see below)

And please also test if the existing behavior is unchanged, don't have a matching setup available :oops:
Last edited by Ath on 29 May 2022, 14:34, edited 1 time in total.
/Ton (PayPal.me)

elfrinjo
Normal user
Posts: 11
Joined: 25 May 2022, 23:53

Re: Serial Server: No events without a networkclient connected

#19 Post by elfrinjo » 29 May 2022, 12:58

Hi Ton,

this version crashes when
- the new setting is enabled
- and when serial data comes in

With the new setting disabled I did not see those problems.

When enabling the setting these are the last and the first line from the log:

Code: Select all

2022-05-29T10:50:26.104639+00:00 espeasy-1 EspEasy: EVENT: TaskExit#serial=2,1 Processing time:104 milliSeconds
2022-05-29T10:50:33.637873+00:00 espeasy-1 EspEasy: firstLoopConnectionsEstablished
When serial data comes in, there is no additional output:

Code: Select all

2022-05-29T10:55:06.237499+00:00 espeasy-1 EspEasy: WiFi : Set TX power to 12dBm sensitivity: -69dBm RSSI: -61dBm
2022-05-29T10:55:17.521029+00:00 espeasy-1 EspEasy: firstLoopConnectionsEstablished

Cheers, elfrinjo

User avatar
Ath
Normal user
Posts: 3386
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Serial Server: No events without a networkclient connected

#20 Post by Ath » 29 May 2022, 13:10

Hm, I'll have a look, and try to set up a testing environment for this for debugging purposes.
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3386
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Serial Server: No events without a networkclient connected

#21 Post by Ath » 29 May 2022, 14:34

Made some improvements, and did some testing, please re-test:

(Updated, see below)
Last edited by Ath on 29 May 2022, 22:55, edited 2 times in total.
/Ton (PayPal.me)

elfrinjo
Normal user
Posts: 11
Joined: 25 May 2022, 23:53

Re: Serial Server: No events without a networkclient connected

#22 Post by elfrinjo » 29 May 2022, 20:04

The crash when submitting the enable multilineprosessing setting seems to be gone
but when receiving data the controller still reboots.

Cheers, elfrinjo

TD-er
Core team member
Posts: 8607
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Serial Server: No events without a networkclient connected

#23 Post by TD-er » 29 May 2022, 21:18

What message length do you typically receive?
It could be an issue with out of memory?

I think the message should be processed immediately as soon as a newline is received and not keep on capturing followed by processing it.
If these messages occur shortly one after the other, then the memory requirements are probably too much to handle. Especially when copying messages from an already long string.

elfrinjo
Normal user
Posts: 11
Joined: 25 May 2022, 23:53

Re: Serial Server: No events without a networkclient connected

#24 Post by elfrinjo » 29 May 2022, 21:26

That is very unlikely. I am receiving data from a blood pressuremonitor, the typical datastream looks like this:

(With long pauses where I put the newlines)

Code: Select all

O N   [0D] [0A]
C H K [0D] [0A]
I N F [0D] [0A]
D E F [0D] [0A]
E X H [0D] [0A] r x 0 0 4 4 0 0 2 F 0 0 5 C [0D] [0A] r a 0 0 0 0 [0D] [0A]
W A I [0D] [0A]
O F F [0D] [0A]

User avatar
Ath
Normal user
Posts: 3386
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Serial Server: No events without a networkclient connected

#25 Post by Ath » 29 May 2022, 22:54

I've tried to improve string-handling by using pointers, but didn't have enough sanity checks included.
That is now corrected, please test this version:

(Updated, see below)

NB: Same filename as previous download, you may need to clear the browser cache.
Last edited by Ath on 30 May 2022, 23:02, edited 1 time in total.
/Ton (PayPal.me)

elfrinjo
Normal user
Posts: 11
Joined: 25 May 2022, 23:53

Re: Serial Server: No events without a networkclient connected

#26 Post by elfrinjo » 30 May 2022, 17:13

No, sorry, I am still getting reboots when data arrives.

User avatar
Ath
Normal user
Posts: 3386
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Serial Server: No events without a networkclient connected

#27 Post by Ath » 30 May 2022, 21:27

Just to make sure you have the correct .bin file installed, what is the Git Build shown on the Main tab?

With the previous build I had reboots too, after receiving a few characters, but then I was under the impression it had to do with my poor testing environment, but with the latest build I couldn't crash it anymore, so it felt like I fixed it...
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3386
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Serial Server: No events without a networkclient connected

#28 Post by Ath » 30 May 2022, 23:02

I did find some room for improvement, though I didn't see any crashes during testing, but here is an update:
ESP_Easy_mega_20220530_normal_ESP8266_4M1M.zip
(619.65 KiB) Downloaded 110 times
/Ton (PayPal.me)

elfrinjo
Normal user
Posts: 11
Joined: 25 May 2022, 23:53

Re: Serial Server: No events without a networkclient connected

#29 Post by elfrinjo » 31 May 2022, 17:46

Hi Ton, Hi TD-er,

this release works flawlessly for me!

The events are generated with the new option turned on and no client connected.
The cr/lfs are recognized as a delimiter for events when the option for that is activated.
And I still see the old behavior when the options are turned off.

Thank you very much for your efforts once again!


Cheers, elfrinjo

User avatar
Ath
Normal user
Posts: 3386
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Serial Server: No events without a networkclient connected

#30 Post by Ath » 31 May 2022, 18:54

Great, thanks for the feedback :D
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest