Skip to content

Commit

Permalink
Add property that lets the user control whether or not to specify the…
Browse files Browse the repository at this point in the history
… number of responses in PID queries
  • Loading branch information
PowerBroker2 committed Apr 16, 2024
1 parent 464ecaa commit ac50431
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 18 deletions.
56 changes: 38 additions & 18 deletions src/ELMduino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,21 +227,30 @@ void ELM327::formatQueryArray(uint8_t service, uint16_t pid, uint8_t num_respons
query[4] = ((pid >> 4) & 0xF) + '0';
query[5] = (pid & 0xF) + '0';

if (num_responses > 0xF)
if (specifyNumResponses)
{
query[6] = ((num_responses >> 4) & 0xF) + '0';
query[7] = (num_responses & 0xF) + '0';
query[8] = '\0';
if (num_responses > 0xF)
{
query[6] = ((num_responses >> 4) & 0xF) + '0';
query[7] = (num_responses & 0xF) + '0';
query[8] = '\0';

upper(query, 8);
}
else
{
query[6] = (num_responses & 0xF) + '0';
query[7] = '\0';
query[8] = '\0';

upper(query, 8);
upper(query, 7);
}
}
else
{
query[6] = (num_responses & 0xF) + '0';
query[6] = '\0';
query[7] = '\0';
query[8] = '\0';

upper(query, 7);
}
}
else
Expand All @@ -254,25 +263,36 @@ void ELM327::formatQueryArray(uint8_t service, uint16_t pid, uint8_t num_respons
query[2] = ((pid >> 4) & 0xF) + '0';
query[3] = (pid & 0xF) + '0';

if (num_responses > 0xF)
if (specifyNumResponses)
{
query[4] = ((num_responses >> 4) & 0xF) + '0';
query[5] = (num_responses & 0xF) + '0';
query[6] = '\0';
query[7] = '\0';
query[8] = '\0';
if (num_responses > 0xF)
{
query[4] = ((num_responses >> 4) & 0xF) + '0';
query[5] = (num_responses & 0xF) + '0';
query[6] = '\0';
query[7] = '\0';
query[8] = '\0';

upper(query, 6);
upper(query, 6);
}
else
{
query[4] = (num_responses & 0xF) + '0';
query[5] = '\0';
query[6] = '\0';
query[7] = '\0';
query[8] = '\0';

upper(query, 5);
}
}
else
{
query[4] = (num_responses & 0xF) + '0';
query[4] = '\0';
query[5] = '\0';
query[6] = '\0';
query[7] = '\0';
query[8] = '\0';

upper(query, 5);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/ELMduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ class ELM327
Stream* elm_port;

bool connected = false;
bool specifyNumResponses = true;
bool debugMode;
char* payload;
uint16_t PAYLOAD_LEN;
Expand Down

0 comments on commit ac50431

Please sign in to comment.