Skip to content

Commit 3576084

Browse files
authored
Attempt to remedy #220 when 0100 command returns more data than can be handled
1 parent 77874c0 commit 3576084

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/ELMduino.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,20 @@ bool ELM327::initializeELM(const char &protocol, const byte &dataTimeout)
117117
// the timeout value to 30 seconds, then restore the previous value.
118118
uint16_t prevTimeout = timeout_ms;
119119
timeout_ms = 30000;
120+
121+
int8_t state = sendCommand_Blocking("0100");
120122

121-
if (sendCommand_Blocking("0100") == ELM_SUCCESS)
123+
if (state == ELM_SUCCESS)
122124
{
123125
timeout_ms = prevTimeout;
124126
connected = true;
125127
return connected;
126128
}
129+
else if (state == ELM_BUFFER_OVERFLOW)
130+
{
131+
while (elm_port->available())
132+
elm_port->read();
133+
}
127134

128135
timeout_ms = prevTimeout;
129136
}

0 commit comments

Comments
 (0)