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

Add SerialStart, SerialIgnore commands for Serial Bridge (both Hardware and Software) #17140

Closed

Conversation

ortegafernando
Copy link
Contributor

@ortegafernando ortegafernando commented Nov 19, 2022

Description:

Hi, I have done two new commands that are very usefull with SerialBridge. (both commands work with hardware or software serial bridge)

If this PR is merged, I will add a new PR for "tasmota docs"

SerialStart: it is configured to work up to 3 bytes. Buffer will begin to record only when this 1, 2 or 3 bytes are recieved in that order

SerialIgnore (0 .. 255): usefull when you have a serial TX that send date every X seconds (in my case a Victron VE.Direct equipment that sends data every second) and you want to exclude data not to saturate your system.

Both commans' configuration are preserved between restarts. Configuration is saved in flash

Also, I have added code to distinguish between D_JSON_SSERIALRECEIVED and D_JSON_SERIALRECEIVED in SerialBridge (hardware vs software serial)
CAUTION: before this change, every message is recieved as D_JSON_SSERIALRECEIVED, so people using hardware serial must check if they manage well D_JSON_SERIALRECEIVED

Compiled and checked with gitpod.io

Examples:
// SerialStart 0 to disable
// SerialStart C1 to start only with C1
// SerialStart C1,C2 to start with C1, C2
// SerialStart C1,C2,C3 to start with C1, C2, C3
// SerialStart show current chars
// C1, C2, C3 must me decimal numbers representing ascii code ("PID" = 80 73 68): serialstart 80,73,68

// SerialIgnore 0 to disable => process all recieved messages
// SerialIgnore 1 is identical as SerialIgnore 0
// SerialIgnore X to "ignore" X serialrecieved messages
// SerialIgnore show current value

Output message from gitpod.io before and after this PR:

RAM:   [=====     ]  50.9% (used 41676 bytes from 81920 bytes)
Flash: [======    ]  62.9% (used 644360 bytes from 1023984 bytes)

RAM:   [=====     ]  50.9% (used 41676 bytes from 81920 bytes)
Flash: [======    ]  63.0% (used 644952 bytes from 1023984 bytes)

Related issue (if applicable): fixes #

Checklist:

  • The pull request is done against the latest development branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • The code change is tested and works with Tasmota core ESP8266 V.2.7.4.9
  • The code change is tested and works with Tasmota core ESP32 V.2.0.5
  • I accept the CLA.

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

@arendst
Copy link
Owner

arendst commented Nov 19, 2022

Thx.

As it stands this won't be merged as it changes default behaviour in case of hardware/software serial. This should not be distinguished here in the code. Although it uses hardware serial, it uses a different driver than the inbuilt serial driver and hence should still report as sserialreceived.

Anyway, I keep this PR open as an idea of how to manage duplicate messages.

BTW how often are the serial messages being received? If it is every 5 seconds (as in your tests) there is no reason to handle it here. You should do it in your back ground code and not in Tasmota.

@arendst arendst self-assigned this Nov 19, 2022
@arendst arendst added the on hold by dev team Result - Feature request put on hold by member of development team label Nov 19, 2022
@ortegafernando
Copy link
Contributor Author

ortegafernando commented Nov 19, 2022

Thx.

As it stands this won't be merged as it changes default behaviour in case of hardware/software serial. This should not be distinguished here in the code. Although it uses hardware serial, it uses a different driver than the inbuilt serial driver and hence should still report as sserialreceived.

Anyway, I keep this PR open as an idea of how to manage duplicate messages.

BTW how often are the serial messages being received? If it is every 5 seconds (as in your tests) there is no reason to handle it here. You should do it in your back ground code and not in Tasmota.

HI @arendst , I understand what you say. so I am going to delete everything about D_JSON_SERIALRECEIVED.

About SerialStart and SerialIgnore I think they are good commands. In my case I am receiving one big message every second (VE.Direct protocol by Victron: MPPT, inverters, ....) that is why I want to ignore several (duplicate or not, I only want a message every 5 or 10 seconds or even more seconds). I am sure that there are or will be others equipments that works by outputting message by"its own".

@ortegafernando ortegafernando changed the title Add SerialStart, SerialIgnore and distinguish between D_JSON_SSERIALRECEIVED and D_JSON_SERIALRECEIVED Add SerialStart, SerialIgnore commands for Serial Bridge (both Hardware and Software) Nov 19, 2022
arendst added a commit that referenced this pull request Nov 20, 2022
Add command ``SetOption35 0..255`` to skip number of received messages in Serial Bridge (default 0) (#17140)
@arendst
Copy link
Owner

arendst commented Nov 20, 2022

SerialIgnore is now implemented in Serial Bridge as SetOption35 0..255

@ortegafernando
Copy link
Contributor Author

ortegafernando commented Nov 20, 2022

SetOption35

Thanks a lot, do you want me to edit the wiki page?

@barbudor
Copy link
Contributor

SetOption35

Thanks a lot, do you want me to edit the wiki page?

That would be very kind
Thanks

@ortegafernando
Copy link
Contributor Author

Hi, PR done for wiki docs (developement branch).

Whay about SerialStart? I hope you can find it also usefull.

@github-actions
Copy link

This PR has been automatically marked as stale because it hasn't any activity in last few weeks. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Action - Issue left behind - Used by the BOT to call for attention label Dec 16, 2022
@github-actions
Copy link

This PR was automatically closed because of being stale.

@github-actions github-actions bot closed this Dec 21, 2022
@ortegafernando
Copy link
Contributor Author

@arendst Bot has closed this PR. It is only pending the SerialStart stuff. I think it is a good way to improve hardware and software serial (I have read several old diccusions about this topic). DO you think is time to re-opening it again? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on hold by dev team Result - Feature request put on hold by member of development team stale Action - Issue left behind - Used by the BOT to call for attention
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants