From fecc4866ce2740292488146f170e4c242fd158dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kolac=C3=AD?= Date: Wed, 23 Dec 2020 23:36:17 +0100 Subject: [PATCH 1/2] Add packet filtering (Ioniq only) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin KolacĂ­ --- CommObd2Can.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CommObd2Can.cpp b/CommObd2Can.cpp index ba3881c..8b7ccbc 100644 --- a/CommObd2Can.cpp +++ b/CommObd2Can.cpp @@ -222,7 +222,7 @@ void CommObd2Can::sendFlowControlFrame() { Receive PID */ uint8_t CommObd2Can::receivePID() { - + if (!digitalRead(pinCanInt)) // If CAN0_INT pin is low, read receive buffer { lastDataSent = millis(); @@ -237,6 +237,16 @@ uint8_t CommObd2Can::receivePID() { Serial.print(msgString); + // Filter received messages (Ioniq only) + if(liveData->settings.carType == CAR_HYUNDAI_IONIQ_2018) { + long unsigned int atsh_response = liveData->hexToDec(liveData->currentAtshRequest.substring(4), 2, false) + 8; + + if(rxId != atsh_response) { + Serial.println(" [Filtered packet]"); + return 0xff; + } + } + if ((rxId & 0x40000000) == 0x40000000) { // Determine if message is a remote request frame. sprintf(msgString, " REMOTE REQUEST FRAME"); Serial.print(msgString); From 01cbd4592cc5359bff2d21d6ef0f9a950e5bc29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kolac=C3=AD?= Date: Wed, 23 Dec 2020 23:55:14 +0100 Subject: [PATCH 2/2] Add packet filtering (Ioniq only) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin KolacĂ­ --- CommObd2Can.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/CommObd2Can.cpp b/CommObd2Can.cpp index 8b7ccbc..56b8231 100644 --- a/CommObd2Can.cpp +++ b/CommObd2Can.cpp @@ -237,16 +237,6 @@ uint8_t CommObd2Can::receivePID() { Serial.print(msgString); - // Filter received messages (Ioniq only) - if(liveData->settings.carType == CAR_HYUNDAI_IONIQ_2018) { - long unsigned int atsh_response = liveData->hexToDec(liveData->currentAtshRequest.substring(4), 2, false) + 8; - - if(rxId != atsh_response) { - Serial.println(" [Filtered packet]"); - return 0xff; - } - } - if ((rxId & 0x40000000) == 0x40000000) { // Determine if message is a remote request frame. sprintf(msgString, " REMOTE REQUEST FRAME"); Serial.print(msgString); @@ -263,6 +253,16 @@ uint8_t CommObd2Can::receivePID() { Serial.println(" [Ignored packet]"); return 0xff; } + + // Filter received messages (Ioniq only) + if(liveData->settings.carType == CAR_HYUNDAI_IONIQ_2018) { + long unsigned int atsh_response = liveData->hexToDec(liveData->currentAtshRequest.substring(4), 2, false) + 8; + + if(rxId != atsh_response) { + Serial.println(" [Filtered packet]"); + return 0xff; + } + } Serial.println(); processFrameBytes();