예제 #1
0
    def parse_bytes(profile_bytes: bytes):
        """
        Profile generic are sent as a sequence of A-XDR encoded DlmsData.
        """
        data_decoder = a_xdr.AXdrDecoder(encoding_conf=a_xdr.EncodingConf(
            attributes=[a_xdr.Sequence(attribute_name="data")]))
        entries: List[List[Any]] = data_decoder.decode(profile_bytes)["data"]

        return AssociationObjectListParser.parse_entries(entries)
예제 #2
0
    encryption_key=encryption_key,
    authentication_key=authentication_key,
)

with public_client(host=host, port=port).session() as client:

    response_data = client.get(
        cosem.CosemAttribute(
            interface=enumerations.CosemInterface.DATA,
            instance=cosem.Obis(0, 0, 0x2B, 1, 0),
            attribute=2,
        )
    )
    data_decoder = a_xdr.AXdrDecoder(
        encoding_conf=a_xdr.EncodingConf(
            attributes=[a_xdr.Sequence(attribute_name="data")]
        )
    )
    invocation_counter = data_decoder.decode(response_data)["data"]
    print(f"meter_initial_invocation_counter = {invocation_counter}")

# we are not reusing the socket as of now. We just need to give the meter some time to
# close the connection on its side
sleep(1)

with management_client(
    host=host, port=port, client_initial_invocation_counter=invocation_counter + 1
).session() as client:

    profile = client.get(
        cosem.CosemAttribute(
예제 #3
0
파일: utils.py 프로젝트: pwitab/dlms-cosem
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"]