Repository navigation
fix: build Trend Log 1's Start_Time/Stop_Time window from UTC, not local time (#2051) - #9
Merged
Merged
Conversation
…cal time (#2051) BACnetStack_SetTrendLogStartStopTime's window was built with localtime_s/localtime_r, but HelperGetSystemTime() returns raw time(0) and this example serves no Device UTC_Offset, so the stack's own "now" (a BACnetDateTime built from GetSystemTime + UTC_Offset=0) is UTC wall-clock, not local wall-clock. On any host not in UTC, the local-time window no longer bracketed the clock the stack actually compares against - west of UTC, Stop_Time landed BEFORE the stack's "now" so ReadyToLog's stopTimeGood check never passed and Record_Count stayed at 0 forever; east of UTC, Start_Time would fail the same way instead. Fixed by switching to gmtime_s/gmtime_r, so the window is built from the same clock the stack uses. Live-verified with bacpypes3: Record_Count climbs continuously (observed 14 -> 29 -> 44 over 30 seconds). Removed TODO.md item 1 (resolved) and renumbered the rest. Updated CHANGELOG.md, README.md, TUTORIAL.md, AGENTS.md and docs/objects.json / docs/PICS.md to drop the "known gap" framing now that Lilac accumulates records correctly. The docs/PICS.md OBJECTS-PROPERTIES block was hand-edited to match the docs/objects.json change 1:1, since tools/gen-objects- properties.py lives in the series-root repo and wasn't available in this checkout - please re-run it to confirm the sync. Fixes chipkin/cas-bacnet-stack#2051.
sws-chipkin
force-pushed
the
fix/2051-trend-log-record-count
branch
from
September 23, 2026 05:54
6d25d57 to
877ae90
Compare
Collaborator
Author
|
Rebased onto main (TODO.md conflict resolved: main's re-verification of the Lilac gap predates this fix, since main.cpp still used localtime) and merged after CI (ubuntu + windows-2022 green). Stack-side: the clock is now documented on BACnetStack_SetTrendLogStartStopTime (chipkin/cas-bacnet-stack#2344, IFC-044). Not changed here, worth a look: the SCHED-I-B DemoAdvance key (main.cpp, KeyCommand::DemoAdvance) also builds its Weekly_Schedule entry from localtime, while the schedule engine evaluates against the device's Local_Date/Local_Time - check it still fires on a non-UTC host. |
sws-chipkin
added a commit
that referenced
this pull request
Sep 23, 2026
Conflicts resolved in favour of both sides: - #9 showed #2051 was an example bug (window built from local time, stack compares UTC), not a stack defect. Dropped every "Lilac never records" claim this branch had carried forward; TODO.md item 1 stays removed and items are renumbered (tracking-issue list, cross-refs in AGENTS.md, TUTORIAL.md and docs/objects.json updated to match). - Kept this branch's 6.0.22 / SCHED-E-B / #2340-#2343 content. - Moved #9's CHANGELOG entry out of the 1.0.1 section into 1.0.6. - Last #963 references -> #1758; PICS regenerated. Re-verified live on the merged build (v1.0.6, stack 6.0.22): Trend Log 1 Record_Count 20, Trend Log Multiple 1 21, 0 flood lines, RPM(Device, ALL) ok, tests/sched_e_b_remote_peer.py PASS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Fixes chipkin/cas-bacnet-stack#2051: Trend Log 1 ("Lilac")'s
Record_Countnever incremented.HelperGetSystemTime()returns rawtime(0)and this example serves no DeviceUTC_Offset, so the stack's own "now" (aBACnetDateTimebuilt fromGetSystemTime+UTC_Offset=0) is UTC wall-clock, not local wall-clock.SetTrendLogStartStopTime's window was built withlocaltime_s/localtime_r— on any host not in UTC, the window no longer bracketed the clock the stack actually compares against, soReadyToLognever passed.gmtime_s/gmtime_r.docs/objects.json/docs/PICS.mdto drop the "known gap" framing.Note on
docs/PICS.mdThe
OBJECTS-PROPERTIESgenerated block was hand-edited to match thedocs/objects.jsonchange exactly, sincetools/gen-objects-properties.pylives in the series-root repo and wasn't available in this checkout. Please re-runpython tools/gen-objects-properties.py BACnetProfileExample-B-BC-CPP --checkto confirm the sync before merging.Test plan
cmake --build build --config Release→ succeeds, 0 errorsRecord_Countclimbs continuously (observed 14 → 29 → 44 over 30 seconds)🤖 Generated with Claude Code