fix(v16): correct drop_transaction_data to drop every second element#1178
Closed
rishabhvaish wants to merge 1 commit intoEVerest:mainfrom
Closed
fix(v16): correct drop_transaction_data to drop every second element#1178rishabhvaish wants to merge 1 commit intoEVerest:mainfrom
rishabhvaish wants to merge 1 commit intoEVerest:mainfrom
Conversation
The erase-while-iterating-forward approach skipped elements because indices shift after each erase(). With 5 messages the algorithm kept [0, 3, 4] instead of the spec-required [0, 2, 4]. Iterate backwards from the highest odd index so that removals never affect the positions of elements still to be processed. Fixes #1165 Signed-off-by: Rishabh Vaish <rishabhvaish.904@gmail.com>
0729487 to
0896eae
Compare
Contributor
|
Hi @rishabhvaish , this comment also applies here. |
3 tasks
Author
|
Thanks @Pietfried! Reopened in the monorepo: EVerest/EVerest#2003 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
drop_transaction_datafunction inv16/utils.cppwas supposed to drop every second MeterValue while keeping the first and last (per OCPP 1.6 Appendix). The implementation iterated forward witherase(), but each removal shifted subsequent indices down, causing the loop to skip elements.With 5 messages
[0, 1, 2, 3, 4]the old code kept[0, 3, 4](after two while-loop passes) instead of[0, 2, 4]in a single pass. The middle message was lost unnecessarily.I switched to backward iteration from the highest odd index so that removals never affect the positions of elements still to be processed. Also updated the existing test expectation and added three new test cases covering 6-element, 7-element, and minimum-preservation scenarios.
Fixes EVerest/EVerest#1990