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

Multiplexer module for ISO communication #776

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

corneliusclaussen
Copy link
Contributor

This module starts and SDP server and waits
for incoming V2G connections (TCP, and optionally TLS). Upon connection, it reads the SupportedAppProtocol.req message to determine if the EV supports ISO-20 or not.

If ISO-20 is supported, it transparently bridges the connection to the ISO-20 module (using TLS->TCP).

If the EV does not support ISO-20, it bridges to the ISO-2 module instead.

Both the required iso-2 and iso-20 modules only need TCP enabled, but they require to accept e.g. PnC on TCP sessions (as the actual communication to the EV may be TLS).
Also the need to listen on localhost (::1) instead of the actual PLC device.

Describe your changes

Issue ticket number and link

Checklist before requesting a review

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

@corneliusclaussen
Copy link
Contributor Author

What's missing: D20 module needs support for ::1 TCP connections via option, both modules need to allow PnC via option on TCP connection. Config files to be updated to actually use D20 module once it is merged.

Copy link
Contributor

@a-w50 a-w50 left a comment

Choose a reason for hiding this comment

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

Stopping reviewing here as most of the code base is copied from the EvseV2G module (and therefore this would be more like a review for that code base). Nice to see that the proxying can be implemented that easy via the connection_proxy functions.
I would recommend for the next time, when copying source files, that they are checked in with their initial/original content in a first commit - so it would be possible to track changes.

// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2022-2023 chargebyte GmbH
// Copyright (C) 2022-2023 Contributors to EVerest
#include "IsoMux.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

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

blank line after main header file


void IsoMux::init() {
/* create v2g context */
v2g_ctx = v2g_ctx_create(&(*r_security));
Copy link
Contributor

Choose a reason for hiding this comment

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

r_security.get()

)
target_sources(${MODULE_NAME}
PRIVATE
"connection/tls_connection.cpp"
Copy link
Contributor

Choose a reason for hiding this comment

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

move to upper target_sources

find_package(PkgConfig REQUIRED)

target_include_directories(${MODULE_NAME} PRIVATE
crypto
Copy link
Contributor

Choose a reason for hiding this comment

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

  • where is this crypto directory?
  • wouldn't include connection here, #include "connection/connection.hpp" should be more explicit

connection
)

target_link_libraries(${MODULE_NAME} PUBLIC -lpthread)
Copy link
Contributor

Choose a reason for hiding this comment

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

would prefer cmakes Threads::Threads if its enough

Comment on lines +43 to +63
mod->r_iso2->subscribe_Require_Auth_EIM([this]() {
if (not mod->selected_iso20()) {
publish_Require_Auth_EIM(nullptr);
}
});
mod->r_iso20->subscribe_Require_Auth_EIM([this]() {
if (mod->selected_iso20()) {
publish_Require_Auth_EIM(nullptr);
}
});

mod->r_iso2->subscribe_Require_Auth_PnC([this](const auto value) {
if (not mod->selected_iso20()) {
publish_Require_Auth_PnC(value);
}
});
mod->r_iso20->subscribe_Require_Auth_PnC([this](const auto value) {
if (mod->selected_iso20()) {
publish_Require_Auth_PnC(value);
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Would sort all these subscriptions by mod->selected_iso20() and not mod->selected_iso20() for better overview. Furthermore, currently as the subscribers don't do anything else it would be probably enough to have one if mod->selected_iso2() block within which you do the subscriptions and the same for the other case

}
});

mod->r_iso2->subscribe_Require_Auth_PnC([this](const auto value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably const auto& value

Comment on lines +502 to +506
void ISO15118_chargerImpl::handle_set_charging_parameters(
types::iso15118_charger::SetupPhysicalValues& physical_values) {
mod->r_iso20->call_set_charging_parameters(physical_values);
mod->r_iso2->call_set_charging_parameters(physical_values);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not easy to reason here, when information needs to be forwarded to both modules and when not.
For the cases where only one module gets informed, it might be easier to have a pointer like active_iso_module which points either to r_iso2 or r_iso20 instead of checking selected_iso20 all the time and making this variable probably obsolete

namespace {

void process_connection_thread(std::shared_ptr<tls::ServerConnection> con, struct v2g_context* ctx) {
assert(con != nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

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

might be question of style, but asserting pointers can also be done simply by assert(con)

proto_ns, app_proto->VersionNumberMajor, app_proto->VersionNumberMinor, app_proto->SchemaID,
app_proto->Priority);

free(proto_ns);
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be done after strncmp.

@corneliusclaussen
Copy link
Contributor Author

Stopping reviewing here as most of the code base is copied from the EvseV2G module (and therefore this would be more like a review for that code base). Nice to see that the proxying can be implemented that easy via the connection_proxy functions. I would recommend for the next time, when copying source files, that they are checked in with their initial/original content in a first commit - so it would be possible to track changes.

Thanks for your review, I'm not sure if it makes sense to fix the issues that are copy past from the EvseV2G module as it will make it harder to merge fixes done to EvseV2G into this module. This module is also just an intermediate solution until the D20 module supports DIN and ISO-2 as well.

This module starts and SDP server and waits
for incoming V2G connections (TCP, and optionally TLS).
Upon connection, it reads the SupportedAppProtocol.req message
to determine if the EV supports ISO-20 or not.

If ISO-20 is supported, it transparently bridges the connection
to the ISO-20 module (using TLS->TCP).

If the EV does not support ISO-20, it bridges to the ISO-2 module
instead.

Both the required iso-2 and iso-20 modules only need TCP enabled,
but they require to accept e.g. PnC on TCP sessions (as the actual
communication to the EV may be TLS).
Also the need to listen on localhost (::1) instead of the actual
PLC device.

Signed-off-by: Cornelius Claussen <[email protected]>
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