Fix: implement missing saveScratchPadByIndex/recallScratchPadByIndex#293
Open
94xhn wants to merge 1 commit into
Open
Fix: implement missing saveScratchPadByIndex/recallScratchPadByIndex#29394xhn wants to merge 1 commit into
94xhn wants to merge 1 commit into
Conversation
DallasTemperature.h declares saveScratchPadByIndex() and recallScratchPadByIndex(), and both are documented and used in the SaveRecallScratchPad example, but their implementations were dropped from DallasTemperature.cpp during the race-condition refactor merged in milesburton#264. Any sketch calling either method now fails at link time with "undefined reference to DallasTemperature::saveScratchPadByIndex(...)" (and the recall counterpart). Restore the two thin wrapper functions that resolve a device index to its address via getAddress() and delegate to the existing saveScratchPad()/recallScratchPad() overloads, matching their pre-refactor behavior.
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.
Problem
DallasTemperature.hdeclaressaveScratchPadByIndex(uint8_t)andrecallScratchPadByIndex(uint8_t), and both are referenced in theSaveRecallScratchPadexample, but their implementations are missing fromDallasTemperature.cpp. They appear to have been dropped during the race-condition refactor merged in #264 (the header declarations, keywords.txt entries, and example comments survived the refactor; the two.cppbodies did not).Any sketch that calls either method now compiles fine but fails at link time:
Fix
Restore the two thin wrapper functions (same logic as before the refactor): resolve the device index to its address via
getAddress(), then delegate to the existingsaveScratchPad()/recallScratchPad()address-based overloads.The change is purely additive — no other lines in the file are touched, and no header changes are needed since the declarations are already correct.
Testing
Built a small host-side harness (stub
Arduino.h/OneWire.h+ aDallasTemperatureinstance with a mocked single-device bus) and confirmed:master(unmodified): compiles, fails to link with the undefined-reference errors above.saveScratchPadByIndex(0)/recallScratchPadByIndex(0)both returntruefor a valid index andfalsefor an out-of-range index (matchinggetAddress()'s failure propagation), with no change to any other existing behavior (getResolution(),isParasitePowerMode(), etc. all unaffected).