From 8361ca797bffeecee9ef6eb9005f3472da4b99ee Mon Sep 17 00:00:00 2001 From: Jim Whitelaw Date: Fri, 5 Jan 2024 02:49:03 -0700 Subject: [PATCH 1/2] Squashed commit of the following: commit f501c2e8f1ea9051117bf016d599f4a6c754f207 Author: Jim Whitelaw Date: Fri Jan 5 02:30:53 2024 -0700 Update for fix for #211 --- src/ELMduino.cpp | 12 ++++++------ src/ELMduino.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ELMduino.cpp b/src/ELMduino.cpp index f794553..f0f41b9 100644 --- a/src/ELMduino.cpp +++ b/src/ELMduino.cpp @@ -393,7 +393,7 @@ int8_t ELM327::nextIndex(char const *str, } /* - void ELM327::conditionResponse(const uint8_t &numExpectedBytes, const float &scaleFactor, const float &bias) + double ELM327::conditionResponse(const uint8_t &numExpectedBytes, const float &scaleFactor, const float &bias) Description: ------------ @@ -408,9 +408,9 @@ int8_t ELM327::nextIndex(char const *str, Return: ------- - * float - Converted numerical value + * double - Converted numerical value */ -double ELM327::conditionResponse(const uint8_t &numExpectedBytes, const float &scaleFactor, const float &bias) +double ELM327::conditionResponse(const uint8_t &numExpectedBytes, const double &scaleFactor, const float &bias) { uint8_t numExpectedPayChars = numExpectedBytes * 2; uint8_t payCharDiff = numPayChars - numExpectedPayChars; @@ -475,7 +475,7 @@ double ELM327::conditionResponse(const uint8_t &numExpectedBytes, const float &s } else { - return ((double)(response >> (4 * payCharDiff)) * scaleFactor) + bias; + return ((response >> (4 * payCharDiff)) * scaleFactor) + bias; } } @@ -575,7 +575,7 @@ bool ELM327::queryPID(char queryStr[]) } /* - float ELM327::processPID(const uint8_t& service, const uint16_t& pid, const uint8_t& num_responses, const uint8_t& numExpectedBytes, const float& scaleFactor, const float& bias) + double ELM327::processPID(const uint8_t& service, const uint16_t& pid, const uint8_t& num_responses, const uint8_t& numExpectedBytes, const float& scaleFactor, const float& bias) Description: ------------ @@ -597,7 +597,7 @@ bool ELM327::queryPID(char queryStr[]) ------- * float - The PID value if successfully received, else 0.0 */ -double ELM327::processPID(const uint8_t &service, const uint16_t &pid, const uint8_t &num_responses, const uint8_t &numExpectedBytes, const float &scaleFactor, const float &bias) +double ELM327::processPID(const uint8_t &service, const uint16_t &pid, const uint8_t &num_responses, const uint8_t &numExpectedBytes, const double &scaleFactor, const float &bias) { if (nb_query_state == SEND_COMMAND) { diff --git a/src/ELMduino.h b/src/ELMduino.h index b7f63ec..4b9f8da 100644 --- a/src/ELMduino.h +++ b/src/ELMduino.h @@ -318,12 +318,12 @@ class ELM327 uint64_t findResponse(); bool queryPID(const uint8_t& service, const uint16_t& pid, const uint8_t& num_responses = 1); bool queryPID(char queryStr[]); - double processPID(const uint8_t& service, const uint16_t& pid, const uint8_t& num_responses, const uint8_t& numExpectedBytes, const float& scaleFactor = 1, const float& bias = 0); + double processPID(const uint8_t& service, const uint16_t& pid, const uint8_t& num_responses, const uint8_t& numExpectedBytes, const double& scaleFactor = 1, const float& bias = 0); void sendCommand(const char *cmd); int8_t sendCommand_Blocking(const char *cmd); int8_t get_response(); bool timeout(); - double conditionResponse(const uint8_t& numExpectedBytes, const float& scaleFactor = 1, const float& bias = 0); + double conditionResponse(const uint8_t& numExpectedBytes, const double& scaleFactor = 1, const float& bias = 0); float batteryVoltage(void); int8_t get_vin_blocking(char vin[]); From c0d0da37248b6c58f0d137acf120d7554ff94fb0 Mon Sep 17 00:00:00 2001 From: Jim Whitelaw Date: Mon, 8 Jan 2024 21:27:56 -0700 Subject: [PATCH 2/2] Fix for compile error re: unsigned int #200 --- src/ELMduino.cpp | 2 +- src/ELMduino.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ELMduino.cpp b/src/ELMduino.cpp index f0f41b9..825b1ea 100644 --- a/src/ELMduino.cpp +++ b/src/ELMduino.cpp @@ -2689,7 +2689,7 @@ void ELM327::currentDTCCodes(const bool &isBlocking) // Each response line will start with "43" indicating it is a response to a Mode 03 request. // See p. 31 of ELM327 datasheet for details and lookup table of code types. - uint codesFound = strlen(payload) / 8; // Each code found returns 8 chars starting with "43" + uint8_t codesFound = strlen(payload) / 8; // Each code found returns 8 chars starting with "43" idx = strstr(payload, "43") + 4; // Pointer to first DTC code digit (third char in the response) if (codesFound > DTC_MAX_CODES) // I don't think the ELM is capable of returning diff --git a/src/ELMduino.h b/src/ELMduino.h index 4b9f8da..8040dc1 100644 --- a/src/ELMduino.h +++ b/src/ELMduino.h @@ -271,8 +271,8 @@ const int8_t ELM_TIMEOUT = 7; const int8_t ELM_GETTING_MSG = 8; const int8_t ELM_MSG_RXD = 9; const int8_t ELM_GENERAL_ERROR = -1; -const int8_t DTC_CODE_LEN = 6; -const int8_t DTC_MAX_CODES = 16; +const uint8_t DTC_CODE_LEN = 6; +const uint8_t DTC_MAX_CODES = 16; // Non-blocking (NB) command states typedef enum { SEND_COMMAND, @@ -308,7 +308,7 @@ class ELM327 byte responseByte_7; struct dtcResponse { - uint codesFound = 0; + uint8_t codesFound = 0; char codes[DTC_MAX_CODES][DTC_CODE_LEN]; } DTC_Response;