Skip to content

Commit 6c742a7

Browse files
authored
Changed timeout when blocking till conversion complete
Discussed in issue milesburton#110
1 parent 2503081 commit 6c742a7

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

DallasTemperature.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -423,16 +423,16 @@ bool DallasTemperature::requestTemperaturesByAddress(
423423
// Continue to check if the IC has responded with a temperature
424424
void DallasTemperature::blockTillConversionComplete(uint8_t bitResolution) {
425425

426-
unsigned long delms = millisToWaitForConversion(bitResolution);
427-
if (checkForConversion && !parasite) {
428-
unsigned long start = millis();
429-
while (!isConversionComplete() && (millis() - start < delms))
430-
yield();
431-
} else {
432-
activateExternalPullup();
433-
delay(delms);
434-
deactivateExternalPullup();
435-
}
426+
if (checkForConversion && !parasite) {
427+
unsigned long start = millis();
428+
while (!isConversionComplete() && (millis() - start < MAX_CONVERSION_TIMEOUT ))
429+
yield();
430+
} else {
431+
unsigned long delms = millisToWaitForConversion(bitResolution);
432+
activateExternalPullup();
433+
delay(delms);
434+
deactivateExternalPullup();
435+
}
436436

437437
}
438438

DallasTemperature.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
#define DEVICE_DISCONNECTED_F -196.6
3838
#define DEVICE_DISCONNECTED_RAW -7040
3939

40+
// Other
41+
#define MAX_CONVERSION_TIMEOUT 750
42+
4043
// For readPowerSupply on oneWire bus
4144
#ifndef nullptr
4245
#define nullptr NULL

0 commit comments

Comments
 (0)