Fix DS18S20 broadcast conversion wait#294
Open
94xhn wants to merge 1 commit into
Open
Conversation
Global resolution also selects the broadcast conversion delay. Keep the requested resolution separate while programming configurable devices so fixed-resolution DS18S20 sensors retain their 750 ms wait. Constraint: DS18S20 is 9-bit but requires up to 750 ms to convert Rejected: Return 9 from getResolution | breaks established conversion timing Confidence: high Scope-risk: narrow Directive: Keep broadcast bitResolution at the slowest device on the bus Tested: WSL GCC 13 ASan/UBSan host bus harness; AVR GCC 7.3 atmega328p -Werror compile Not-tested: Physical mixed DS18S20 and DS18B20 bus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
A DS18S20 has a fixed 9-bit temperature register, but its maximum conversion time is 750 ms. The library intentionally returns 12 from the address-based
getResolution()as a conversion-time carrier for this reason (see #1, #4, and #174).setResolution(uint8_t)currently overwrites the globalbitResolutionwith the requested value and asks each address-based setter to skip global recalculation. AftersetResolution(9), a broadcastrequestTemperatures()therefore waits 94 ms even when a DS18S20 is on the bus. Address-based requests still wait 750 ms, so the two paths disagree.The change keeps the caller's requested value for configurable devices while restoring the global wait carrier to 12 when the scan encounters a DS18S20.
Validation
DallasTemperature.cppand reproduced global resolution 9 plus a 94 ms broadcast delay aftersetResolution(9)on a DS18S20 bus.DallasTemperature.cppcompiled foratmega328pwith AVR GCC 7.3,-Os -Wall -Wextra -Werror; RAM usage was unchanged.Not tested on a physical mixed-sensor bus.