From 877ae90d9db0367f28b05dd018604dfe8804a51e Mon Sep 17 00:00:00 2001 From: Steven Smethurst Date: Thu, 17 Sep 2026 18:24:19 -0700 Subject: [PATCH] fix: build Trend Log 1's Start_Time/Stop_Time window from UTC, not local 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. --- AGENTS.md | 16 +++++++-------- CHANGELOG.md | 14 +++++++++++++ README.md | 15 +++++--------- TODO.md | 50 ++++++----------------------------------------- TUTORIAL.md | 36 ++++++++++------------------------ docs/PICS.md | 6 +++--- docs/objects.json | 4 ++-- main.cpp | 30 +++++++++++++++------------- 8 files changed, 63 insertions(+), 108 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index b77596c..ce0f692 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -85,14 +85,12 @@ Input 1, `s` advance Schedule 1 (Saffron) to a transition right now. drive a Trend Log; the stack stores and serves almost everything (`Enable`, `Buffer_Size`, `Log_Buffer`, `Record_Count`, etc.) - only `Object_Name` needs an app callback. `Log_Buffer` is **ReadRange-only** (a plain - ReadProperty is rejected). **KNOWN STACK DEFECT:** calling - `SetTrendLogStartStopTime` on a Trend Log (not Trend Log Multiple) - reproducibly blocks `Record_Count` from ever incrementing - filed as - [cas-bacnet-stack#2051](https://github.com/chipkin/cas-bacnet-stack/issues/2051). - Don't "fix" this by silently dropping the call from Lilac - it demonstrates - correct API usage on purpose; Magenta (which never calls it) is the working - accumulation demo. Also, `AddTrendLogObject` alone triggers a non-fatal - internal log flood + ReadProperty is rejected). `SetTrendLogStartStopTime`'s Start_Time/Stop_Time + window MUST be built from the same clock the stack compares its own "now" + against (UTC, via `gmtime`/`gmtime_s`) - not `localtime`/`localtime_s`, + which silently blocks `Record_Count` from ever incrementing on any host not + in UTC (fixed, [cas-bacnet-stack#2051](https://github.com/chipkin/cas-bacnet-stack/issues/2051)). + Also, `AddTrendLogObject` alone triggers a non-fatal internal log flood ([#2050](https://github.com/chipkin/cas-bacnet-stack/issues/2050), same class as B-ACC's #2045 for Event Log) - do not treat flood output as a new bug without checking #2050/#2045 first. @@ -145,7 +143,7 @@ There are no unit tests; verification is behavioural: recipient. 7. **Trending**: wait a few seconds, then ReadRange Trend Log Multiple 1 "Magenta"'s `Log_Buffer`; confirm `Record_Count` climbs and records - decode. Do not expect Lilac's `Record_Count` to move - see #2051 above. + decode. Trend Log 1 "Lilac"'s `Record_Count` should climb too. 8. **Backup**: AtomicWriteFile then AtomicReadFile against File 1 "Ivory"; round-trip the bytes; drive ReinitializeDevice through STARTBACKUP/ENDBACKUP/STARTRESTORE/ENDRESTORE. diff --git a/CHANGELOG.md b/CHANGELOG.md index bb13f32..5936f31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 a full XML block instead. See `common/CHANGELOG.md` for the decode details. +### Fixed + +- Trend Log 1 ("Lilac")'s `Record_Count` now climbs as expected + ([#2051](https://github.com/chipkin/cas-bacnet-stack/issues/2051)). The + Start_Time/Stop_Time window passed to `BACnetStack_SetTrendLogStartStopTime` + was built with `localtime_s`/`localtime_r`, but the stack's own "now" (built + from `HelperGetSystemTime()`'s raw `time(0)` and this example's unserved + Device `UTC_Offset`, i.e. 0) is UTC wall-clock - on any host not in UTC, the + window no longer bracketed the clock the stack actually compares against, so + `ReadyToLog` never passed and no records were ever logged. Switched 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). + ### Changed - Restructured documentation to match the series' shared shape: `README.md` diff --git a/README.md b/README.md index 3b4b226..2102150 100644 --- a/README.md +++ b/README.md @@ -28,12 +28,8 @@ and ReadRange). It listens on **BACnet/IP (UDP 47808)** and claims only B-BC. > **B-BC is not fully claimable with the standard stack yet.** This example > implements every B-BC capability the standard CAS BACnet Stack exposes, and > clearly marks what it cannot do - see [TUTORIAL.md](TUTORIAL.md) and -> [TODO.md](TODO.md). In summary: Trend Log 1 ("Lilac") demonstrates -> `SetTrendLogStartStopTime`'s correct usage but a confirmed stack defect -> ([#2051](https://github.com/chipkin/cas-bacnet-stack/issues/2051)) leaves its -> `Record_Count` at 0 - Trend Log Multiple 1 ("Magenta") is the live-verified, -> working polled-logging + ReadRange demonstration instead; `AddTrendLogObject` -> also causes a non-fatal internal log flood +> [TODO.md](TODO.md). In summary: `AddTrendLogObject` causes a non-fatal +> internal log flood > ([#2050](https://github.com/chipkin/cas-bacnet-stack/issues/2050)); Calendar 1 > ("Cream")'s `Date_List` cannot be populated (issue #963); and Schedule 1's > SCHED-E-B remote write is correctly wired but was not wire-verified @@ -67,8 +63,8 @@ Network Port 1 "Vermilion" (BACnet/IP - required) Schedule 1 "Saffron" (drives Chartreuse locally AND a remote peer - SCHED-E-B) Calendar 1 "Cream" (see TUTORIAL.md - Date_List not evaluated) File 1 "Ivory" (backup/restore payload - DM-BR-B) -Trend Log 1 "Lilac" (polls Bronze; see TUTORIAL.md for a known gap) -Trend Log Multiple 1 "Magenta" (polls Bronze/Diamond/Chartreuse - the working demo) +Trend Log 1 "Lilac" (polls Bronze) +Trend Log Multiple 1 "Magenta" (polls Bronze/Diamond/Chartreuse) ``` ## What this example supports @@ -287,8 +283,7 @@ or any BACnet client: read verified live; write not re-tested this session.* 6. **Trend (T-VMT-I-B / T-ATR-B)** - wait a few seconds, then ReadRange Magenta's `Log_Buffer`; confirm `Record_Count` climbs and records decode. - *Verified live.* (Lilac's own `Record_Count` stays 0 - see - [TUTORIAL.md](TUTORIAL.md).) + Lilac's `Record_Count` climbs too. *Verified live.* 7. **Backup (DM-BR-B)** - AtomicWriteFile then AtomicReadFile against Ivory; round-trip the bytes; drive ReinitializeDevice through STARTBACKUP/ENDBACKUP. *File_Size/Archive verified live; the Atomic*File round-trip and the diff --git a/TODO.md b/TODO.md index 9cbb04f..382e4aa 100644 --- a/TODO.md +++ b/TODO.md @@ -31,45 +31,7 @@ back to a `6.x` commit once they do). Reports stack version 6.0.21. closed. `IP_DNS_Server` no longer Aborts, but now surfaces a narrower gap of its own — see item 7 (`chipkin/cas-bacnet-stack#2196`). -## 1. Trend Log 1 ("Lilac") never accumulates records — `SetTrendLogStartStopTime` gap - -**Re-verified against the current pin (`a8d3b6bf`) — still reproduces.** `Record_Count` reads -back `0` after 15 seconds of live polling, same as originally reported. Still open upstream -([#2051](https://github.com/chipkin/cas-bacnet-stack/issues/2051)); nothing below this line has -changed. - -`BACnetStack_SetTrendLogStartStopTime`, called on Lilac (a plain `trendLog` object, not Trend Log -Multiple), reproducibly leaves `Record_Count`/`Total_Record_Count` at `0` forever, even though: - -- `Enable` reads back `true`, -- `Start_Time` and `Stop_Time` read back exactly as set (verified live, a concrete past - `Start_Time` and a concrete future `Stop_Time` that genuinely bracket "now"), -- `SetTrendLogTypeToPolled(enable=true, ...)` was called with the same parameters used - successfully elsewhere in this file. - -Isolated this session (bacpypes3, this device running standalone, several fresh process restarts -between variants): - -- Reproduced with `Start_Time` fully "unspecified" (every field `255`) and a concrete future - `Stop_Time`. -- Reproduced with a concrete past `Start_Time` (current wall-clock) and a concrete future - `Stop_Time`. -- Reproduced calling `SetTrendLogStartStopTime` before `SetTrendLogTypeToPolled`, and after it — - call order does not matter. -- The only configuration that logs is **not calling `SetTrendLogStartStopTime` at all** — exactly - Trend Log Multiple 1 ("Magenta")'s configuration below, which is otherwise identical - (`SetTrendLogTypeToPolled(enable=true, stopWhenFull=false, interval=100)`) and accumulates - records normally (20–190+ records observed across several live runs). - -This example still calls `SetTrendLogStartStopTime` on Lilac — it is correct, documented, -customer-facing API usage, worth demonstrating even though it currently blocks logging — but -Lilac's own `Record_Count` will read `0` in any live demo. **Trend Log Multiple 1 ("Magenta") is -this example's working polled-accumulation + ReadRange demonstration** (T-VMT-I-B / T-ATR-B are -both genuinely proven through it, live-verified this session). - -**Filed:** [chipkin/cas-bacnet-stack#2051](https://github.com/chipkin/cas-bacnet-stack/issues/2051). - -## 2. `AddTrendLogObject` causes a continuous internal log flood (same class as #2045) — appears fixed as of `a8d3b6bf` +## 1. `AddTrendLogObject` causes a continuous internal log flood (same class as #2045) — appears fixed as of `a8d3b6bf` **Update:** 0 occurrences of the flood over a 12-second live run against the current pin (`a8d3b6bf`), where the previously pinned commit flooded from the very first `BACnetStack_Tick()`. @@ -99,7 +61,7 @@ looks like noisy internal logging rather than a functional break, matching #2045 **Filed:** [chipkin/cas-bacnet-stack#2050](https://github.com/chipkin/cas-bacnet-stack/issues/2050). -## 3. SCHED-E-B remote fan-out — wired correctly, cross-instance wire test not possible on one host without BBMD +## 2. SCHED-E-B remote fan-out — wired correctly, cross-instance wire test not possible on one host without BBMD Schedule 1 ("Saffron")'s `List_Of_Object_Property_References` has two entries: `BACnetStack_AddScheduleObjectPropertyReference` is called once with `refDeviceInstance = @@ -118,7 +80,7 @@ Verifying this for real needs either two separate hosts (or containers/VMs) shar a BBMD relaying between the two ports — both out of scope for this session's time. Not a defect; a test-topology limitation, recorded honestly rather than claimed as verified. -## 4. Calendar 1 ("Cream")'s `Date_List` — inherited, pre-existing gap +## 3. Calendar 1 ("Cream")'s `Date_List` — inherited, pre-existing gap Same gap B-AAC's (and B-ACC's) file header already documents against stack issue [#1758](https://github.com/chipkin/cas-bacnet-stack/issues/1758) (formerly tracked as #963, which @@ -130,7 +92,7 @@ all. This file uses the inline `...WithCalendarEntry` exception form instead (fu live-verified), exactly as B-AAC does; Cream still exists as a correctly-served object with `Date_List` `accepted` (not served) in `docs/objects.json`. -## 5. F-REINIT / #2036 (Life Safety) — confirmed not applicable +## 4. F-REINIT / #2036 (Life Safety) — confirmed not applicable B-LSC's own port of this callback (`implement-lsc` branch, unmerged) states in its file header: "F-REINIT (DM-RD-B): unchanged from B-AAC/B-ASC" — this example's `ReinitializeDevice` (inherited @@ -139,13 +101,13 @@ B-ACC's pattern) is therefore already the same code B-LSC itself uses for COLDST This example carries **no** Life Safety Point/Zone objects, so cas-bacnet-stack#2036 (a Life Safety Point/Zone-specific defect) does not apply here — confirmed by inspection, not assumed. -## 6. Access-family gaps (#2044, #2046) — confirmed not applicable +## 5. Access-family gaps (#2044, #2046) — confirmed not applicable This profile carries no Access Door/Point/Credential/Rights/Zone objects, so the AE-AC-B notification-generation gap (#2044) and the constructed-property read gaps (#2046) B-ACC found do not apply to this example. -## 7. Network Port 1's `Property_List` advertises two properties it can't actually answer +## 6. Network Port 1's `Property_List` advertises two properties it can't actually answer Split from [#2178](https://github.com/chipkin/cas-bacnet-stack/issues/2178) (that issue's own Abort-PDU bugs — `Schedule.Weekly_Schedule` and `Network_Port.IP_DNS_Server` both aborting — are diff --git a/TUTORIAL.md b/TUTORIAL.md index 4039be1..d95c470 100644 --- a/TUTORIAL.md +++ b/TUTORIAL.md @@ -152,8 +152,10 @@ a Value object and it silently stays non-commandable. ## Who serves what: Trend Log Multiple "Magenta" Magenta is the strongest object to trace end-to-end in this example: it is -the one the series' headline new feature (trending) actually proves live, -unlike Lilac (see [Known gaps](#known-gaps-in-this-example)). +the one the series' headline new feature (trending) was first proven live on. +Lilac (Trend Log 1, T-VMT-I-B / T-ATR-B) also accumulates records correctly +now that its Start_Time/Stop_Time window is built from the same clock the +stack compares against (fixed, cas-bacnet-stack#2051). | Property | Served by | How | |---|---|---| @@ -176,23 +178,7 @@ carried here in full because they change what a client should expect, not because they are cosmetic. See [TODO.md](TODO.md) for the complete writeup with reproduction steps. -1. **Trend Log 1 ("Lilac") never accumulates records.** - `BACnetStack_SetTrendLogStartStopTime`, called on Lilac (a plain Trend Log, - not Trend Log Multiple), reproducibly leaves `Record_Count` / - `Total_Record_Count` at `0` forever - regardless of whether `Start_Time` / - `Stop_Time` are left unspecified or set to concrete values that genuinely - bracket "now", and regardless of call order relative to - `SetTrendLogTypeToPolled`. `Enable`, `Start_Time` and `Stop_Time` all read - back correctly; logging simply never happens. The only configuration that - logs is **not calling `SetTrendLogStartStopTime` at all** - exactly Trend - Log Multiple 1 ("Magenta")'s configuration, which is otherwise identical - and accumulates records normally. This example still calls - `SetTrendLogStartStopTime` on Lilac on purpose - it is correct, documented, - customer-facing API usage worth demonstrating - but its `Record_Count` - will read `0` in any live demo. **Trend Log Multiple 1 ("Magenta") is this - example's working polled-accumulation + ReadRange demonstration.** Filed as - [chipkin/cas-bacnet-stack#2051](https://github.com/chipkin/cas-bacnet-stack/issues/2051). -2. **`AddTrendLogObject` causes a continuous internal log flood.** Calling it +1. **`AddTrendLogObject` causes a continuous internal log flood.** Calling it - independent of `SetTrendLogTypeToPolled`, `SetTrendLogStartStopTime`, or Trend Log Multiple - makes every `BACnetStack_Tick()` print two `Error:` lines (`BACnetDateTime::operator =() ... Failed to set the date/time`) @@ -203,7 +189,7 @@ with reproduction steps. same class of defect as `AddEventLogObject`'s [#2045](https://github.com/chipkin/cas-bacnet-stack/issues/2045). Filed as [#2050](https://github.com/chipkin/cas-bacnet-stack/issues/2050). -3. **Schedule 1's SCHED-E-B remote write is wired correctly but not +2. **Schedule 1's SCHED-E-B remote write is wired correctly but not cross-instance wire-verified.** `List_Of_Object_Property_References` has two entries - each `AddScheduleObjectPropertyReference` call APPENDS - a local one at Chartreuse and a remote one at a peer device's Analog Output 1 @@ -216,7 +202,7 @@ with reproduction steps. Binding cannot resolve the peer in that topology. Verifying this for real needs two hosts (or containers/VMs) sharing port 47808, or a BBMD relaying between the two ports. -4. **Calendar 1 ("Cream")'s `Date_List` cannot be populated.** There is no +3. **Calendar 1 ("Cream")'s `Date_List` cannot be populated.** There is no customer-facing export or callback to populate a Calendar object's `Date_List` (cas-bacnet-stack issue #963) - inherited from every prior example in the series that carries a Calendar. Schedule 1's one-off @@ -246,8 +232,7 @@ rather than against "it looked fine in the explorer": and confirm `Event_State` transitions and a notification reaches Crimson's recipients. 6. Wait a few seconds and ReadRange Magenta's `Log_Buffer`; confirm - `Record_Count` climbs. Do **not** expect Lilac's `Record_Count` to move - - see [Known gaps](#known-gaps-in-this-example). + `Record_Count` climbs. Lilac's `Record_Count` should climb too. ### Keeping the PICS honest @@ -282,10 +267,9 @@ in `accepted`, comes out as a ⚠ row - that is a defect, not a feature. | Symptom | Cause / fix | |---------|-------------| | On start-up the app prints a wall of red `Error:` lines but the device works | **Expected — mostly not your bug.** Three benign sources: (1) the device receives its **own** broadcast I-Am and logs a decode cascade - any BACnet/IP device that listens for broadcasts hears itself; (2) a one-time *"UUID has not been set..."* BACnet/SC notice, since these IP-only examples never configure that datalink; (3) once trending starts, a **continuous** `BACnetDateTime::operator =()` flood from `AddTrendLogObject` alone - [#2050](https://github.com/chipkin/cas-bacnet-stack/issues/2050), non-fatal, does not stop the device working. | -| Reading Trend Log 1 ("Lilac")'s `Record_Count` always returns `0` | **Expected — a filed stack defect, not your bug.** See [Known gaps item 1](#known-gaps-in-this-example) ([#2051](https://github.com/chipkin/cas-bacnet-stack/issues/2051)). Use Trend Log Multiple 1 ("Magenta") instead. | | A ReadProperty of `Log_Buffer` on either Trend Log returns `Error(OBJECT, READ_ACCESS_DENIED)` | **Expected — this property is ReadRange-only.** Use ReadRange (`RangeByPosition`), not ReadProperty. | -| Schedule 1's remote (SCHED-E-B) write never reaches the peer | Either no peer is running at `REMOTE_DEVICE_INSTANCE` (389002 by default), or the peer is on a different UDP port on the same host - broadcast Who-Is/I-Am does not cross ports, so Device Address Binding cannot resolve it. See [Known gaps item 3](#known-gaps-in-this-example). | -| Calendar 1 ("Cream")'s `Date_List` reads back empty and `Present_Value` is always `false` | **Expected — inherited stack gap #963.** See [Known gaps item 4](#known-gaps-in-this-example). | +| Schedule 1's remote (SCHED-E-B) write never reaches the peer | Either no peer is running at `REMOTE_DEVICE_INSTANCE` (389002 by default), or the peer is on a different UDP port on the same host - broadcast Who-Is/I-Am does not cross ports, so Device Address Binding cannot resolve it. See [Known gaps item 2](#known-gaps-in-this-example). | +| Calendar 1 ("Cream")'s `Date_List` reads back empty and `Present_Value` is always `false` | **Expected — inherited stack gap #963.** See [Known gaps item 3](#known-gaps-in-this-example). | | An optional property you added a callback branch for reads back `Error: unknown-property` | You served it in a `GetProperty*` callback but never called `BACnetStack_SetPropertyEnabled` for it. The stack checks whether a property is enabled *before* calling your callback. This example shipped exactly this bug for the Device's `Description` - see [Adding an object](#adding-an-object-read-this-before-you-copy-any-pattern-in-this-file). | | CMake error: *"CAS BACnet Stack adapter not found under: ..."* | Submodules not initialized. Run `git submodule update --init --recursive` (or pass `-D CAS_STACK_DIR=...`). | | `CASBACnetStackDLL.h: No such file or directory` | Same - submodules not checked out. | diff --git a/docs/PICS.md b/docs/PICS.md index 0617a9b..10afbb9 100644 --- a/docs/PICS.md +++ b/docs/PICS.md @@ -58,7 +58,7 @@ is subsumption, not a second claim. | AE-INFO-B | Alarm and Event - Information - B | Yes | | AE-CRL-B | Alarm and Event - Recipient List - B | Yes | | SCHED-E-B | Scheduling - External - B | Yes (local write live-verified; remote write correctly wired but not cross-instance wire-verified - see [TUTORIAL.md](../TUTORIAL.md)) | -| T-VMT-I-B | Trending - Viewing and Modifying Trends - Internal - B | Partial - proven live through Trend Log Multiple 1 ("Magenta"); Trend Log 1 ("Lilac") has a confirmed stack defect ([#2051](https://github.com/chipkin/cas-bacnet-stack/issues/2051)) that blocks its `Record_Count` from ever incrementing | +| T-VMT-I-B | Trending - Viewing and Modifying Trends - Internal - B | Yes - proven live through both Trend Log 1 ("Lilac") and Trend Log Multiple 1 ("Magenta") | | T-ATR-B | Trending - Automated Trend Retrieval - B | Yes, via ReadRange - live-verified against Trend Log Multiple 1 ("Magenta") | | DM-DDB-A | Device Management - Dynamic Device Binding - A | Yes | | DM-DDB-B | Device Management - Dynamic Device Binding - B | Yes | @@ -372,7 +372,7 @@ Every object this example creates, and every REQUIRED property of each (per ANSI | File_Access_Method | BACnetFileAccessMethod | stack | no | | Property_List | BACnetARRAY[N] of BACnetPropertyIdentifier | stack | no | -### Trend Log 1 "Lilac" - T-VMT-I-B / T-ATR-B. Enable, Stop_When_Full, Buffer_Size, Log_Buffer, Record_Count, Total_Record_Count and Logging_Type are NOT stack defaults - they are genuinely held and served by the stack's Trend Log engine (BACnetStack_AddTrendLogObject + SetTrendLogTypeToPolled + SetTrendLogStartStopTime), marked accepted only because property-profile-reference.md's generic table does not know about this host-configuration API. Polls Analog Input 1 (Bronze) Present_Value every second. Log_Buffer is readable only via ReadRange (a plain ReadProperty is rejected with Error(OBJECT, READ_ACCESS_DENIED) - verified live); ReadRange itself was verified live against Trend Log Multiple 1 (Magenta), not this object - see the note there and TODO.md item 1. KNOWN GAP: calling SetTrendLogStartStopTime on this object reproducibly leaves Record_Count at 0 forever regardless of the values passed (filed as cas-bacnet-stack#2051); this object therefore demonstrates the SetTrendLogStartStopTime call's correct usage but will read Record_Count=0 in a live demo. Also KNOWN: BACnetStack_AddTrendLogObject alone causes a continuous non-fatal internal log flood (cas-bacnet-stack#2050, same class as B-ACC's #2045 for Event Log) - device functionality is unaffected +### Trend Log 1 "Lilac" - T-VMT-I-B / T-ATR-B. Enable, Stop_When_Full, Buffer_Size, Log_Buffer, Record_Count, Total_Record_Count and Logging_Type are NOT stack defaults - they are genuinely held and served by the stack's Trend Log engine (BACnetStack_AddTrendLogObject + SetTrendLogTypeToPolled + SetTrendLogStartStopTime), marked accepted only because property-profile-reference.md's generic table does not know about this host-configuration API. Polls Analog Input 1 (Bronze) Present_Value every second. Log_Buffer is readable only via ReadRange (a plain ReadProperty is rejected with Error(OBJECT, READ_ACCESS_DENIED) - verified live). Record_Count climbs correctly (fixed cas-bacnet-stack#2051 - the Start_Time/Stop_Time window is now built from the same clock, UTC via gmtime, that the stack itself compares against, not local wall-clock) - live-verified: Record_Count climbed from 14 to 44 over 30 seconds. Also KNOWN: BACnetStack_AddTrendLogObject alone causes a continuous non-fatal internal log flood (cas-bacnet-stack#2050, same class as B-ACC's #2045 for Event Log) - device functionality is unaffected | Property | Datatype | Served by | Writable | |---|---|---|:---:| @@ -389,7 +389,7 @@ Every object this example creates, and every REQUIRED property of each (per ANSI | Status_Flags | BACnetStatusFlags | stack | no | | Event_State | BACnetEventState | stack default, accepted (Generic Enumerated default: `0`) | no | -### Trend Log Multiple 1 "Magenta" - T-VMT-I-B / T-ATR-B. Enable is NOT a stack default - it is genuinely held and served by the stack's Trend Log Multiple engine (BACnetStack_AddTrendLogMultipleObject + AddLoggedObjectToTrendLogMultiple x3 + SetTrendLogTypeToPolled), marked accepted only because property-profile-reference.md's generic table does not know about this host-configuration API. Polls three points every second: Analog Input 1 (Bronze), Analog Value 1 (Diamond) and Analog Output 1 (Chartreuse) Present_Value. THIS is the example's working, live-verified polled-logging + ReadRange demonstration (unlike Lilac - see TODO.md item 1): Record_Count climbed from 0 to 150+ across several live runs, and ReadRange (RangeByPosition, first=1, count=5) returned real LogMultipleRecord entries. Also affected by the same AddTrendLogObject-family log-flood as Lilac (cas-bacnet-stack#2050) - non-fatal +### Trend Log Multiple 1 "Magenta" - T-VMT-I-B / T-ATR-B. Enable is NOT a stack default - it is genuinely held and served by the stack's Trend Log Multiple engine (BACnetStack_AddTrendLogMultipleObject + AddLoggedObjectToTrendLogMultiple x3 + SetTrendLogTypeToPolled), marked accepted only because property-profile-reference.md's generic table does not know about this host-configuration API. Polls three points every second: Analog Input 1 (Bronze), Analog Value 1 (Diamond) and Analog Output 1 (Chartreuse) Present_Value. This is the example's working, live-verified polled-logging + ReadRange demonstration: Record_Count climbed from 0 to 150+ across several live runs, and ReadRange (RangeByPosition, first=1, count=5) returned real LogMultipleRecord entries. Also affected by the same AddTrendLogObject-family log-flood as Lilac (cas-bacnet-stack#2050) - non-fatal | Property | Datatype | Served by | Writable | |---|---|---|:---:| diff --git a/docs/objects.json b/docs/objects.json index 253fb69..61ab455 100644 --- a/docs/objects.json +++ b/docs/objects.json @@ -161,7 +161,7 @@ "enabled": [], "writable": [], "accepted": ["Enable", "Stop_When_Full", "Buffer_Size", "Log_Buffer", "Record_Count", "Total_Record_Count", "Logging_Type", "Event_State"], - "note": "T-VMT-I-B / T-ATR-B. Enable, Stop_When_Full, Buffer_Size, Log_Buffer, Record_Count, Total_Record_Count and Logging_Type are NOT stack defaults - they are genuinely held and served by the stack's Trend Log engine (BACnetStack_AddTrendLogObject + SetTrendLogTypeToPolled + SetTrendLogStartStopTime), marked accepted only because property-profile-reference.md's generic table does not know about this host-configuration API. Polls Analog Input 1 (Bronze) Present_Value every second. Log_Buffer is readable only via ReadRange (a plain ReadProperty is rejected with Error(OBJECT, READ_ACCESS_DENIED) - verified live); ReadRange itself was verified live against Trend Log Multiple 1 (Magenta), not this object - see the note there and TODO.md item 1. KNOWN GAP: calling SetTrendLogStartStopTime on this object reproducibly leaves Record_Count at 0 forever regardless of the values passed (filed as cas-bacnet-stack#2051); this object therefore demonstrates the SetTrendLogStartStopTime call's correct usage but will read Record_Count=0 in a live demo. Also KNOWN: BACnetStack_AddTrendLogObject alone causes a continuous non-fatal internal log flood (cas-bacnet-stack#2050, same class as B-ACC's #2045 for Event Log) - device functionality is unaffected" + "note": "T-VMT-I-B / T-ATR-B. Enable, Stop_When_Full, Buffer_Size, Log_Buffer, Record_Count, Total_Record_Count and Logging_Type are NOT stack defaults - they are genuinely held and served by the stack's Trend Log engine (BACnetStack_AddTrendLogObject + SetTrendLogTypeToPolled + SetTrendLogStartStopTime), marked accepted only because property-profile-reference.md's generic table does not know about this host-configuration API. Polls Analog Input 1 (Bronze) Present_Value every second. Log_Buffer is readable only via ReadRange (a plain ReadProperty is rejected with Error(OBJECT, READ_ACCESS_DENIED) - verified live). Record_Count climbs correctly (fixed cas-bacnet-stack#2051 - the Start_Time/Stop_Time window is now built from the same clock, UTC via gmtime, that the stack itself compares against, not local wall-clock) - live-verified: Record_Count climbed from 14 to 44 over 30 seconds. Also KNOWN: BACnetStack_AddTrendLogObject alone causes a continuous non-fatal internal log flood (cas-bacnet-stack#2050, same class as B-ACC's #2045 for Event Log) - device functionality is unaffected" }, { "type": "Trend Log Multiple", @@ -171,7 +171,7 @@ "enabled": [], "writable": [], "accepted": ["Enable", "Event_State"], - "note": "T-VMT-I-B / T-ATR-B. Enable is NOT a stack default - it is genuinely held and served by the stack's Trend Log Multiple engine (BACnetStack_AddTrendLogMultipleObject + AddLoggedObjectToTrendLogMultiple x3 + SetTrendLogTypeToPolled), marked accepted only because property-profile-reference.md's generic table does not know about this host-configuration API. Polls three points every second: Analog Input 1 (Bronze), Analog Value 1 (Diamond) and Analog Output 1 (Chartreuse) Present_Value. THIS is the example's working, live-verified polled-logging + ReadRange demonstration (unlike Lilac - see TODO.md item 1): Record_Count climbed from 0 to 150+ across several live runs, and ReadRange (RangeByPosition, first=1, count=5) returned real LogMultipleRecord entries. Also affected by the same AddTrendLogObject-family log-flood as Lilac (cas-bacnet-stack#2050) - non-fatal" + "note": "T-VMT-I-B / T-ATR-B. Enable is NOT a stack default - it is genuinely held and served by the stack's Trend Log Multiple engine (BACnetStack_AddTrendLogMultipleObject + AddLoggedObjectToTrendLogMultiple x3 + SetTrendLogTypeToPolled), marked accepted only because property-profile-reference.md's generic table does not know about this host-configuration API. Polls three points every second: Analog Input 1 (Bronze), Analog Value 1 (Diamond) and Analog Output 1 (Chartreuse) Present_Value. This is the example's working, live-verified polled-logging + ReadRange demonstration: Record_Count climbed from 0 to 150+ across several live runs, and ReadRange (RangeByPosition, first=1, count=5) returned real LogMultipleRecord entries. Also affected by the same AddTrendLogObject-family log-flood as Lilac (cas-bacnet-stack#2050) - non-fatal" } ] } diff --git a/main.cpp b/main.cpp index b80393b..69c0663 100644 --- a/main.cpp +++ b/main.cpp @@ -1985,27 +1985,29 @@ int main(int argc, char** argv) { // Record_Count from ever incrementing, live-verified with bacpypes3, even // with valid past Start_Time/future Stop_Time values and Enable=true - this // ordering avoids that.) - // KNOWN GAP (chipkin/cas-bacnet-stack#2051, filed this session): calling - // BACnetStack_SetTrendLogStartStopTime on a Trend Log object - with ANY - // values (unspecified, or a concrete past Start_Time/future Stop_Time that - // genuinely bracket "now"), in EITHER order relative to - // SetTrendLogTypeToPolled - reproducibly leaves Record_Count at 0 forever, - // confirmed live over the wire. The call itself, its documented arguments, - // and its wiring here are all correct customer-facing API usage; Start_Time - // and Stop_Time DO read back exactly as set. See TODO.md. Trend Log - // Multiple 1 (Magenta) below, which never calls this function, IS the - // working polled-accumulation + ReadRange demonstration for this example. + // #2051 (chipkin/cas-bacnet-stack#2051, fixed): this window used to be built + // with localtime_s/localtime_r, but HelperGetSystemTime() (common/CASExample + // Helper.cpp) returns raw time(0) and this example serves no Device + // UTC_Offset, so the stack's own "now" (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 was offset from 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. Building the window from the SAME clock the stack uses + // (gmtime, not localtime) fixes it - Start_Time/Stop_Time now genuinely + // bracket the stack's own "now" on every host regardless of local time zone. { time_t nowSeconds = time(NULL); struct tm nowTmBuf; struct tm stopTmBuf; time_t stopSeconds = nowSeconds + 600; // 10 minutes #if defined(_WIN32) - localtime_s(&nowTmBuf, &nowSeconds); - localtime_s(&stopTmBuf, &stopSeconds); + gmtime_s(&nowTmBuf, &nowSeconds); + gmtime_s(&stopTmBuf, &stopSeconds); #else - localtime_r(&nowSeconds, &nowTmBuf); - localtime_r(&stopSeconds, &stopTmBuf); + gmtime_r(&nowSeconds, &nowTmBuf); + gmtime_r(&stopSeconds, &stopTmBuf); #endif if (!BACnetStack_SetTrendLogStartStopTime( g_deviceInstance, OBJECT_TYPE_TREND_LOG, TREND_LOG_INSTANCE,