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

VE.Direct: Reset state machine on timeout, fix and extend logging #416

Merged
merged 4 commits into from
Sep 4, 2023

Conversation

schlimmchen
Copy link
Member

In the event of unreliable serial communication to the Victron MPPT, bitflips and other errors may cause the state machine to hang in a particular state, such that the end of a frame/message is never detected correctly. This changeset adds a timeout: If no serial data was received for 500ms, the state machine is reset, so when a new frame is received, the state machine is expecting the start of a frame and it can decode it properly.

This change also makes sure that problems detected by the VeDirectFrameHandler are also put into the WebConsole. Previously, the messages were printed directly to the serial connection, so they never appeared on the web console.

The VE.Direct settings now include a setting to enable verbose logging. If enabled, the message output will include the raw serial data received.

there will never be a large gap between two bytes of the same frame.
if such a large gap is observed, reset the state machine so it tries
to decode a new frame once more data arrives.

this is helpful in case of corrupted data that prevents the state
machine of transitioning to the final state even though the VE.Direct
data producer is done sending bytes that belong to the same frame.
this includes the web console in particular, where many users have
access to while the serial console is not attached or monitored.
should help debug issues for users.
@schlimmchen schlimmchen mentioned this pull request Sep 3, 2023
@helgeerbe helgeerbe merged commit ba303da into hoylabs:development Sep 4, 2023
@schlimmchen schlimmchen deleted the ve-direct-debugging branch September 4, 2023 18:14
@philippsandhaus
Copy link

Not sure if I should open a new Issue or if a comment here is enough: When disabling verbose logging, I constantly get the following error in the logs:

22:10:57.515 > [VE.Direct] ERROR: debug buffer overrun!
22:10:59.501 > [VE.Direct] ERROR: debug buffer overrun!
22:11:00.984 > [VE.Direct] ERROR: debug buffer overrun!
22:11:02.934 > [VE.Direct] ERROR: debug buffer overrun!
22:11:04.442 > [VE.Direct] ERROR: debug buffer overrun!

Problem seems to be that 'VeDirectFrameHandler::dumpDebugBuffer() ' only get's called when verbs logging is enabled and this function is the only place where _debugIn is set to 0.

@schlimmchen
Copy link
Member Author

@philippsandhaus Yes. You are absolutely right. Quite embarrassing... See #437 for the fix.

Copy link

github-actions bot commented Apr 5, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion or issue for related concerns.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants