Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
50 changes: 6 additions & 44 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()`.
Expand Down Expand Up @@ -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 =
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
36 changes: 10 additions & 26 deletions TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
|---|---|---|
Expand All @@ -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`)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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. |
Expand Down
Loading
Loading