File: routing_indication.py

package info (click to toggle)
python-xknx 3.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,012 kB
  • sloc: python: 39,710; javascript: 8,556; makefile: 27; sh: 12
file content (37 lines) | stat: -rw-r--r-- 1,063 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
Module for Serialization and Deserialization of KNX RoutingIndication frames.

Routing indications are used to transport CEMI Messages.
"""

from __future__ import annotations

from .body import KNXIPBody
from .knxip_enum import KNXIPServiceType


class RoutingIndication(KNXIPBody):
    """Representation of a KNX RoutingIndication frame."""

    SERVICE_TYPE = KNXIPServiceType.ROUTING_INDICATION

    def __init__(self, raw_cemi: bytes = b"") -> None:
        """Initialize RoutingIndication object."""
        self.raw_cemi = raw_cemi

    def calculated_length(self) -> int:
        """Get length of KNX/IP body."""
        return len(self.raw_cemi)

    def from_knx(self, raw: bytes) -> int:
        """Parse/deserialize from KNX/IP raw data."""
        self.raw_cemi = raw
        return len(raw)

    def to_knx(self) -> bytes:
        """Serialize to KNX/IP raw data."""
        return self.raw_cemi

    def __repr__(self) -> str:
        """Return object as readable string."""
        return f'<RoutingIndication cemi="{self.raw_cemi.hex()}" />'