Esempio n. 1
0
    def header_content(self) -> bytes:

        return b"".join([
            fields.DlmsHdlcFrameFormatField(
                length=self.frame_length, segmented=self.segmented).to_bytes(),
            self.destination_address.to_bytes(),
            self.source_address.to_bytes(),
            self.get_control_field().to_bytes(),
        ])
Esempio n. 2
0
def test_hdlc_frame_format_to_bytes_segmented():
    f = fields.DlmsHdlcFrameFormatField(length=29, segmented=True)
    assert f.to_bytes().hex() == "a81d"
Esempio n. 3
0
def test_hdlc_frame_format_raises_value_error_too_long():
    with pytest.raises(ValueError):
        fields.DlmsHdlcFrameFormatField(length=999999, segmented=False)