From 53e05e1985b597c1de9ef27669d7b2a4709c9fbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=92=A6?= Date: Mon, 17 Jul 2023 11:18:38 +0800 Subject: [PATCH 1/5] Fix the hidden bug which may cause many inexplicable exceptions. For example, after changing the AuthorizationKey, RpcBase::start will be called, but m_results_queue is not set to true. As a result, many inexplicable issues will occur for all subsequent requests. --- src/rpc/RpcBase.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpc/RpcBase.cpp b/src/rpc/RpcBase.cpp index 65afaa16..dcfd978a 100644 --- a/src/rpc/RpcBase.cpp +++ b/src/rpc/RpcBase.cpp @@ -231,6 +231,7 @@ void RpcBase::start() { // Start reception thread m_requests_queue.setEnable(true); + m_results_queue.setEnable(true); m_rx_thread = new std::thread(std::bind(&RpcBase::rxThread, this)); } } From 70ac05986ca87634c8f9a23cba76439aaa73e58b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=92=A6?= Date: Mon, 17 Jul 2023 11:28:16 +0800 Subject: [PATCH 2/5] Fix the problem of invalid judgment in the command ChangeConfigurationConf. Here, value.find should be used to obtain the issued data. --- examples/common/config/OcppConfig.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/common/config/OcppConfig.cpp b/examples/common/config/OcppConfig.cpp index 3c53f5a9..6c4db9be 100644 --- a/examples/common/config/OcppConfig.cpp +++ b/examples/common/config/OcppConfig.cpp @@ -200,8 +200,8 @@ ocpp::types::ConfigurationStatus OcppConfig::setConfiguration(const std::string& std::size_t key_is_interval = key.find("Interval"); if (key_is_interval != std::string::npos) { - std::size_t value_is_negative = key.find("-"); - if (value_is_negative) + std::size_t value_is_negative = value.find("-"); + if (value_is_negative != std::string::npos) { ret = ConfigurationStatus::Rejected; } From b13a07d3d3450c3e5665029a5b5666192872e9b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=92=A6?= Date: Mon, 17 Jul 2023 13:32:20 +0800 Subject: [PATCH 3/5] Fix the precision loss issue in DateTime.h. I think your test was conducted in the UTC timezone, so it was difficult for you to discover this issue. If you are in another timezone, you will notice that the hour, minute, and second data will be lost. For example, in the time judgment of intelligent charging. --- src/types/DateTime.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/types/DateTime.h b/src/types/DateTime.h index 1ba8f79f..13a67006 100644 --- a/src/types/DateTime.h +++ b/src/types/DateTime.h @@ -84,7 +84,6 @@ class DateTime m_datetime = _mkgmtime(&t); #else // _MSC_VER m_datetime = std::mktime(&t); - m_datetime += t.tm_gmtoff; m_datetime -= (t.tm_isdst * 3600); #endif // _MSC_VER ret = true; @@ -179,7 +178,7 @@ class DateTime #ifdef _MSC_VER gmtime_s(&t, &m_datetime); #else // _MSC_VER - gmtime_r(&m_datetime, &t); + localtime_r(&m_datetime, &t); #endif // _MSC_VER ss << std::put_time(&t, "%Y-%m-%dT%TZ"); return ss.str(); From 031efc076f287b78e948e852fc1dc859ab972736 Mon Sep 17 00:00:00 2001 From: c-jimenez <18682655+c-jimenez@users.noreply.github.com> Date: Mon, 24 Jul 2023 09:45:28 +0200 Subject: [PATCH 4/5] [websocket] Fix return values for websocket factory start/stop --- src/websockets/WebsocketFactory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/websockets/WebsocketFactory.cpp b/src/websockets/WebsocketFactory.cpp index 6858f654..ef3044c8 100644 --- a/src/websockets/WebsocketFactory.cpp +++ b/src/websockets/WebsocketFactory.cpp @@ -98,7 +98,7 @@ bool WebsocketFactory::setClientPoolCount(size_t count) /** @brief Start the client pools */ bool WebsocketFactory::startClientPools() { - bool ret = false; + bool ret = true; std::lock_guard lock(s_client_pools_mutex); if (!s_client_pools.empty()) @@ -115,7 +115,7 @@ bool WebsocketFactory::startClientPools() /** @brief Stop the client pools */ bool WebsocketFactory::stopClientPools() { - bool ret = false; + bool ret = true; std::lock_guard lock(s_client_pools_mutex); if (!s_client_pools.empty()) From 58474fdf965e1edadfe800229a407c365d70b7e9 Mon Sep 17 00:00:00 2001 From: c-jimenez <18682655+c-jimenez@users.noreply.github.com> Date: Mon, 24 Jul 2023 09:50:16 +0200 Subject: [PATCH 5/5] Revert "Fix the precision loss issue in DateTime.h. I think your test was conducted in the UTC timezone, so it was difficult for you to discover this issue. If you are in another timezone, you will notice that the hour, minute, and second data will be lost. For example, in the time judgment of intelligent charging." This reverts commit b13a07d3d3450c3e5665029a5b5666192872e9b5. --- src/types/DateTime.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/types/DateTime.h b/src/types/DateTime.h index 13a67006..1ba8f79f 100644 --- a/src/types/DateTime.h +++ b/src/types/DateTime.h @@ -84,6 +84,7 @@ class DateTime m_datetime = _mkgmtime(&t); #else // _MSC_VER m_datetime = std::mktime(&t); + m_datetime += t.tm_gmtoff; m_datetime -= (t.tm_isdst * 3600); #endif // _MSC_VER ret = true; @@ -178,7 +179,7 @@ class DateTime #ifdef _MSC_VER gmtime_s(&t, &m_datetime); #else // _MSC_VER - localtime_r(&m_datetime, &t); + gmtime_r(&m_datetime, &t); #endif // _MSC_VER ss << std::put_time(&t, "%Y-%m-%dT%TZ"); return ss.str();