handle scale timeouts better
This commit is contained in:
parent
3cf651b338
commit
924ec0719f
|
|
@ -56,7 +56,7 @@ enum {
|
||||||
|
|
|
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
|
|
||||||
static const int32_t fwVersion = 20200629;
|
static const int32_t fwVersion = 20200630;
|
||||||
|
|
||||||
static const byte INIT_PACKAGE_INTERVAL = 100; // send an init package every 100 packages;
|
static const byte INIT_PACKAGE_INTERVAL = 100; // send an init package every 100 packages;
|
||||||
static const byte MAX_VALUES_TO_SEND = 8;
|
static const byte MAX_VALUES_TO_SEND = 8;
|
||||||
|
|
|
||||||
|
|
@ -97,9 +97,11 @@ long ReadScale(char channel)
|
||||||
for (int i = 0; i < num_scale_readings; i++) {
|
for (int i = 0; i < num_scale_readings; i++) {
|
||||||
//while (digitalRead(interruptPin) == LOW) {
|
//while (digitalRead(interruptPin) == LOW) {
|
||||||
long mytimer = millis();
|
long mytimer = millis();
|
||||||
while (! myScale.available()) {
|
int timeouts = 0;
|
||||||
|
while (! myScale.available() && (timeouts < 3)) {
|
||||||
// we set a timeout of 10 seconds for the measurement...
|
// we set a timeout of 10 seconds for the measurement...
|
||||||
if ((millis() - mytimer) > 10000) {
|
if ((millis() - mytimer) > 10000) {
|
||||||
|
timeouts = timeouts + 1;
|
||||||
// Timeout reading scale...
|
// Timeout reading scale...
|
||||||
Wire.endTransmission(true);
|
Wire.endTransmission(true);
|
||||||
delay(50);
|
delay(50);
|
||||||
|
|
@ -107,7 +109,6 @@ long ReadScale(char channel)
|
||||||
if (debug_level > 0) {
|
if (debug_level > 0) {
|
||||||
gCatena.SafePrintf("Timeout while reading scale...\n");
|
gCatena.SafePrintf("Timeout while reading scale...\n");
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
delay(50);
|
delay(50);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue