Skip to content

libiso15118: Add response msg interval control#1784

Open
FaHaGit wants to merge 1 commit intoEVerest:mainfrom
chargebyte:feature/libiso_add_response_msg_interval_control
Open

libiso15118: Add response msg interval control#1784
FaHaGit wants to merge 1 commit intoEVerest:mainfrom
chargebyte:feature/libiso_add_response_msg_interval_control

Conversation

@FaHaGit
Copy link
Contributor

@FaHaGit FaHaGit commented Feb 2, 2026

Describe your changes

There are EV implementations that can configure request messages within a few milliseconds, which can currently trigger a flood of internal communication. To avoid performance issues, we should therefore wait a certain amount of time after receiving a request message before sending the next response message. The delay of maximum 100 ms should not cause any problems, as the most critical time of the ISO 15118-20 (V2G_SECC_Msg_Performance_Time of the charging loop) is 250 ms.

Already successfully tested in the SIL environment (with a higher delay, because the josev lib based implementation needs ~500ms to configure a request message).

Changes:

  • introduce MIN_RESPONSE_INTERVAL_MS to manage time between responses
  • add last_response_tx_time to track last response timestamp
  • implement delay to ensure minimum interval between response messages

Issue ticket number and link

Checklist before requesting a review

  • [X ] I have performed a self-review of my code
  • I have made corresponding changes to the documentation
  • [X ] I read the contribution documentation and made sure that my changes meet its requirements

Copy link
Member

@SebaLukas SebaLukas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I like the PR. Wait for some time before sending the response is a good idea.

My problem with this implementation is that it blocks the whole process for 100ms.
That could be really a problem in some cases.

I need to think how to fix this problem not blocking the whole process.

@FaHaGit
Copy link
Contributor Author

FaHaGit commented Feb 6, 2026

@SebaLukas what is your opinion on how the delay should be implemented? Would you prefer it to be implemented as it currently is, with a fixed response interval (i.e., keeping the time between two res messages constant), or to wait a fixed amount of time after receiving a request message? The first approach has been implemented here. I think that's quite good because we don't necessarily delay, but only when the EV generates request messages quickly. Or do you think a delay after a response would always be useful in order to have the chance to react to the content of the request message? I can also imagine a hybrid form: max 100ms interval + constant delay (e.g. 50ms) after a request.

@FaHaGit
Copy link
Contributor Author

FaHaGit commented Feb 6, 2026

In general I like the PR. Wait for some time before sending the response is a good idea.

My problem with this implementation is that it blocks the whole process for 100ms. That could be really a problem in some cases.

I need to think how to fix this problem not blocking the whole process.

I already worked on a solution for this issue

@SebaLukas
Copy link
Member

I would prefer the second option, as a delay here does not block the entire process.

I would start a separate timer after sending the response and check this timer after receiving the request to see whether the timer is over 100 ms or not.
If the car sends the request after the response very fast in less than 100 ms, the session poll function should return early and check later whether the timer is over 100 ms. Only then is the response created via the state machine.
The advantage of this is that various events can also be received by EVerest during the waiting time. And the events can also be reflected in the response.

@FaHaGit
Copy link
Contributor Author

FaHaGit commented Feb 6, 2026

Thx for the quick response. I think I've already implemented this as you described it in my local branch (not pushed yet). The problem is that if the EV itself needs 100 ms to send the request message, for example, then the delay timer expires immediately and we generate the response directly without first communicating the request content internally.

Hence the proposal for a hybrid solution consisting of a maximum wait time for a request plus a fixed delay. If the EV responds very quickly (e.g. ~0ms), maximum (100+50 ms) = 150 ms is waited for the response to be generated. If the vehicle takes a long time, e.g., 100 ms, then only 50 ms is delayed.

@SebaLukas
Copy link
Member

The problem is that if the EV itself needs 100 ms to send the request message, for example, then the delay timer expires immediately and we generate the response directly without first communicating the request content internally.

I think this is actually okay. Do you have an example of what could be problematic if the state machine responds directly to the req message?
The state machine is handling the req message and react depending on the req. And right now this behaivour is happing in libiso15118 and EvseV2G.

@FaHaGit
Copy link
Contributor Author

FaHaGit commented Feb 6, 2026

I don't have a specific example. I just thought that if there is certain V2G content in a request that causes an internal abort on EVSE side, for example, then the response to this request would only occur in the next response, for example, through a failed response code. I don't have a big problem with that. We can implement it that way for now.

As far as I can remember, EvseV2g currently only works with a static delay after a request and does not take into account the time between two response messages. But I think it's smarter to take the request time into account in the delay.

@SebaLukas
Copy link
Member

Okay 👍 Lets see if we will have some problems in the future then we can add this extra 50ms. But for now I think we dont need them.

There are EV implementations that can configure request messages within
a few milliseconds, which can currently trigger a flood of internal
communication. To avoid performance issues, we should therefore wait a
certain amount of time after receiving a request message before sending
the next response message. The delay of maximum 100 ms should not cause
any problems, as the most critical time of the ISO 15118-20
(V2G_SECC_Msg_Performance_Time of the charging loop) is 250 ms.

Changes:
- introduce MIN_RESPONSE_INTERVAL_MS to manage time between responses
- add last_response_tx_time to track last response timestamp
- implement delay to ensure minimum interval between response messages
- implement send_response function to streamline response logic
- introduce `has_response()` to check for response availability
- add `peek_response_meta()` for response metadata inspection

Signed-off-by: Fabian Hartung <fabian.hartung@chargebyte.com>
@FaHaGit FaHaGit force-pushed the feature/libiso_add_response_msg_interval_control branch from a010967 to 1191a71 Compare February 9, 2026 11:01
@FaHaGit
Copy link
Contributor Author

FaHaGit commented Feb 9, 2026

The thread should no longer be blocked. Since the processing of requests is currently linked to the configuration of responses, it is unfortunately not possible to easy implement whereby the response is only configured when it is sent.

@FaHaGit FaHaGit requested a review from SebaLukas February 16, 2026 11:18
@Pietfried
Copy link
Contributor

The problem should be mitigated with 16bc99b . @FaHaGit Can you please verify if we still need this suggested change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants