From e1188463775b81933b45d619443585b21e5ae4e3 Mon Sep 17 00:00:00 2001 From: wrfz <77174685+wrfz@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:02:48 +0200 Subject: [PATCH] Ignore request and set messages in handle method --- components/daikin_rotex_can/request.cpp | 16 ++++++++++------ components/daikin_rotex_can/request.h | 4 ---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/daikin_rotex_can/request.cpp b/components/daikin_rotex_can/request.cpp index a246456..1800b0a 100644 --- a/components/daikin_rotex_can/request.cpp +++ b/components/daikin_rotex_can/request.cpp @@ -8,7 +8,7 @@ namespace daikin_rotex_can { std::array TRequest::calculate_reponse(TMessage const& message) { const uint16_t DC = 0xFFFF; std::array response = {DC, DC, DC, DC, DC, DC, DC}; - if (message[2] == 0xFA) { + if (message[2] == 0xFA) { // https://github.com/crycode-de/ioBroker.canbus/blob/master/well-known-messages/configs/rotex-hpsu.md response[2] = message[2]; response[3] = message[3]; response[4] = message[4]; @@ -25,14 +25,18 @@ bool TRequest::isGetInProgress() const { } bool TRequest::isMatch(uint32_t can_id, TMessage const& responseData) const { - //if (can_id == get_response_canid()) + const uint16_t response_can_id = (m_command[0] & 0xF0) * 8 + (m_command[1] & 0x0F); + + //if (can_id == response_can_id()) { - for (uint32_t index = 0; index < responseData.size(); ++index) { - if (m_expected_reponse[index] != DC && responseData[index] != m_expected_reponse[index]) { - return false; + if ((responseData[0] & 0x0F) == 0x02) { // is a response + for (uint32_t index = 0; index < responseData.size(); ++index) { + if (m_expected_reponse[index] != DC && responseData[index] != m_expected_reponse[index]) { + return false; + } } + return responseData.size() == 7; } - return responseData.size() == 7; } return false; } diff --git a/components/daikin_rotex_can/request.h b/components/daikin_rotex_can/request.h index 30ee5ed..07290f9 100644 --- a/components/daikin_rotex_can/request.h +++ b/components/daikin_rotex_can/request.h @@ -61,10 +61,6 @@ class TRequest return m_last_handle_timestamp; } - uint16_t get_response_canid() const { - return m_command.size() >= 7 ? (m_command[0] & 0xF0) * 8 + (m_command[1] & 0x0F) : 0x00; - } - bool isMatch(uint32_t can_id, TMessage const& responseData) const; bool handle(uint32_t can_id, TMessage const& responseData, uint32_t timestamp);