Skip to content

fix: intrinsic alarm crash in the storage example (the "Hmm?" exception)#194

Merged
gralin merged 1 commit into
masterfrom
fix-event-notification-crash
Jul 3, 2026
Merged

fix: intrinsic alarm crash in the storage example (the "Hmm?" exception)#194
gralin merged 1 commit into
masterfrom
fix-event-notification-crash

Conversation

@gralin

@gralin gralin commented Jul 3, 2026

Copy link
Copy Markdown
Member

Discovered while running AnotherStorageImplementation and clicking the device in YABE: as soon as an object's intrinsic limit alarm fired, the device crashed with:

System.Exception: Hmm?
  at System.IO.BACnet.Serialize.Services.EncodeEventNotifyData(...) Services.cs:1224
  ...
  at BaCSharp.NotificationClass...SendIntrinsectEvent...

Root causes

  1. CoreEncodeEventNotifyData had a leftover placeholder throw new Exception("Hmm?") in the EVENT_CHANGE_OF_VALUE default branch. Replaced with a meaningful NotImplementedException (matching the sibling switch one level up).
  2. ExampleAnalogObjectEvent reported analog high/low-limit alarms as EVENT_CHANGE_OF_VALUE with no payload, which the encoder can't serialize. It now sends EVENT_OUT_OF_RANGE with the proper payload (exceeding value, status flags, deadband, exceeded limit) — the correct BACnet event for an analog limit alarm.
  3. Example robustness — the notification is sent on a thread-pool thread; an unhandled exception there took down the whole device process. Wrapped it in try/catch so a failed send is logged instead.

Verified

  • Core + example build; 119 tests pass.
  • EVENT_OUT_OF_RANGE with payload now encodes cleanly; an unset CHANGE_OF_VALUE throws the new meaningful NotImplementedException instead of "Hmm?".

Result: clicking the device in YABE now shows a proper Out-Of-Range alarm instead of crashing.

Clicking the AnotherStorageImplementation device in YABE raised System.Exception "Hmm?"
from the core event-notification encoder. Root causes:

- Core: EncodeEventNotifyData threw a placeholder new Exception("Hmm?") in the
  EVENT_CHANGE_OF_VALUE default branch. Replace it with a meaningful NotImplementedException.
- Example: AnalogObjectEvent reported analog high/low-limit alarms as EVENT_CHANGE_OF_VALUE
  with no payload, which the encoder can't serialize. Send EVENT_OUT_OF_RANGE with the
  proper payload (exceeding value, status flags, deadband, exceeded limit) - the correct
  BACnet event for an analog limit alarm.
- Example: guard the thread-pool notification send with try/catch so a failed send logs
  instead of taking down the device process.
@gralin gralin merged commit 31c1f98 into master Jul 3, 2026
4 checks passed
@gralin gralin deleted the fix-event-notification-crash branch July 3, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant