Skip to content

Fix DS18S20 broadcast conversion wait#294

Open
94xhn wants to merge 1 commit into
milesburton:masterfrom
94xhn:fix/ds18s20-broadcast-wait
Open

Fix DS18S20 broadcast conversion wait#294
94xhn wants to merge 1 commit into
milesburton:masterfrom
94xhn:fix/ds18s20-broadcast-wait

Conversation

@94xhn

@94xhn 94xhn commented Jul 14, 2026

Copy link
Copy Markdown

Summary

  • keep the requested resolution separate while configuring devices
  • retain the 750 ms broadcast conversion wait when a DS18S20 is present
  • preserve requested 9/10/11-bit settings for configurable sensors regardless of search order

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 global bitResolution with the requested value and asks each address-based setter to skip global recalculation. After setResolution(9), a broadcast requestTemperatures() 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

  • Baseline host bus harness compiled the current DallasTemperature.cpp and reproduced global resolution 9 plus a 94 ms broadcast delay after setResolution(9) on a DS18S20 bus.
  • The fixed source passed the same harness under GCC 13 with ASan/UBSan for a DS18S20-only bus, DS18B20 at 9/10/11/12 bits, and mixed buses in both enumeration orders.
  • The same regression suite passed with MinGW GCC 8.
  • DallasTemperature.cpp compiled for atmega328p with AVR GCC 7.3, -Os -Wall -Wextra -Werror; RAM usage was unchanged.

Not tested on a physical mixed-sensor bus.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant