-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Helpfully the libmbus test data has two files with error state BCDs so I had to spend a while trying to understand the unhelpfully vague EN 13757-3:2018 Annex B and the ultimately entirely incorrect behaviour introduced to `libmbus` in a series of commits several years ago. The understanding I have come to is that it's still a normal BCD number, but some elements have been replaced with hexadecimal symbols to indicate particular parts are now errors. What do those errors mean? Completely unspecified! I have decided to return this as an uppercase hex string, taking negatives into account. Converting this as per Table B.1 for use on a 7 segment display is left as an exercise to the reader. Unfortunately, the way libmbus handles this is twofold. 1. If the data function is "value during error state" and you are generating the standard XML output, it parses it into a pure hex string, ignoring the rules regarding negative numbers 2. Otherwise, for each pair of nibbles the first one is discarded if it is over 0xA unless it's the last one, in which case it negates the entire number. This means that an input of 0xFFFF is interpreted as -0x0F0F, The second nibbles are then added without any clamping at all, resulting in -1616. 0x1F would be 17. This is suboptimal. This is specifically unfortunate for me because I want to be start testing my output against their test output and that means I am going to have to *implement* both of these behaviours for my compatability layer.
- Loading branch information
1 parent
2e9d582
commit d32b780
Showing
3 changed files
with
135 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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