rscada / libmbus

Meter-bus library and utility programs
http://www.rscada.se/libmbus
BSD 3-Clause "New" or "Revised" License
217 stars 137 forks source link

Also generate normalized XML #168

Closed lategoodbye closed 3 years ago

lategoodbye commented 4 years ago

In order to increase the test coverage also generate the normalized version of XML output.

lategoodbye commented 4 years ago

I pushed a new version

fredrik-sk commented 4 years ago

Hello

We can definetly handle this as a new issue. I want to point out what I have seen, and what my opinions are.

I didn't notice this until I rebased my work onto your PR and ran the tests. There is some file that gives some output

When looking at the tests of this PR, https://github.com/rscada/libmbus/pull/168/checks?check_run_id=816071416

Lines 12-14 of the step "generate test frames" is new. There is no indication what file is causing this. (The level above probably just ignores it.)

mbus_vif_unit_normalize: Unknown VIF 0x07B
mbus_vib_unit_normalize: Error mbus_vif_unit_normalize
mbus_parse_variable_record: problem with mbus_vib_unit_normalize

Locally, I added this command echo "*** "$hexfile at the loop at the end of generate-xml.sh.

It indicated:

*** test/test-frames/sen_pollutherm.hex

Looking at the diff, indicates that datarecord with id=2 is completly empty in the normalized file. The contents in the record with id=9, is how the normalized xml should look?

diff -u sen_pollutherm.xml sen_pollutherm.norm.xml | less

     <DataRecord id="1">
         <Function>Instantaneous value</Function>
         <StorageNumber>0</StorageNumber>
-        <Unit>Volume (1e-2  m^3)</Unit>
-        <Value>799892</Value>
+        <Unit>m^3</Unit>
+        <Quantity>Volume</Quantity>
+        <Value>7998.920000</Value>
     </DataRecord>

     <DataRecord id="2">
-        <Function>Instantaneous value</Function>
-        <StorageNumber>0</StorageNumber>
-        <Unit>Unknown (VIF=0x7B)</Unit>
-        <Value>302</Value>
     </DataRecord>
...
     <DataRecord id="9">
         <Function>More records follow</Function>
+        <StorageNumber>0</StorageNumber>
+        <Unit></Unit>
+        <Quantity></Quantity>
         <Value></Value>
     </DataRecord>

I would suggest two actions from this.