bikeshedder / sunspec

Rust crate for accessing SunSpec compliant devices in a safe and convenient way.
Apache License 2.0
4 stars 3 forks source link

Model 802: SOC Incorrect Type #13

Open kenny-peak-energy opened 2 days ago

kenny-peak-energy commented 2 days ago

Per my comment on the file. I believe this should be an Option<u16>.

    /// State of Charge
    ///
    /// State of charge, expressed as a percentage.
    ///
    /// Notes: Measurement.
    pub soc: u16,
bikeshedder commented 2 days ago

The SoC field is marked as mandatory in the JSON model:

            {
                "desc": "State of charge, expressed as a percentage.",
                "label": "State of Charge",
                "mandatory": "M",
                "name": "SoC",
                "sf": "SoC_SF",
                "size": 1,
                "type": "uint16",
                "units": "%WHRtg"
            },

https://github.com/sunspec/models/blob/241057a11d8cd82ca1c2c7e69a7eb4b210169bb1/json/model_802.json#L112-L121

I just checked the SMDX (XML) model file and it's been mandatory ever since:

      <point id="SoC" offset="9" type="uint16" sf="SoC_SF" units="%WHRtg" mandatory="true" />

https://github.com/sunspec/models/blob/a1184356743f7a2673b2a58d633c3d884b6a04ba/smdx/smdx_00802.xml#L14C7-L14C94

Just to be sure I also checked in the SunSpec_Information_Model_Referenc_20211209.xls file:

image


Unless the spec is wrong this really should be a u16 and not an Option<u16>.

bikeshedder commented 2 days ago

I just opened a new issue about parsing invalid model data:

Is this maybe what you were looking for?