63 if (!retryIfEchoDoesntMatch)
69 for (
int i = 0; i < 8; ++i)
83 for (i = 0; i < startBytesToMatch; ++i)
90 for (i = 8- endBytesToMatch; i < 8; ++i)
102 delayMicroseconds(100);
108 delayMicroseconds(100);
119 unsigned long currentTime = millis();
131 if (_currentlyCommunicating)
135 _currentlyCommunicating =
true;
136 uint32_t milisStart = millis();
137 while (Serial->read() >= 0);
138 uint32_t milisFlush = millis();
139 Serial->write(tx, 8);
140 uint32_t millisWrite = millis();
143 uint32_t timenow = millis();
144 while (bytesRx < 8 && timenow <= (millisWrite + 50))
146 int32_t data = Serial->read();
154 uint32_t milisread = millis();
157 if (errorHandler != NULL)
162 _currentlyCommunicating =
false;
168 if (errorHandler != NULL)
174 _currentlyCommunicating =
false;
177 _currentlyCommunicating =
false;
181 if (i2cInterface != NULL)
191 if (_currentlyCommunicating)
195 _currentlyCommunicating =
true;
199 i2cInterface->beginTransmission(
address);
200 bytesWritten = i2cInterface->write(tx, 8);
201 i2cResult = i2cInterface->endTransmission();
203 if (bytesWritten == 8 && i2cResult == 0)
209 delayMicroseconds(100);
210 char echoTx[] =
"!COM_ERR";
221 delayMicroseconds(100);
222 i2cInterface->requestFrom(
address, (uint8_t)8);
226 while (r >= 0 && count < 8)
228 r = i2cInterface->read();
232 rx[count] = (uint8_t) r;
243 delayMicroseconds(100);
244 i2cInterface->requestFrom(
address, (uint8_t)8);
247 while (i2cInterface->available() && count < 8)
249 int r = i2cInterface->read();
253 rx[count] = (uint8_t)r;
263 if (errorHandler != NULL)
268 _currentlyCommunicating =
false;
275 if (errorHandler != NULL)
281 _currentlyCommunicating =
false;
285 _currentlyCommunicating =
false;