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

mbus-serial-request-data only gets correct data if mbus-serial-request-data-multi-reply is called before #180

Open meberli opened 3 years ago

meberli commented 3 years ago

when reading a sontex heat outlet with command line tools I found a strange behaviour:

And if mbus-serial-request-data-multi-reply is executed again, the whole thing starts from the beginning...

ttjaden commented 3 years ago

For me it's the same with the following hardware:

If i first do mbus-serial-request-data-multi-reply -b 2400 /dev/ttyUSB0 2 i get the output, see: 01_mbus-serial-request-data-multi-reply.log

Afterwards I do mbus-serial-request-data -b 2400 /dev/ttyUSB0 2 and get: 02_mbus-serial-request-data.log

But without doing the first command, or by doing the command twice, at least the following information is missing in when calling mbus-serial-request-data -b 2400 /dev/ttyUSB0 2:

 <DataRecord id="9">
        <Function>Instantaneous value</Function>
        <StorageNumber>0</StorageNumber>
        <Unit>Flow temperature (1e-2 deg C)</Unit>
        <Value>2972</Value>
        <Timestamp>2021-03-05T21:34:14Z</Timestamp>
    </DataRecord>

    <DataRecord id="10">
        <Function>Instantaneous value</Function>
        <StorageNumber>0</StorageNumber>
        <Unit>Return temperature (1e-2 deg C)</Unit>
        <Value>2261</Value>
        <Timestamp>2021-03-05T21:34:14Z</Timestamp>
    </DataRecord>

    <DataRecord id="11">
        <Function>Instantaneous value</Function>
        <StorageNumber>0</StorageNumber>
        <Unit>Temperature Difference (1e-2  deg C)</Unit>
        <Value>711</Value>
        <Timestamp>2021-03-05T21:34:14Z</Timestamp>
    </DataRecord>

    <DataRecord id="12">
        <Function>Instantaneous value</Function>
        <StorageNumber>0</StorageNumber>
        <Unit>Power (100 W)</Unit>
        <Value>0</Value>
        <Timestamp>2021-03-05T21:34:14Z</Timestamp>
    </DataRecord>

    <DataRecord id="13">
        <Function>Instantaneous value</Function>
        <StorageNumber>0</StorageNumber>
        <Unit>Volume flow (m m^3/h)</Unit>
        <Value>0</Value>
        <Timestamp>2021-03-05T21:34:14Z</Timestamp>
    </DataRecord>

    <DataRecord id="14">
        <Function>Instantaneous value</Function>
        <StorageNumber>0</StorageNumber>
        <Unit>Time Point (time &amp; date)</Unit>
        <Value>2021-03-05T22:14:00</Value>
        <Timestamp>2021-03-05T21:34:14Z</Timestamp>
    </DataRecord>

    <DataRecord id="15">
        <Function>Instantaneous value</Function>
        <StorageNumber>0</StorageNumber>
        <Unit>Operating time (hours)</Unit>
        <Value>12975</Value>
        <Timestamp>2021-03-05T21:34:14Z</Timestamp>
    </DataRecord>
Apollon77 commented 3 years ago

I can proof the basic solution to send a rest to the respective device address working. I basically only added the lines here and left "Init_slaves" as is.

https://github.com/Apollon77/node-mbus/commit/95d02e1041d82c0c29f4506326f0d9a8b1023e98#diff-e8fba70aee8fbbcfc020c8266880774a1f474f09f3f8c5ffb5a1a76254712038R305-R320