Repository navigation
B-ASC example: adopt the CAS BACnet Stack C++ adapter (v6), verify all three link modes, and correct the docs - #3
Merged
Merged
Conversation
Pin the stack submodule to 6.x-TestTool 92c91d74 (Sprint 261 P1-P5 public-interface review). v6 removed BACnetStack_AddNetworkPortObject; migrated to BACnetStack_AddNetworkPortObjectWithNetworkNumber, passing networkNumber 0 + NETWORK_NUMBER_QUALITY_UNKNOWN, which reproduce the old behaviour (a local port that has not been configured with, or learned, a network number). Added the BACnetNetworkNumberQuality constants (cl. 12.56.11) to the example constants header. Builds clean against the pinned stack. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…D re-sync) Vendoring sweep. common/ must be identical in every example of the series, so this lands the v1.4.0 helper here even though this profile does not use it: - Adds RequestRestart()/RestartDue(), the deferred-restart pattern for ReinitializeDevice (DM-RD-B). Inert unless an example calls it; only B-AAC does, since it is the only profile in the series with DM-RD-B. - Re-syncs CASBACnetStackExampleConstants.h in B-OD, which had silently gone stale: it never received the NETWORK_NUMBER_QUALITY_* constants from the 2026-07-17 item-16 migration because B-OD was the one example that did not itself need the migrated AddNetworkPortObjectWithNetworkNumber call. Nothing failed to compile there, so the folder's byte-identical guarantee broke silently. (No-op in the other six repos, which were already current.) Verified: content-identical across all 8 repos; B-AAC and B-OD both build. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
38 commits ahead of the previous pin (92c91d74). Breaking API changes in range (RegisterHookProperty* removal, DecodeAs fold, SetCOVMultipleSettings rename, SetBackupAndRestoreEnabled signature, SetObjectTypeSupported removal) verified unused by this example. Rebuilt Release, smoke-tested: binds, broadcasts I-Am, device ready. One-time cosmetic BACnetSC 'UUID has not been set' debug-log line at startup is new stack behavior, noted in CHANGELOG. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…lobbing stack source CMakeLists.txt now add_subdirectory()s submodules/cas-bacnet-stack/adapters/cpp and links CASBACnetStack::Adapter, instead of file(GLOB)-ing every source/*.cpp itself. CAS_BACNET_STACK_LINK (SOURCE default, or STATIC/DLL - set before configure) now switches link modes without touching this file. TEMPORARY submodule pin: submodules/cas-bacnet-stack now points at the tip of the adapter-cpp-package branch (stacked on adapter-cpp-generate), not yet merged into 6.x-TestTool - see cas-bacnet-stack PRs #267 and #268. Re-pin to 6.x-TestTool once both merge. main.cpp/common/ still include CASBACnetStackDLL.h directly and call BACnetStack_* unchanged (SOURCE mode exposes the same declarations via the adapter's transitive include dirs) - the include-swap + LoadBACnetFunctions() adoption is the next commit. Verified: fresh MSVC Release build, clean; smoke-run on --port 47899 identical to pre-migration (binds, broadcasts I-Am, "Device 389003 (Rainbow) ready"). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…apter.h main.cpp and common/CASExampleHelper.cpp now include CASBACnetStackAdapter.h instead of CASBACnetStackDLL.h directly. All BACnetStack_* call sites are UNCHANGED (34 in main.cpp, ~8 in common/) - the adapter exposes the exact same names in every link mode, so this is purely an include swap plus one new call: LoadBACnetFunctions() now runs as the very first thing in main(), before even --help/--version (PrintVersion calls BACnetStack_GetAPIMajorVersion() etc., so skipping the load step there would be a null-pointer call in DLL mode). common/ -> v1.5.0 (CHANGELOG entry): this is a contract change for every example in the series that vendors common/, not just B-ASC - each needs the same LoadBACnetFunctions() call added to its main() when it re-syncs (Stage D, out of scope here). Verified: clean incremental MSVC rebuild; smoke-run identical to before (binds, broadcasts I-Am, "Device 389003 (Rainbow) ready", RX 21 bytes from a real LAN device - proving the adapter-mediated send/receive path both directions); --version path also verified (exercises the pre-HandleHelpAndVersionArgs LoadBACnetFunctions() placement specifically). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
README gets a new "Link modes" section under Build (SOURCE/STATIC/DLL, CAS_BACNET_STACK_LINK cache var). CHANGELOG entry summarizes the CMake-target migration across all 3 stages. DLL-mode verification results (built the stack DLL via submodules/cas-bacnet-stack/projects/msvs/BuildCASBACnetStack.sln, ReleaseDll|x64, /p:PlatformToolset=v143 override - v145 isn't installed): - FAILURE PATHS VERIFIED: DLL entirely absent -> clean "could not load the DLL" error, exit 1, no crash. DLL present but missing a required export -> clean "missing export: BACnetStack_X" error naming the exact symbol, exit 1, no crash. Both prove CASBACnetStackAdapter_LastError() and the all-or-nothing binding contract work correctly against a real DLL. - SUCCESS PATH NOT ACHIEVED: the built DLL is missing 3 of 213 declared exports (BACnetStack_RegisterCallbackWriteGroupInhibitDelay, SendWhoAmI, SendYouAre) for reasons not fully root-caused (ruled out incremental-build staleness via a from-scratch clean rebuild; ruled out a source-level #ifdef miss for 2 of the 3, which are unguarded in source). Root-cause + fix is a stack-repo follow-up (task chip spawned) - two leads documented: the STACK_OPTION_TARGET_FULL preset not cascading to STACK_OPTION_WRITE_GROUP, and a possible LTCG/OPT:ICF interaction with __declspec(dllexport) for the unguarded pair. SOURCE and STATIC mode are unaffected (real function linkage, not runtime symbol lookup) and are fully verified end-to-end (Stage C1/C2 commits). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Submodule pin -> c22ac0ab, which carries the stack-side fix for the three exports that were silently missing from every DLL build (option guards in CASBACnetStackDLL.h evaluated before any options header was in scope). With that fixed, DLL mode's SUCCESS path works for the first time: the example loads the library, binds all 213 exports, passes the version handshake, and runs - verified on port 47900. Both failure paths still degrade cleanly (library absent -> "could not load ..."; wrong build -> "missing export: ..."). README's Link modes section rewritten accordingly, including the CWD-relative library-lookup caveat and the BACNET_LIB_FILE override. Documentation corrections from the five-persona review: - Version banner and sample output said common/ v1.3.0 against a v1.5.0 tree - the exact drift the README teaches readers to detect. Now accurate, with a "trust the program" note. - Defined at first use: the BIBB -A/-B (client/server side) convention, Protocol_Revision, BACnet/SC, "BACnet internetwork", and a concrete what-is-a-B-ASC anchor (thermostat / VAV / fan-coil). - Verify section now names free clients (YABE, Wireshark) next to the commercial one, so evaluating costs nothing. - Reading order no longer implies you must start at another repository. - New: "What to copy, what to rewrite" - which parts of common/ are demo-only (per-packet printf, keyboard loop, first-adapter IP guess) versus worth keeping. - New: "Calling BACnetStack_Tick() in a real product" - cadence, and the single-threaded contract (the stack contains no locking of any kind; callbacks run synchronously on the calling thread). Verified: SOURCE mode rebuilt + smoke-run (binds, I-Am, RX from a live device); DLL mode built, run, and both failure paths exercised. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
common/ 1.5.1: - --help printed the version banner twice (the handler printed it, then PrintHelp printed it again). Split the interactive key list into its own helper; --help now prints banner / usage / keys once each. - common/README.md was STALE in the way that matters most: it still said the stack "is compiled from source... there is no DLL to load at runtime", and its "How main.cpp uses it" skeleton - presented as a starting point to copy - omitted LoadBACnetFunctions(), which 1.5.0 had just made mandatory in every link mode. Copying it produced exactly the bug 1.5.0 exists to prevent (a null-pointer call in DLL mode). This was a regression from this arc's own work: CASExampleHelper.h/.cpp were updated and the folder's README was not. README corrections (all reported by the review panel, each verified first): - Troubleshooting named a CMake error string that no longer exists - CMake now says "CAS BACnet Stack adapter not found under:", so searching the README for the real message found nothing. Added the STATIC-mode configure error too. - A troubleshooting row blamed SO_REUSEADDR for duplicate-device symptoms; common/SimpleUDP.cpp deliberately asks for SO_EXCLUSIVEADDRUSE on Windows so that case fails loudly at bind instead. Rewritten per-platform. - New troubleshooting row for the most likely silent failure on a dev laptop: the example picks the first non-loopback adapter, which with Hyper-V/WSL/ VirtualBox/VPN is often not the real NIC, so the device looks healthy and no client ever sees it. Says to check the IP in the TX line. - Expected-output block listed the red Error line before "Device ready"; the real order is TX -> ready -> RX -> Error. Corrected, and noted that those lines are traffic-dependent. - Added --parallel to the build instructions (the ~600-file first build is the single largest time cost, and matters most when running a class through it). - Version banner in the sample output refreshed to common/ 1.5.1. Verified: rebuilt, --help prints one banner, smoke-run on --port 47899 shows the documented startup sequence with the banner matching the README. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Submodule -> 9f95ff2a (STATIC-mode MSVC runtime fix). STATIC previously configured but could not link - the prebuilt library is built /MT and consumers default to /MD, giving 562 LNK2038 errors that read like a corrupt library. README now documents the ReleaseLib build step, the automatic library lookup (and CAS_BACNET_STACK_LIB override), and the /MT forcing. The 'all three modes verified' claim is now actually earned: SOURCE, STATIC and DLL were each built AND run, with STATIC confirmed to need no DLL beside the executable. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…apshot A customer opening main.cpp for the first time has no interest in what a previous version of the file said. Several comments narrated this repo's own review history at the reader, which undermines confidence in the thing they are reading rather than building it. Removed the self-referential framing while keeping every technical claim: - 'the most important paragraph in the file, because an earlier version of this comment got it backwards' -> states the same warning directly. - 'HONEST NOTE, because an earlier version of this comment was wrong and a reader would have found out the hard way' -> 'WORTH KNOWING BEFORE YOU COPY THIS'. - 'This example shipped exactly that bug; it was caught by a reviewer tracing the stack source' -> explains the failure is invisible in code review, which is the part a reader can act on. - 'Trust the code, not the comment - including this one: go read it' -> cut; a comment telling you not to trust comments is not guidance. - 'this loop used to hardcode a literal 1' -> says what to do and why, without the archaeology. - 'v6: the old AddNetworkPortObject was removed' -> describes what the current arguments mean; migration notes belong in the stack's own changelog. Comment-only: shows no non-comment line changed. Rebuilt and smoke-tested to confirm identical behaviour. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
main.cpp cited stack source files by name (BACnetBusinessLogic.cpp, BACnetDBDevice.cpp, BACnetDBPropertyProfile.cpp) and internal symbols (valueShouldBeInitialized, IsPropertyCommandable, IsPropertyEnabled, GetDefaultPropertyValue) as evidence for its claims. Those are ~600 files of someone else's code that a first-time reader cannot usefully open, and citing them invites the reader to go verify rather than to trust and move on. Every claim is kept, stated as observable behaviour of the API instead: 'the stack substitutes a default for these properties', 'the stack treats Present_Value as commandable unconditionally on output types', 'the stack checks whether the property is enabled before reaching the callbacks'. What the reader can act on is unchanged; the archaeology is gone. Comment-only: shows no non-comment line changed. Rebuilt and smoke-tested. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Release artifacts are built with CAS_BACNET_STACK_LINK=SOURCE, now stated explicitly rather than relying on it being the CMake default - what we publish must not change if that default ever moves. Added a step that reads the value back out of CMakeCache.txt and fails the build if it is not SOURCE. Why SOURCE for a published binary: the artifact is a single self-contained executable. STATIC would need a prebuilt library matched here first, and DLL would require shipping CASBACnetStack_x64_Release.dll alongside and would fail at start-up for anyone who downloaded only the exe. Those modes are for integrators choosing them deliberately in their own build. The cache assertion anchors its grep as '^CAS_BACNET_STACK_LINK:' - without the colon it also matches the CAS_BACNET_STACK_LINK-STRINGS:INTERNAL helper entry, and the comparison silently never matches. Verified against a real CMakeCache.txt both ways before committing. Also: README version banner said common/ v1.5.0 while the code ships v1.5.1 - the same doc/code drift the review panel flagged, reintroduced by my own 1.5.1 bump. Fixed. Submodule -> f9e65559 (licence verbiage + debug-limit comment). Rebuilt and smoke-tested: banner now matches the binary's output. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
PRs #267 and #268 are merged, so the pin moves off the adapter-cpp-package
branch tip and onto 6.x-TestTool, retiring the TEMPORARY note in the CHANGELOG.
Verified the adapter content is byte-identical to the branch-tip pin it
replaces (diff over adapters/cpp + CASBACnetStackDLL.{h,cpp} is empty), so this
is a provenance change, not a code change. Also corrects the common/ version
reference in that entry to 1.5.1.
Rebuilt and smoke-tested on the merged pin.
Co-Authored-By: Claude Opus 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.
Brings the B-ASC example onto CAS BACnet Stack v6 and its new C++ adapter, verifies every
supported link mode by actually running the binary, and fixes a batch of documentation defects
found by a five-persona review. The stack submodule moves
863a090e→756371c1(
6.x-TestTool, containing cas-bacnet-stack PRs #267 and #268).Squash note: this branch also carries two earlier commits by @funvill that predate the adapter
work — the v6 / Network Port migration and the
common/v1.4.0 sync (deferred restart, B-ODre-sync). They are included here and described below.
What changed
1. Links the stack through
CASBACnetStack::Adapterinstead of hand-globbing its sourceCMakeLists.txtnowadd_subdirectory()s the stack'sadapters/cppand links one target,replacing the
file(GLOB)over ~600source/*.cppthat every example in the series repeats.CAS_BACNET_STACK_LINKselects how the stack is linked —SOURCE(default; compiles in,self-contained binary),
STATIC(prebuilt.lib/.a), orDLL(loaded at runtime).Switching is a CMake flag, not a code change.
2. Application code is unchanged — that is the point
main.cppandcommon/still callBACnetStack_AddDevice(...)and friends by the exact exportname. The adapter exposes the same names in all three modes (in DLL mode they are same-named
function-pointer variables bound at load). The only new requirement is one call:
It is the first statement in
main()— before--help/--version, because printing theversion calls into the stack. Mandatory in every mode: in DLL mode it binds the symbols, and in
all modes it runs a stack-version handshake.
3. All three link modes verified — built and run, not just configured
STATIC needed a real fix to get there: the prebuilt library is built
/MTwhile CMake defaultsconsumers to
/MD, which produced 562LNK2038errors that read like a corrupt library. Theadapter now forces the matching runtime (fixed upstream in #268).
4. Release CI pins the published link mode explicitly
release.ymlpasses-DCAS_BACNET_STACK_LINK=SOURCErather than relying on the CMake default,and asserts it back out of
CMakeCache.txt. A published artifact must stay a singleself-contained executable even if that default ever moves; DLL mode would fail at start-up for
anyone who downloaded only the exe.
5. Documentation corrections (five-persona review, two rounds)
Reviewed as a lead developer, an educator, a junior integrator, a BACnet newcomer, and a staff
architect; average score 7.6 → 8.0 across rounds. Fixed here:
common/v1.3.0 against a newer tree, in a projectwhose own docs teach "the printed versions are how you detect drift". Now matches the binary.
-A/-B(initiator/responder) convention,Protocol_Revision, BACnet/SC, "BACnet internetwork", and a concrete answer to what a B-ASCdevice actually is (thermostat, VAV box, fan-coil controller).
evaluating the example costs nothing.
(a reader pastes the real message into ctrl-F and finds nothing); another blamed
SO_REUSEADDRwhere the code asks forSO_EXCLUSIVEADDRUSEon Windows. Added a row for themost likely silent failure on a dev laptop: the example picks the first non-loopback adapter,
which with Hyper-V/WSL/VPN is often not the real NIC, so the device looks healthy and no
client ever sees it.
common/is demo-only vs production-worthy (per-packetprintf, the keyboard loop, the IP guess), and theBACnetStack_Tick()contract: callregularly, callbacks run synchronously on the calling thread, and the stack contains no
locking of any kind, so drive it from exactly one thread.
common/README.mdno longer teaches a broken skeleton — its copyablemain()omitted thenow-mandatory
LoadBACnetFunctions(), which in DLL mode is a null-pointer call.the file ("an earlier version of this comment got it backwards", "this example shipped exactly
that bug", "trust the code, not the comment"), and citations into stack internals
(
BACnetBusinessLogic.cpp,IsPropertyCommandable()) that a first-time reader cannot usefullyopen. Every technical claim is kept, restated as observable API behaviour.
6. Included from earlier on this branch (not part of the adapter work)
AddNetworkPortObjectWithNetworkNumber, plus theconstants it needs.
common/v1.4.0 — the deferred-restart helper for DM-RD-B (never restart inside theReinitializeDevicecallback; the SimpleACK does not reach the wire until a laterTick()),and a B-OD re-sync.
common/ends this branch at v1.5.1.Verification
--help/--versionchecked (they run before the socket binds, and--helpno longer printsthe version banner twice).
drift + export-coverage gates, doc-lint.
Reviewer notes
common/is vendored into all eight examples in the series. It ends at v1.5.1 here andthe
LoadBACnetFunctions()requirement is a contract change: every other example needs thesame call added to its
main()when it re-syncs. That propagation is deliberately not inthis PR — one example at a time.
docs/runbook-bacnet-profile.md(§3a), for the other seven profiles and for new-language ports.🤖 Generated with Claude Code