dlms-cosem icon indicating copy to clipboard operation
dlms-cosem copied to clipboard

Remove the need for the general A XDR parser.

Open Krolken opened this issue 3 years ago • 0 comments

The current A XDR parser was made so that it was possible to just write a parsing config to APDUs and it would output the correct dict to create the object.

But it has proven that it is just was smoother to handparse each APDU. Some of the larger and more complex ones might be a little bit annoying but on the whole it is much clearer in the code when the parsing is done explicitly.

The use we want to keep it for is to parse dynamic DLMS data returned from meters. If we remove the general parsing and make it into a dlms response data parse we can get a smoother solution than:


def parse_as_dlms_data(data: bytes):
    data_decoder = a_xdr.AXdrDecoder(
        encoding_conf=a_xdr.EncodingConf(
            attributes=[a_xdr.Sequence(attribute_name="data")]
        )
    )
    return data_decoder.decode(data)["data"]

Krolken avatar Feb 18 '21 09:02 Krolken