Skip to content

register printing#10

Open
jktjkt wants to merge 4 commits intogertvdijk:developfrom
jktjkt:wip/register-printing
Open

register printing#10
jktjkt wants to merge 4 commits intogertvdijk:developfrom
jktjkt:wip/register-printing

Conversation

@jktjkt
Copy link
Copy Markdown
Contributor

@jktjkt jktjkt commented Apr 21, 2026

For my KMP log exporter, I need a reusable way of printing these registers outside of the main CLI. This PR first moves code around to make this reusable and testable, then it adds some basic tests, and then it adds support for working with non-decimal string representation.

Please see the individual commits for motivation/explanation. Maybe stacked PRs will make this doable in an easier way...

@jktjkt jktjkt force-pushed the wip/register-printing branch from f6620a1 to 276de10 Compare April 21, 2026 23:19
jktjkt added 2 commits April 22, 2026 12:12
Code which converts KMP-spcific binary representation to native Python
types is useful on its own.
The KMP protocol implements a few different date/time formats. Instead
of showing raw numbers, let's show a nice, properly formatted date.

I do not feel like changing the RegisterOutput to support many native
Python types, IMHO it's perfectly OK to stick with numbers (which will
be typically fed to a time series DB or something similar) and
"everything else", but let's print that "everything else" properly.

I'm not 100% sure how to handle the `yy-mm-dd` format. I *think* that
it's rather uncommon to see meters with 26+ years old data record today,
which is why I decided to hardcode the year-2000 prefix. A non-public
document mentions '99:12:31' as an example, though.

Also, a proper y/m/d separator is definitely `-`, not `:`, so I'm using
that for clarity.
@jktjkt jktjkt force-pushed the wip/register-printing branch from 07245d6 to 8bdd63f Compare April 22, 2026 10:12
jktjkt added 2 commits April 22, 2026 12:15
The new year's eve of 2024 is from a real-world meter data, the other
test is from a KMP document (adjusted for the "number of bytes" and
"size and exponent" bytes).
Verified by a meter type ID of my new hot water meter; it matches the
laser print on the meter's face.
@jktjkt jktjkt force-pushed the wip/register-printing branch from 8bdd63f to a8dec38 Compare April 22, 2026 10:16
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