Skip to content

Ignore Mbus short frames when parsing HDLC transmission#19

Merged
PolarGoose merged 1 commit into
mainfrom
ignore_mbus_short_frames_in_hdlc_parser
Jul 16, 2026
Merged

Ignore Mbus short frames when parsing HDLC transmission#19
PolarGoose merged 1 commit into
mainfrom
ignore_mbus_short_frames_in_hdlc_parser

Conversation

@PolarGoose

@PolarGoose PolarGoose commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

The log provided by @TheNetStriker here shows that the Landis+Gyr E450 smart meter sends Mbus short frames while transmitting HDLC packets

Lone Mbus packet without any HDLC packets:

2026-07-14T09:57:59.916Z gplugm01/debug [0;37m[V][dlms_meter:157]: Processing frame of size: 5 bytes
2026-07-14T09:57:59.961Z gplugm01/debug [0;38m[VV][dlms_meter:030]: Buffer content:
2026-07-14T09:57:59.961Z gplugm01/debug [0;38m[VV][dlms_meter:030]: 1040014116
2026-07-14T09:57:59.961Z gplugm01/debug [0;38m[VV][dlms_meter:030]: ============
2026-07-14T09:57:59.961Z gplugm01/debug [0;37m[V][dlms_meter:027]: Skipping M-Bus short frame prefix

Mbus short packet 107B017C16 in between the end of HDLC transmission. It later causes an error because the last HDLC packet comes after more than a second and is treated as a separate transmission (it is another issue that we need to address):

2026-07-14T09:58:13.782Z gplugm01/debug [0;37m[V][dlms_meter:157]: Processing frame of size: 657 bytes
2026-07-14T09:58:13.810Z gplugm01/debug [0;38m[VV][dlms_meter:030]: Buffer content:
2026-07-14T09:58:13.811Z gplugm01/debug [0;38m[VV][dlms_meter:030]: 7EA084CEFF0313128BE6E700E04000010000700F005A35950C07EA070E020B3A0AFF800000021C011C020412002809060008190900FF0F021200000204120001090600002A0000FF0F02120000020412000309060101010800FF0F021200000204120003
2026-07-14T09:58:13.811Z gplugm01/debug [0;38m[VV][dlms_meter:030]: 09060101020800FF0F02120000020412000309060101030800FF0F02120000EE6C7E7EA07DCEFF0313D045E040000200006C020412000309060101040800FF0F02120000020412000109060000600E00FF0F02120000020412000309060100010700FF0F
2026-07-14T09:58:13.811Z gplugm01/debug [0;38m[VV][dlms_meter:030]: 02120000020412000309060100020700FF0F02120000020412000309060100200700FF0F02120000020412000309060100340700FF0F02120000FEF57E7EA07DCEFF0313D045E040000300006C020412000309060100480700FF0F021200000204120003
2026-07-14T09:58:13.811Z gplugm01/debug [0;38m[VV][dlms_meter:030]: 090601001F0700FF0F02120000020412000309060100330700FF0F02120000020412000309060100470700FF0F02120000020412000309060100150700FF0F02120000020412000309060100290700FF0F02120000FB657E7EA07DCEFF0313D045E04000
2026-07-14T09:58:13.811Z gplugm01/debug [0;38m[VV][dlms_meter:030]: 0400006C0204120003090601003D0700FF0F02120000020412000309060100160700FF0F021200000204120003090601002A0700FF0F021200000204120003090601003E0700FF0F02120000020412000309060100170700FF0F02120000020412000309
2026-07-14T09:58:13.812Z gplugm01/debug [0;38m[VV][dlms_meter:030]: 0601002B0700FF0F02120000C8FF7E7EA087CEFF0313DE96E04000050000760204120003090601003F0700FF0F02120000020412000309060100180700FF0F021200000204120003090601002C0700FF0F02120000020412000309060100400700FF0F02
2026-07-14T09:58:13.865Z gplugm01/debug [0;38m[VV][dlms_meter:030]: 120000020412000109060000600D00FF0F0212000009104C475A31303330363636303038323132060081684406008E0E2646B57E107B017C16
2026-07-14T09:58:13.865Z gplugm01/debug [0;38m[VV][dlms_meter:030]: ============

This pull request makes the HDLC parser ignore MBus short packets.

Copilot AI review requested due to automatic review settings July 16, 2026 11:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the HDLC decoding path to tolerate valid M-Bus short frames interleaved within an HDLC transmission, moving the “skip M-Bus short frame” logic into the HDLC decoder and adjusting tests accordingly.

Changes:

  • Add M-Bus short frame detection/skipping to decode_hdlc_frames_in_place().
  • Update HDLC decoder tests to cover skipping short frames and invalid-checksum behavior.
  • Remove the older integration test case that prepended an M-Bus short frame to an Iskra 550 dump, and update parser routing for 0x10.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_meter_dumps.cpp Removes the integration subcase that included an M-Bus short frame prefix.
tests/test_hdlc_decoder.cpp Adds unit tests asserting M-Bus short frames are skipped (and invalid ones are not).
src/dlms_parser/hdlc_decoder.h Updates public header documentation for HDLC in-place decode behavior.
src/dlms_parser/hdlc_decoder.cpp Implements M-Bus short frame detection and skipping in the HDLC decoder loop.
src/dlms_parser/dlms_parser.cpp Removes parser-level short-frame stripping and routes 0x10 buffers into HDLC decoding.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/dlms_parser/dlms_parser.cpp
Comment thread src/dlms_parser/hdlc_decoder.h
@PolarGoose
PolarGoose force-pushed the ignore_mbus_short_frames_in_hdlc_parser branch 2 times, most recently from 58e0d75 to 7708da9 Compare July 16, 2026 12:09
@PolarGoose
PolarGoose requested a review from Copilot July 16, 2026 12:09
@PolarGoose
PolarGoose force-pushed the ignore_mbus_short_frames_in_hdlc_parser branch from 7708da9 to 88d93b6 Compare July 16, 2026 12:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread src/dlms_parser/hdlc_decoder.cpp Outdated
@PolarGoose
PolarGoose force-pushed the ignore_mbus_short_frames_in_hdlc_parser branch from 88d93b6 to c7cef02 Compare July 16, 2026 12:40
@PolarGoose
PolarGoose force-pushed the ignore_mbus_short_frames_in_hdlc_parser branch from c7cef02 to 3053cbe Compare July 16, 2026 12:40
@PolarGoose
PolarGoose requested a review from Copilot July 16, 2026 12:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@PolarGoose
PolarGoose merged commit 1c643b5 into main Jul 16, 2026
8 checks passed
@PolarGoose
PolarGoose deleted the ignore_mbus_short_frames_in_hdlc_parser branch July 16, 2026 12:47
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.

2 participants