#  #############################################################################
#  ##           THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.            ##
#  #############################################################################
from __future__ import annotations

import contextlib
import dataclasses
import enum
import struct
import typing
from loguru import logger
from ozobot.common.crc import crc32
from ozobot.common.convert import serialize_array, deserialize_array
from ozobot.common.rlock import RLock
from ozobot.common.types import s8_24_deserialize, s8_24_serialize
__all__ = ["AsyncControl", "Types"]


class S8_24_impl(float):
    data_width =  4

    def serialize(self) -> bytes:
        return s8_24_serialize(self)

    @classmethod
    def deserialize(cls, data: bytes) -> typing.Self:
        return cls(s8_24_deserialize(data))

    def expected_length(self, source: typing.Any) -> int:
        return 4


class _PacketType(typing.Protocol):

    def serialize(self) -> bytes:
        ...

    @classmethod
    def deserialize(cls, data: bytes) -> typing.Self:
        ...

    def expected_length(self, source: typing.Any) -> int:
        ...

    def is_response_to(self, request: _PacketType) -> bool:
        ...

    def is_event_of(self, request: _PacketType) -> bool:
        ...


class _ProtocolType(typing.Protocol):

    @classmethod
    def get_data_width(cls) -> int:
        ...

    def serialize(self) -> bytes:
        ...

    @classmethod
    def deserialize(cls, data: bytes) -> typing.Self:
        ...


@dataclasses.dataclass
class PropertyMetadata[T: _ProtocolType]:
    is_readable: bool
    is_writable: bool
    type: type[T]
    address: int

    @property
    def size(self) -> int:
        return self.type.get_data_width()


class _Channel(typing.Protocol):

    @property
    def packet_size_max(self) -> int:
        ...

    def open_session(self) -> typing.AsyncContextManager[_Session]:
        ...


class _Session(typing.Protocol):

    def read(self) -> typing.AsyncIterator[bytes]:
        ...

    async def write(self, data: bytes) -> None:
        ...
type RpcCall[TResponse, TEvent] = contextlib.AbstractAsyncContextManager[tuple[TResponse, typing.AsyncIterator[TEvent]]]


class Types:

    class c8(str):
        """Builtin type: c8(str)"""
        data_width = 1

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width
        py_pack = 'c'

        def serialize(self):
            return struct.pack(self.py_pack, self)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<'+cls.py_pack, data))

    class u8(int):
        """Builtin type: u8(int)"""
        data_width = 1

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width
        py_pack = 'B'

        def serialize(self):
            return struct.pack(self.py_pack, self)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<'+cls.py_pack, data))

    class u16(int):
        """Builtin type: u16(int)"""
        data_width = 2

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width
        py_pack = 'H'

        def serialize(self):
            return struct.pack(self.py_pack, self)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<'+cls.py_pack, data))

    class u32(int):
        """Builtin type: u32(int)"""
        data_width = 4

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width
        py_pack = 'I'

        def serialize(self):
            return struct.pack(self.py_pack, self)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<'+cls.py_pack, data))

    class u64(int):
        """Builtin type: u64(int)"""
        data_width = 8

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width
        py_pack = 'Q'

        def serialize(self):
            return struct.pack(self.py_pack, self)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<'+cls.py_pack, data))

    class i8(int):
        """Builtin type: i8(int)"""
        data_width = 1

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width
        py_pack = 'b'

        def serialize(self):
            return struct.pack(self.py_pack, self)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<'+cls.py_pack, data))

    class i16(int):
        """Builtin type: i16(int)"""
        data_width = 2

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width
        py_pack = 'h'

        def serialize(self):
            return struct.pack(self.py_pack, self)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<'+cls.py_pack, data))

    class i32(int):
        """Builtin type: i32(int)"""
        data_width = 4

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width
        py_pack = 'i'

        def serialize(self):
            return struct.pack(self.py_pack, self)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<'+cls.py_pack, data))

    class i64(int):
        """Builtin type: i64(int)"""
        data_width = 8

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width
        py_pack = 'q'

        def serialize(self):
            return struct.pack(self.py_pack, self)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<'+cls.py_pack, data))

    class RequestID(int):
        """Builtin type: RequestID(int)"""
        data_width = 4

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width
        py_pack = 'I'

        def serialize(self):
            return struct.pack(self.py_pack, self)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<'+cls.py_pack, data))

    class S8_24(S8_24_impl):
        """Builtin type: S8_24(S8_24_impl)"""
        data_width = 4

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width
        pass

    class addr_t(u32):
        """Scalar type: addr_t(int)

        Address type. Should be able to address any location in protocol virtual memory. Location of singular entries are available within memory_map object."""
        pass

        def __repr__(self):
            return f'addr_t({int(self)})'

    class size_t(u16):
        """Scalar type: size_t(int)

        Size type. Should be able to express size of arbitrary protocol object. Size is often coerced in to <0,metadata.max_packet_length>"""
        pass

        def __repr__(self):
            return f'size_t({int(self)})'

    class interval_t(u16):
        """Scalar type: interval_t(int)

        Interval type. Expresses any time interval used in protocol. Interval's unit should be millisecond unless explicitly specified."""
        pass

        def __repr__(self):
            return f'interval_t({int(self)})'

    class time_t(u32):
        """Scalar type: time_t(int)

        Time type. Expresses any absolute time used in protocol. Time's unit should be millisecond unless explicitly specified."""
        pass

        def __repr__(self):
            return f'time_t({int(self)})'

    class Version:
        """Struct type
        Raw version number. Note that major field is currently offset by 128 for newer firmware versions.

        Version(
            major: u8,
            minor: u8,
            patch: u16
        )

        Example JSON representation:
        {
            "major": 0,
            "minor": 0,
            "patch": 0
        }"""
        data_width = 4

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, major, minor, patch):
            self.major = Types.u8(major)
            self.minor = Types.u8(minor)
            self.patch = Types.u16(patch)

        def __repr__(self):
            return f'Version(major={self.major}, minor={self.minor}, patch={self.patch})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.major == other.major) and (self.minor == other.minor) and (self.patch == other.patch)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(4))
            buffer[0:1] = Types.u8.serialize(self.major)
            buffer[1:2] = Types.u8.serialize(self.minor)
            buffer[2:4] = Types.u16.serialize(self.patch)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            major = Types.u8.deserialize(data[0:1])
            minor = Types.u8.deserialize(data[1:2])
            patch = Types.u16.deserialize(data[2:4])
            return cls(major, minor, patch)

        @classmethod
        def expected_length(cls, source):
            return 4

    @enum.unique
    class RequestIdSource(enum.IntEnum):
        """Enum type RequestIdSource
                Request ID group identifier (there can be many of request ID groups). MSB (top 8 bits) of every requestId should be this source.
        Can attain one of:
                Ble, Firmware, LegacyLfOnOf, Remote, Reserved, VirtualMachine"""
        data_width = enum.nonmember(1)

        Ble = 2
        Firmware = 4
        LegacyLfOnOf = 3
        Remote = 5
        Reserved = 0
        VirtualMachine = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class LoggingState(enum.IntEnum):
        """Enum type LoggingState
                Logging state.
        Can attain one of:
                Off, On_IgnoreSampleDrop, On_StopWithSampleDrop"""
        data_width = enum.nonmember(1)

        Off = 0
        On_IgnoreSampleDrop = 2
        On_StopWithSampleDrop = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class LightSource(enum.IntEnum):
        """Enum type LightSource
                Light source state.
        Can attain one of:
                Off, On"""
        data_width = enum.nonmember(1)

        Off = 0
        On = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class ColorCodeExecution(enum.IntEnum):
        """Enum type ColorCodeExecution
                Color code execution like increasing line navigation speed etc. Disabled - disables FW color code execution it still can be executed via OzoVM or other mean. Legacy - if not intercepted by the OzoVM firmware executes legacy behavior.
        Can attain one of:
                Disabled, Legacy"""
        data_width = enum.nonmember(1)

        Disabled = 0
        Legacy = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class IRChannelEmitState(enum.IntEnum):
        """Enum type IRChannelEmitState
                IR channel emit state.
        Can attain one of:
                Off, On"""
        data_width = enum.nonmember(1)

        Off = 0
        On = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class ErrorModuleIDs(enum.IntEnum):
        """Enum type ErrorModuleIDs
                Error signalization module identifier.
        Can attain one of:
                Bluetooth, BrightnessControl, ControlProtocol, OzoVMLoadFromColors, OzoVMProgramStreamLoader, OzoVMSystemCalls, Undefined, UnsupportedOperation, VirtualMachineTask"""
        data_width = enum.nonmember(1)

        Bluetooth = 4
        BrightnessControl = 8
        ControlProtocol = 9
        OzoVMLoadFromColors = 1
        OzoVMProgramStreamLoader = 0
        OzoVMSystemCalls = 2
        Undefined = 255
        UnsupportedOperation = 5
        VirtualMachineTask = 7

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class ButtonOverrideEnum(enum.IntEnum):
        """Enum type ButtonOverrideEnum
                Button override status.
        Can attain one of:
                NotOverridden, Overridden"""
        data_width = enum.nonmember(1)

        NotOverridden = 0
        Overridden = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class PickupDetectionEnum(enum.IntEnum):
        """Enum type PickupDetectionEnum
                Pickup detection state as on surface or picked up.
        Can attain one of:
                OnSurface, PickedUp"""
        data_width = enum.nonmember(1)

        OnSurface = 0
        PickedUp = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    class ColorSensorData:
        """Struct type
        Raw data from color sensor.

        ColorSensorData(
            red: u16,
            green: u16,
            blue: u16,
            clear: u16,
            lightSource: Enum<LightSource.Off, LightSource.On>,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "red": 0,
            "green": 0,
            "blue": 0,
            "clear": 0,
            "lightSource": "On",
            "timestamp": 0
        }"""
        data_width = 13

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, red, green, blue, clear, lightSource, timestamp):
            self.red = Types.u16(red)
            self.green = Types.u16(green)
            self.blue = Types.u16(blue)
            self.clear = Types.u16(clear)
            self.lightSource = Types.LightSource(lightSource)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'ColorSensorData(red={self.red}, green={self.green}, blue={self.blue}, clear={self.clear}, lightSource={self.lightSource}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.red == other.red) and (self.green == other.green) and (self.blue == other.blue) and (self.clear == other.clear) and (self.lightSource == other.lightSource) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(13))
            buffer[0:2] = Types.u16.serialize(self.red)
            buffer[2:4] = Types.u16.serialize(self.green)
            buffer[4:6] = Types.u16.serialize(self.blue)
            buffer[6:8] = Types.u16.serialize(self.clear)
            buffer[8:9] = Types.LightSource.serialize(self.lightSource)
            buffer[9:13] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            red = Types.u16.deserialize(data[0:2])
            green = Types.u16.deserialize(data[2:4])
            blue = Types.u16.deserialize(data[4:6])
            clear = Types.u16.deserialize(data[6:8])
            lightSource = Types.LightSource.deserialize(data[8:9])
            timestamp = Types.time_t.deserialize(data[9:13])
            return cls(red, green, blue, clear, lightSource, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 13

    @enum.unique
    class ColorSensorStatus(enum.IntFlag):
        """Bitmap type ColorSensorStatus
                Color sensor sample status.
        Can attain none, one or more of (separated by '|' character):
                AnalogSaturation, DigitalSaturation, Valid
        """
        data_width = enum.nonmember(1)

        AnalogSaturation = 2
        DigitalSaturation = 4
        Valid = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    class ColorSensorDataWithStatus:
        """Struct type
        Raw data from color sensor.

        ColorSensorDataWithStatus(
            red: u16,
            green: u16,
            blue: u16,
            clear: u16,
            lightSource: Enum<LightSource.Off, LightSource.On>,
            status: Bitfield<ColorSensorStatus.AnalogSaturation | ColorSensorStatus.DigitalSaturation | ColorSensorStatus.Valid>,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "red": 0,
            "green": 0,
            "blue": 0,
            "clear": 0,
            "lightSource": "On",
            "status": "Valid",
            "timestamp": 0
        }"""
        data_width = 14

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, red, green, blue, clear, lightSource, status, timestamp):
            self.red = Types.u16(red)
            self.green = Types.u16(green)
            self.blue = Types.u16(blue)
            self.clear = Types.u16(clear)
            self.lightSource = Types.LightSource(lightSource)
            self.status = Types.ColorSensorStatus(status)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'ColorSensorDataWithStatus(red={self.red}, green={self.green}, blue={self.blue}, clear={self.clear}, lightSource={self.lightSource}, status={self.status}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.red == other.red) and (self.green == other.green) and (self.blue == other.blue) and (self.clear == other.clear) and (self.lightSource == other.lightSource) and (self.status == other.status) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(14))
            buffer[0:2] = Types.u16.serialize(self.red)
            buffer[2:4] = Types.u16.serialize(self.green)
            buffer[4:6] = Types.u16.serialize(self.blue)
            buffer[6:8] = Types.u16.serialize(self.clear)
            buffer[8:9] = Types.LightSource.serialize(self.lightSource)
            buffer[9:10] = Types.ColorSensorStatus.serialize(self.status)
            buffer[10:14] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            red = Types.u16.deserialize(data[0:2])
            green = Types.u16.deserialize(data[2:4])
            blue = Types.u16.deserialize(data[4:6])
            clear = Types.u16.deserialize(data[6:8])
            lightSource = Types.LightSource.deserialize(data[8:9])
            status = Types.ColorSensorStatus.deserialize(data[9:10])
            timestamp = Types.time_t.deserialize(data[10:14])
            return cls(red, green, blue, clear, lightSource, status, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 14

    class RGBColor:
        """Struct type
        RGB color.

        RGBColor(
            red: u8,
            green: u8,
            blue: u8
        )

        Example JSON representation:
        {
            "red": 0,
            "green": 0,
            "blue": 0
        }"""
        data_width = 3

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, red, green, blue):
            self.red = Types.u8(red)
            self.green = Types.u8(green)
            self.blue = Types.u8(blue)

        def __repr__(self):
            return f'RGBColor(red={self.red}, green={self.green}, blue={self.blue})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.red == other.red) and (self.green == other.green) and (self.blue == other.blue)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(3))
            buffer[0:1] = Types.u8.serialize(self.red)
            buffer[1:2] = Types.u8.serialize(self.green)
            buffer[2:3] = Types.u8.serialize(self.blue)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            red = Types.u8.deserialize(data[0:1])
            green = Types.u8.deserialize(data[1:2])
            blue = Types.u8.deserialize(data[2:3])
            return cls(red, green, blue)

        @classmethod
        def expected_length(cls, source):
            return 3

    class RGBColorWithTimestamp:
        """Struct type
        RGB color with timestamp.

        RGBColorWithTimestamp(
            color: RGBColor(
                red: u8,
                green: u8,
                blue: u8
            ),
            timestamp: time_t
        )

        Example JSON representation:
        {
            "color": {
                "red": 0,
                "green": 0,
                "blue": 0
            },
            "timestamp": 0
        }"""
        data_width = 7

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, color, timestamp):
            self.color = Types.RGBColor(color)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'RGBColorWithTimestamp(color={self.color}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.color == other.color) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(7))
            buffer[0:3] = Types.RGBColor.serialize(self.color)
            buffer[3:7] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            color = Types.RGBColor.deserialize(data[0:3])
            timestamp = Types.time_t.deserialize(data[3:7])
            return cls(color, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 7

    class ProcessedRGBColor:
        """Struct type
        Processed RGB color. Look at lightSource to know surface type (paper or screen).

        ProcessedRGBColor(
            normalized: RGBColor(
                red: u8,
                green: u8,
                blue: u8
            ),
            transformed: RGBColor(
                red: u8,
                green: u8,
                blue: u8
            ),
            lightSource: Enum<LightSource.Off, LightSource.On>,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "normalized": {
                "red": 0,
                "green": 0,
                "blue": 0
            },
            "transformed": {
                "red": 0,
                "green": 0,
                "blue": 0
            },
            "lightSource": "On",
            "timestamp": 0
        }"""
        data_width = 11

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, normalized, transformed, lightSource, timestamp):
            self.normalized = Types.RGBColor(normalized)
            self.transformed = Types.RGBColor(transformed)
            self.lightSource = Types.LightSource(lightSource)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'ProcessedRGBColor(normalized={self.normalized}, transformed={self.transformed}, lightSource={self.lightSource}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.normalized == other.normalized) and (self.transformed == other.transformed) and (self.lightSource == other.lightSource) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(11))
            buffer[0:3] = Types.RGBColor.serialize(self.normalized)
            buffer[3:6] = Types.RGBColor.serialize(self.transformed)
            buffer[6:7] = Types.LightSource.serialize(self.lightSource)
            buffer[7:11] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            normalized = Types.RGBColor.deserialize(data[0:3])
            transformed = Types.RGBColor.deserialize(data[3:6])
            lightSource = Types.LightSource.deserialize(data[6:7])
            timestamp = Types.time_t.deserialize(data[7:11])
            return cls(normalized, transformed, lightSource, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 11

    class HCLColor:
        """Struct type
        HCL color.

        HCLColor(
            hue: u16,
            chroma: u8,
            lightness: u8
        )

        Example JSON representation:
        {
            "hue": 0,
            "chroma": 0,
            "lightness": 0
        }"""
        data_width = 4

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, hue, chroma, lightness):
            self.hue = Types.u16(hue)
            self.chroma = Types.u8(chroma)
            self.lightness = Types.u8(lightness)

        def __repr__(self):
            return f'HCLColor(hue={self.hue}, chroma={self.chroma}, lightness={self.lightness})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.hue == other.hue) and (self.chroma == other.chroma) and (self.lightness == other.lightness)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(4))
            buffer[0:2] = Types.u16.serialize(self.hue)
            buffer[2:3] = Types.u8.serialize(self.chroma)
            buffer[3:4] = Types.u8.serialize(self.lightness)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            hue = Types.u16.deserialize(data[0:2])
            chroma = Types.u8.deserialize(data[2:3])
            lightness = Types.u8.deserialize(data[3:4])
            return cls(hue, chroma, lightness)

        @classmethod
        def expected_length(cls, source):
            return 4

    class HCLColorWithTimestamp:
        """Struct type
        HCL color with timestamp.

        HCLColorWithTimestamp(
            color: HCLColor(
                hue: u16,
                chroma: u8,
                lightness: u8
            ),
            timestamp: time_t
        )

        Example JSON representation:
        {
            "color": {
                "hue": 0,
                "chroma": 0,
                "lightness": 0
            },
            "timestamp": 0
        }"""
        data_width = 8

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, color, timestamp):
            self.color = Types.HCLColor(color)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'HCLColorWithTimestamp(color={self.color}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.color == other.color) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(8))
            buffer[0:4] = Types.HCLColor.serialize(self.color)
            buffer[4:8] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            color = Types.HCLColor.deserialize(data[0:4])
            timestamp = Types.time_t.deserialize(data[4:8])
            return cls(color, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 8

    class SurfaceProximityData:
        """Struct type
        Raw surface proximity data from color sensor.

        SurfaceProximityData(
            proximity: u16,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "proximity": 0,
            "timestamp": 0
        }"""
        data_width = 6

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, proximity, timestamp):
            self.proximity = Types.u16(proximity)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'SurfaceProximityData(proximity={self.proximity}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.proximity == other.proximity) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(6))
            buffer[0:2] = Types.u16.serialize(self.proximity)
            buffer[2:6] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            proximity = Types.u16.deserialize(data[0:2])
            timestamp = Types.time_t.deserialize(data[2:6])
            return cls(proximity, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 6

    @enum.unique
    class LineColorEnum(enum.IntEnum):
        """Enum type LineColorEnum
                Line colors.
        Can attain one of:
                Black, Blue, Green, Red, Unknown"""
        data_width = enum.nonmember(1)

        Black = 0
        Blue = 3
        Green = 2
        Red = 1
        Unknown = 255

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class SurfaceColorEnum(enum.IntEnum):
        """Enum type SurfaceColorEnum
                Surface colors.
        Can attain one of:
                Black, Blue, Cyan, Green, Magenta, Red, Unknown, White, Yellow"""
        data_width = enum.nonmember(1)

        Black = 0
        Blue = 4
        Cyan = 6
        Green = 2
        Magenta = 5
        Red = 1
        Unknown = 8
        White = 7
        Yellow = 3

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class PlasticColor(enum.IntEnum):
        """Enum type PlasticColor
                Plastic dominant color.
        Can attain one of:
                Black, White"""
        data_width = enum.nonmember(1)

        Black = 1
        White = 0

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class EncryptionKeyVariant(enum.IntEnum):
        """Enum type EncryptionKeyVariant
                Encryption key variant.
        Can attain one of:
                Development, KeyFingerprint, Production"""
        data_width = enum.nonmember(1)

        Development = 1
        KeyFingerprint = 255
        Production = 0

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class LogLevel(enum.IntEnum):
        """Enum type LogLevel
                Logger levels. Error - information about critical errors. Warning - recoverable error messages. Info - basic state information like color code events. DebugX - serve for a module testing and debugging.
        Can attain one of:
                Debug, Debug1, Debug2, Debug3, Disabled, Error, Info, Warning"""
        data_width = enum.nonmember(1)

        Debug = 4
        Debug1 = 5
        Debug2 = 6
        Debug3 = 7
        Disabled = 0
        Error = 1
        Info = 3
        Warning = 2

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class LEDsMask(enum.IntFlag):
        """Bitmap type LEDsMask
                LEDs mask based on theirs placement.
        Can attain none, one or more of (separated by '|' character):
                back, button, front_center, front_left, front_left_center, front_right, front_right_center, top
        """
        data_width = enum.nonmember(2)

        back = 128
        button = 64
        front_center = 8
        front_left = 2
        front_left_center = 4
        front_right = 32
        front_right_center = 16
        top = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 2

        def serialize(self) -> bytes:
            return struct.pack('<H', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<H', data))

    @enum.unique
    class BootloaderFields(enum.IntFlag):
        """Bitmap type BootloaderFields
                Bootloader action fields as recovery loaded.
        Can attain none, one or more of (separated by '|' character):
                firmwareLoaded, recoveryLoaded, smartSkin
        """
        data_width = enum.nonmember(1)

        firmwareLoaded = 4
        recoveryLoaded = 2
        smartSkin = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class IOResult(enum.IntEnum):
        """Enum type IOResult
                Result of an IO operation. Result is considered erroneous unless equal to Success.
        Can attain one of:
                ErrorInvalidData, ErrorMisaligned, ErrorOutOfRange, ErrorPartialWrite, ErrorPermissionDenied, ErrorRangeToLarge, ErrorReadOnly, ErrorUnknown, Success"""
        data_width = enum.nonmember(1)

        ErrorInvalidData = 8
        ErrorMisaligned = 6
        ErrorOutOfRange = 4
        ErrorPartialWrite = 7
        ErrorPermissionDenied = 3
        ErrorRangeToLarge = 5
        ErrorReadOnly = 2
        ErrorUnknown = 1
        Success = 0

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class IntersectionDirection(enum.IntEnum):
        """Enum type IntersectionDirection
                Possible directions to choose from at an intersection.
        Can attain one of:
                Backward, Left, Right, Straight"""
        data_width = enum.nonmember(1)

        Backward = 8
        Left = 1
        Right = 4
        Straight = 2

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class IntersectionBitmap(enum.IntFlag):
        """Bitmap type IntersectionBitmap
                Intersection bitmap. All recognizable intersections can be describe with it. Consecutive intersections are valid only if they contain Back flag due to the fact robot must have arrived from a previously established line. Emission of intersection with forward only or empty flags can happen if robot started outside of line bounds and/or never moved to a line.
        Can attain none, one or more of (separated by '|' character):
                Backward, Left, Right, Straight
        """
        data_width = enum.nonmember(1)

        Backward = 8
        Left = 1
        Right = 4
        Straight = 2

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class LineCharacteristic(enum.IntFlag):
        """Bitmap type LineCharacteristic
                Line characteristics like whether line is under all sensors. LineOnLeft/Right is set when there are multiple lines detected under the sensors whilst line following. Can me used to read arbitrary data besides the current line-followed line.
        Can attain none, one or more of (separated by '|' character):
                LineOnLeft, LineOnRight, LineUnderAll
        """
        data_width = enum.nonmember(1)

        LineOnLeft = 2
        LineOnRight = 4
        LineUnderAll = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class ExecutionStateEnum(enum.IntEnum):
        """Enum type ExecutionStateEnum
                Execution states. State is considered erroneous unless equals to FinishedNormal. All states except the Running signal completion of the execution.
        Can attain one of:
                CorruptedInput, FileNotFound, FinishedForced, FinishedNormal, InvalidCalibration, InvalidRequest, NotExecuted, Running"""
        data_width = enum.nonmember(1)

        CorruptedInput = 6
        FileNotFound = 4
        FinishedForced = 2
        FinishedNormal = 1
        InvalidCalibration = 7
        InvalidRequest = 5
        NotExecuted = 3
        Running = 0

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class ChargerStateEnum(enum.IntEnum):
        """Enum type ChargerStateEnum
                Charger state.
        Can attain one of:
                Connected, Disconnected, LowPower"""
        data_width = enum.nonmember(1)

        Connected = 1
        Disconnected = 0
        LowPower = 2

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class ShutdownSource(enum.IntEnum):
        """Enum type ShutdownSource
                Shutdown source.
        Can attain one of:
                BleDisconnect, Button, ChargerDisconnect, ColorCode, LowBattery, OzoVM, Restart, SystemAPI"""
        data_width = enum.nonmember(1)

        BleDisconnect = 5
        Button = 0
        ChargerDisconnect = 4
        ColorCode = 6
        LowBattery = 1
        OzoVM = 7
        Restart = 3
        SystemAPI = 2

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class PressType(enum.IntEnum):
        """Enum type PressType
                Button press type.
        Can attain one of:
                Double, Long, Max, Release, Short"""
        data_width = enum.nonmember(1)

        Double = 2
        Long = 1
        Max = 3
        Release = 4
        Short = 0

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class CalibrationType(enum.IntEnum):
        """Enum type CalibrationType
                Calibration type.
        Can attain one of:
                ColorSensor, Encoders, HeightSensor, LineSensors, OnSpot, OnSpotWithoutEncoders"""
        data_width = enum.nonmember(1)

        ColorSensor = 2
        Encoders = 0
        HeightSensor = 3
        LineSensors = 1
        OnSpot = 4
        OnSpotWithoutEncoders = 5

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class FirmwareUpdateSourceEnum(enum.IntEnum):
        """Enum type FirmwareUpdateSourceEnum
                Firmware update source.
        Can attain one of:
                FileSystem, Recovery"""
        data_width = enum.nonmember(1)

        FileSystem = 0
        Recovery = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class FirmwareUpdateTargetEnum(enum.IntEnum):
        """Enum type FirmwareUpdateTargetEnum
                Firmware update target.
        Can attain one of:
                MainMCU, WirelessMCU"""
        data_width = enum.nonmember(1)

        MainMCU = 0
        WirelessMCU = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class CallStatus(enum.IntEnum):
        """Enum type CallStatus
                Response to the request previously sent for processing. It's considered erroneous unless equals to CallSuccess.
        Can attain one of:
                CallError, CallSuccess, InvalidParameters, Unsupported"""
        data_width = enum.nonmember(1)

        CallError = 2
        CallSuccess = 0
        InvalidParameters = 1
        Unsupported = 3

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class SurfaceType(enum.IntEnum):
        """Enum type SurfaceType
                Surface type as paper or screen.
        Can attain one of:
                Paper, Screen, Unknown"""
        data_width = enum.nonmember(1)

        Paper = 0
        Screen = 1
        Unknown = 255

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class CalibrationResultEnum(enum.IntEnum):
        """Enum type CalibrationResultEnum
                Calibration result.
        Can attain one of:
                ColorSensorCalibrationAlignmentFailure, ColorSensorThresholdFailure, EncodersFailure, LineSensorsCalibrationAlignmentFailure, LineSensorsThresholdFailure, NewDotFinalAlignmentFailure,
                NewDotLineAlignmentFailure, Success"""
        data_width = enum.nonmember(1)

        ColorSensorCalibrationAlignmentFailure = 5
        ColorSensorThresholdFailure = 3
        EncodersFailure = 1
        LineSensorsCalibrationAlignmentFailure = 4
        LineSensorsThresholdFailure = 2
        NewDotFinalAlignmentFailure = 7
        NewDotLineAlignmentFailure = 6
        Success = 0

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class CalibrationStatus(enum.IntEnum):
        """Enum type CalibrationStatus
                Calibration status which tells whether calibration can be used or need to be performed again.
        Can attain one of:
                Invalid, Valid"""
        data_width = enum.nonmember(1)

        Invalid = 0
        Valid = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class CalibrationRangeStatus(enum.IntFlag):
        """Bitmap type CalibrationRangeStatus
                Calibration range status which tells whether range is valid or in which criteria is failing.
        Can attain none, one or more of (separated by '|' character):
                DifferenceTooHigh, DifferenceTooLow, LowerBoundCrossed, UpperBoundCrossed
        """
        data_width = enum.nonmember(1)

        DifferenceTooHigh = 2
        DifferenceTooLow = 1
        LowerBoundCrossed = 4
        UpperBoundCrossed = 8

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    class WatcherInfo:
        """Struct type
        Information about watchers such as count or number of regions each can oversee.

        WatcherInfo(
            watcherCount: u8,
            watcherRegionCount: u8
        )

        Example JSON representation:
        {
            "watcherCount": 0,
            "watcherRegionCount": 0
        }"""
        data_width = 2

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, watcherCount, watcherRegionCount):
            self.watcherCount = Types.u8(watcherCount)
            self.watcherRegionCount = Types.u8(watcherRegionCount)

        def __repr__(self):
            return f'WatcherInfo(watcherCount={self.watcherCount}, watcherRegionCount={self.watcherRegionCount})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.watcherCount == other.watcherCount) and (self.watcherRegionCount == other.watcherRegionCount)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(2))
            buffer[0:1] = Types.u8.serialize(self.watcherCount)
            buffer[1:2] = Types.u8.serialize(self.watcherRegionCount)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            watcherCount = Types.u8.deserialize(data[0:1])
            watcherRegionCount = Types.u8.deserialize(data[1:2])
            return cls(watcherCount, watcherRegionCount)

        @classmethod
        def expected_length(cls, source):
            return 2

    @enum.unique
    class WatcherFlags(enum.IntFlag):
        """Bitmap type WatcherFlags
                Watcher flags permitting Enable state to the watcher. To disable the watcher and remove any additional options, set it to 0.
        Can attain none, one or more of (separated by '|' character):
                DisableWhenDisconnected, Enabled, SendInitialValue
        """
        data_width = enum.nonmember(1)

        DisableWhenDisconnected = 2
        Enabled = 1
        SendInitialValue = 4

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class WatcherRegionFlags(enum.IntFlag):
        """Bitmap type WatcherRegionFlags
                Watcher region flags. It describes how watcher works with the region. For most of the use-cases should be 0 or otherwise empty. DoNotSetDirty bundles the associated data with other events, never sends them alone; cannot be set together with DoNotSetDirty. DoNotSendInNotify sends the data alone and never bundles them with other data; cannot be set together with DoNotSetDirty.
        Can attain none, one or more of (separated by '|' character):
                DoNotSendInNotify, DoNotSetDirty
        """
        data_width = enum.nonmember(1)

        DoNotSendInNotify = 2
        DoNotSetDirty = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class BatteryFieldsEnum(enum.IntFlag):
        """Bitmap type BatteryFieldsEnum
                Battery state fields as charging.
        Can attain none, one or more of (separated by '|' character):
                Charging
        """
        data_width = enum.nonmember(1)

        Charging = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class MemoryTestFields(enum.IntFlag):
        """Bitmap type MemoryTestFields
                Memory test fields as page error.
        Can attain none, one or more of (separated by '|' character):
                PageError
        """
        data_width = enum.nonmember(1)

        PageError = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class TestModeFields(enum.IntFlag):
        """Bitmap type TestModeFields
                Test mode fields.
        Can attain none, one or more of (separated by '|' character):
                disableUSBRestrictions
        """
        data_width = enum.nonmember(4)

        disableUSBRestrictions = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 4

        def serialize(self) -> bytes:
            return struct.pack('<I', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<I', data))

    @enum.unique
    class BootloaderErrorCodes(enum.IntEnum):
        """Enum type BootloaderErrorCodes
                Bootloader error codes.
        Can attain one of:
                FirmwareDoesNotExist, FirmwareVerificationFailed, FirmwareVersionIsTooOld, FirmwareWillNotFitInMemory, FirmwareWrongEncryptionType, InconsistentFirmware, InvalidFileSystem, LowBattery, NoError,
                UnsupportedHW"""
        data_width = enum.nonmember(1)

        FirmwareDoesNotExist = 3
        FirmwareVerificationFailed = 6
        FirmwareVersionIsTooOld = 9
        FirmwareWillNotFitInMemory = 4
        FirmwareWrongEncryptionType = 5
        InconsistentFirmware = 2
        InvalidFileSystem = 8
        LowBattery = 1
        NoError = 0
        UnsupportedHW = 7

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class BluetoothUpdateErrorCodes(enum.IntEnum):
        """Enum type BluetoothUpdateErrorCodes
                Bluetooth update error codes.
        Can attain one of:
                BlockWriteFailed, BlueFlagEraseFailed, BlueFlagResetFailed, BootloaderHWVersionReadFailed, FileCRCCheckFailed, FileCorrupted, FileIncorrectSize, FileNotFound, InProgress, SectorCRCCheckFailed,
                SectorCRCGetFailed, SectorEraseFailed, Success, UnsupportedBootloaderHWVersion, UnsupportedBootloaderVersion, VersionReadFailed, WaitForUpdaterToBoot"""
        data_width = enum.nonmember(1)

        BlockWriteFailed = 12
        BlueFlagEraseFailed = 9
        BlueFlagResetFailed = 10
        BootloaderHWVersionReadFailed = 7
        FileCRCCheckFailed = 4
        FileCorrupted = 3
        FileIncorrectSize = 2
        FileNotFound = 1
        InProgress = 15
        SectorCRCCheckFailed = 13
        SectorCRCGetFailed = 14
        SectorEraseFailed = 11
        Success = 0
        UnsupportedBootloaderHWVersion = 8
        UnsupportedBootloaderVersion = 6
        VersionReadFailed = 5
        WaitForUpdaterToBoot = 16

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class BluetoothInitializedCode(enum.IntEnum):
        """Enum type BluetoothInitializedCode
                Bluetooth initialized code.
        Can attain one of:
                BrownoutReset, FirmwareStartedProperly, NotInitialized, ResetCrash, ResetECC, ResetLockUp, ResetWatchdog, UpdaterBadBlueFlag, UpdaterStartACI, UpdaterStartPin"""
        data_width = enum.nonmember(1)

        BrownoutReset = 7
        FirmwareStartedProperly = 1
        NotInitialized = 0
        ResetCrash = 8
        ResetECC = 9
        ResetLockUp = 6
        ResetWatchdog = 5
        UpdaterBadBlueFlag = 3
        UpdaterStartACI = 2
        UpdaterStartPin = 4

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class ProductTypeEnum(enum.IntEnum):
        """Enum type ProductTypeEnum
                Product type.
        Can attain one of:
                Anvil, Bridge, Evo, Evo_S, Jot15b, Jot18"""
        data_width = enum.nonmember(1)

        Anvil = 5
        Bridge = 3
        Evo = 0
        Evo_S = 1
        Jot15b = 4
        Jot18 = 2

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class AccountTypeEnum(enum.IntEnum):
        """Enum type AccountTypeEnum
                DEPRECATED. Account type.
        Can attain one of:
                Adult, Children"""
        data_width = enum.nonmember(1)

        Adult = 0
        Children = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class BehaviourTypeEnum(enum.IntEnum):
        """Enum type BehaviourTypeEnum
                Behaviour type.
        Can attain one of:
                Base, School"""
        data_width = enum.nonmember(1)

        Base = 0
        School = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class MemoryTestTypes(enum.IntEnum):
        """Enum type MemoryTestTypes
                Memory test types.
        Can attain one of:
                FullTest, FullTestReport, QuickTest"""
        data_width = enum.nonmember(1)

        FullTest = 1
        FullTestReport = 0
        QuickTest = 2

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    @enum.unique
    class LineNavigationAction(enum.IntEnum):
        """Enum type LineNavigationAction
                Line navigation action after direction alignment.

        - DoNotFollow aligns the device according to the direction specified and stops. It's semantically similar to rotating the device by N degrees, though this helps to align with the line beyond the intersection bounds.
        - Follow starts the movement and continues until the next intersection. If the movement should be cancelled due to other factors, it has to be manually cancelled.
        Can attain one of:
                DoNotFollow, Follow"""
        data_width = enum.nonmember(1)

        DoNotFollow = 0
        Follow = 1

        @classmethod
        def get_data_width(cls) -> int:
            return 1

        def serialize(self) -> bytes:
            return struct.pack('<B', self.value)

        @classmethod
        def deserialize(cls, data):
            return cls(*struct.unpack('<B', data))

    class LineAttributes:
        """Struct type
        Line properties as width.

        LineAttributes(
            position: S8_24,
            width: S8_24,
            characteristics: Bitfield<LineCharacteristic.LineOnLeft | LineCharacteristic.LineOnRight | LineCharacteristic.LineUnderAll>,
            bitmap: u8
        )

        Example JSON representation:
        {
            "position": 0.0,
            "width": 0.0,
            "characteristics": "LineUnderAll",
            "bitmap": 0
        }"""
        data_width = 10

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, position, width, characteristics, bitmap):
            self.position = Types.S8_24(position)
            self.width = Types.S8_24(width)
            self.characteristics = Types.LineCharacteristic(characteristics)
            self.bitmap = Types.u8(bitmap)

        def __repr__(self):
            return f'LineAttributes(position={self.position}, width={self.width}, characteristics={self.characteristics}, bitmap={self.bitmap})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.position == other.position) and (self.width == other.width) and (self.characteristics == other.characteristics) and (self.bitmap == other.bitmap)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(10))
            buffer[0:4] = Types.S8_24.serialize(self.position)
            buffer[4:8] = Types.S8_24.serialize(self.width)
            buffer[8:9] = Types.LineCharacteristic.serialize(self.characteristics)
            buffer[9:10] = Types.u8.serialize(self.bitmap)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            position = Types.S8_24.deserialize(data[0:4])
            width = Types.S8_24.deserialize(data[4:8])
            characteristics = Types.LineCharacteristic.deserialize(data[8:9])
            bitmap = Types.u8.deserialize(data[9:10])
            return cls(position, width, characteristics, bitmap)

        @classmethod
        def expected_length(cls, source):
            return 10

    class LineSensorsRAW_8bit:
        """Struct type
        Line sensors raw

        LineSensorsRAW_8bit(
            raw: u8
        )

        Example JSON representation:
        {
            "raw": 0
        }"""
        data_width = 7

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, raw):
            self.raw = list([Types.u8(x) for x in raw])

        def __repr__(self):
            return f'LineSensorsRAW_8bit(raw={self.raw})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.raw == other.raw)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(7))
            buffer[0:7] = serialize_array(self.raw, Types.u8)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            raw = deserialize_array(Types.u8, data[0:7])
            return cls(raw)

        @classmethod
        def expected_length(cls, source):
            return 7

    class LineSensorsRAW_16bit:
        """Struct type
        Line sensors raw, purpose of which is to be used as reference values for line sensor calibration.

        LineSensorsRAW_16bit(
            raw: u16
        )

        Example JSON representation:
        {
            "raw": 0
        }"""
        data_width = 14

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, raw):
            self.raw = list([Types.u16(x) for x in raw])

        def __repr__(self):
            return f'LineSensorsRAW_16bit(raw={self.raw})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.raw == other.raw)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(14))
            buffer[0:14] = serialize_array(self.raw, Types.u16)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            raw = deserialize_array(Types.u16, data[0:14])
            return cls(raw)

        @classmethod
        def expected_length(cls, source):
            return 14

    class Line:
        """Struct type
        Line attributes and source data with timestamp.

        Line(
            normalized: u8,
            attributes: LineAttributes(
                position: S8_24,
                width: S8_24,
                characteristics: Bitfield<LineCharacteristic.LineOnLeft | LineCharacteristic.LineOnRight | LineCharacteristic.LineUnderAll>,
                bitmap: u8
            ),
            timestamp: time_t
        )

        Example JSON representation:
        {
            "normalized": 0,
            "attributes": {
                "position": 0.0,
                "width": 0.0,
                "characteristics": "LineUnderAll",
                "bitmap": 0
            },
            "timestamp": 0
        }"""
        data_width = 21

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, normalized, attributes, timestamp):
            self.normalized = list([Types.u8(x) for x in normalized])
            self.attributes = Types.LineAttributes(attributes)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'Line(normalized={self.normalized}, attributes={self.attributes}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.normalized == other.normalized) and (self.attributes == other.attributes) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(21))
            buffer[0:7] = serialize_array(self.normalized, Types.u8)
            buffer[7:17] = Types.LineAttributes.serialize(self.attributes)
            buffer[17:21] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            normalized = deserialize_array(Types.u8, data[0:7])
            attributes = Types.LineAttributes.deserialize(data[7:17])
            timestamp = Types.time_t.deserialize(data[17:21])
            return cls(normalized, attributes, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 21

    class LineWithRAW_8bit:
        """Struct type
        Line attributes and source data with timestamp.

        LineWithRAW_8bit(
            raw: u8,
            normalized: u8,
            attributes: LineAttributes(
                position: S8_24,
                width: S8_24,
                characteristics: Bitfield<LineCharacteristic.LineOnLeft | LineCharacteristic.LineOnRight | LineCharacteristic.LineUnderAll>,
                bitmap: u8
            ),
            timestamp: time_t
        )

        Example JSON representation:
        {
            "raw": 0,
            "normalized": 0,
            "attributes": {
                "position": 0.0,
                "width": 0.0,
                "characteristics": "LineUnderAll",
                "bitmap": 0
            },
            "timestamp": 0
        }"""
        data_width = 28

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, raw, normalized, attributes, timestamp):
            self.raw = list([Types.u8(x) for x in raw])
            self.normalized = list([Types.u8(x) for x in normalized])
            self.attributes = Types.LineAttributes(attributes)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'LineWithRAW_8bit(raw={self.raw}, normalized={self.normalized}, attributes={self.attributes}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.raw == other.raw) and (self.normalized == other.normalized) and (self.attributes == other.attributes) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(28))
            buffer[0:7] = serialize_array(self.raw, Types.u8)
            buffer[7:14] = serialize_array(self.normalized, Types.u8)
            buffer[14:24] = Types.LineAttributes.serialize(self.attributes)
            buffer[24:28] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            raw = deserialize_array(Types.u8, data[0:7])
            normalized = deserialize_array(Types.u8, data[7:14])
            attributes = Types.LineAttributes.deserialize(data[14:24])
            timestamp = Types.time_t.deserialize(data[24:28])
            return cls(raw, normalized, attributes, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 28

    class LineColor:
        """Struct type
        Line color under bot.

        LineColor(
            color: Enum<LineColorEnum.Black, LineColorEnum.Blue, LineColorEnum.Green, LineColorEnum.Red, LineColorEnum.Unknown>,
            lightSource: Enum<LightSource.Off, LightSource.On>,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "color": "Unknown",
            "lightSource": "On",
            "timestamp": 0
        }"""
        data_width = 6

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, color, lightSource, timestamp):
            self.color = Types.LineColorEnum(color)
            self.lightSource = Types.LightSource(lightSource)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'LineColor(color={self.color}, lightSource={self.lightSource}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.color == other.color) and (self.lightSource == other.lightSource) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(6))
            buffer[0:1] = Types.LineColorEnum.serialize(self.color)
            buffer[1:2] = Types.LightSource.serialize(self.lightSource)
            buffer[2:6] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            color = Types.LineColorEnum.deserialize(data[0:1])
            lightSource = Types.LightSource.deserialize(data[1:2])
            timestamp = Types.time_t.deserialize(data[2:6])
            return cls(color, lightSource, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 6

    class SurfaceColor:
        """Struct type
        Surface color under bot.

        SurfaceColor(
            color: Enum<SurfaceColorEnum.Black, SurfaceColorEnum.Blue, SurfaceColorEnum.Cyan, SurfaceColorEnum.Green, SurfaceColorEnum.Magenta, SurfaceColorEnum.Red, SurfaceColorEnum.Unknown, SurfaceColorEnum.White,
            SurfaceColorEnum.Yellow>,
            lightSource: Enum<LightSource.Off, LightSource.On>,
            counter: u16,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "color": "Yellow",
            "lightSource": "On",
            "counter": 0,
            "timestamp": 0
        }"""
        data_width = 8

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, color, lightSource, counter, timestamp):
            self.color = Types.SurfaceColorEnum(color)
            self.lightSource = Types.LightSource(lightSource)
            self.counter = Types.u16(counter)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'SurfaceColor(color={self.color}, lightSource={self.lightSource}, counter={self.counter}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.color == other.color) and (self.lightSource == other.lightSource) and (self.counter == other.counter) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(8))
            buffer[0:1] = Types.SurfaceColorEnum.serialize(self.color)
            buffer[1:2] = Types.LightSource.serialize(self.lightSource)
            buffer[2:4] = Types.u16.serialize(self.counter)
            buffer[4:8] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            color = Types.SurfaceColorEnum.deserialize(data[0:1])
            lightSource = Types.LightSource.deserialize(data[1:2])
            counter = Types.u16.deserialize(data[2:4])
            timestamp = Types.time_t.deserialize(data[4:8])
            return cls(color, lightSource, counter, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 8

    class Surface:
        """Struct type
        Surface type with timestapm.

        Surface(
            type: Enum<SurfaceType.Paper, SurfaceType.Screen, SurfaceType.Unknown>,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "type": "Unknown",
            "timestamp": 0
        }"""
        data_width = 5

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, type, timestamp):
            self.type = Types.SurfaceType(type)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'Surface(type={self.type}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.type == other.type) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(5))
            buffer[0:1] = Types.SurfaceType.serialize(self.type)
            buffer[1:5] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            type = Types.SurfaceType.deserialize(data[0:1])
            timestamp = Types.time_t.deserialize(data[1:5])
            return cls(type, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 5

    class PickupDetection:
        """Struct type
        Information about current surface presence with timestamp.

        PickupDetection(
            state: Enum<PickupDetectionEnum.OnSurface, PickupDetectionEnum.PickedUp>,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "state": "PickedUp",
            "timestamp": 0
        }"""
        data_width = 5

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, state, timestamp):
            self.state = Types.PickupDetectionEnum(state)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'PickupDetection(state={self.state}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.state == other.state) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(5))
            buffer[0:1] = Types.PickupDetectionEnum.serialize(self.state)
            buffer[1:5] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            state = Types.PickupDetectionEnum.deserialize(data[0:1])
            timestamp = Types.time_t.deserialize(data[1:5])
            return cls(state, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 5

    class PickupSensorRaw:
        """Struct type
        Value for analogue comparator.

        PickupSensorRaw(
            adcValue: u16,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "adcValue": 0,
            "timestamp": 0
        }"""
        data_width = 8

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, adcValue, timestamp):
            self.adcValue = list([Types.u16(x) for x in adcValue])
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'PickupSensorRaw(adcValue={self.adcValue}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.adcValue == other.adcValue) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(8))
            buffer[0:4] = serialize_array(self.adcValue, Types.u16)
            buffer[4:8] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            adcValue = deserialize_array(Types.u16, data[0:4])
            timestamp = Types.time_t.deserialize(data[4:8])
            return cls(adcValue, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 8

    class IRProximity:
        """Struct type
        Received IR signal strength from all sensors with timestamp.

        IRProximity(
            leftRear: u8,
            leftFront: u8,
            rightRear: u8,
            rightFront: u8,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "leftRear": 0,
            "leftFront": 0,
            "rightRear": 0,
            "rightFront": 0,
            "timestamp": 0
        }"""
        data_width = 8

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, leftRear, leftFront, rightRear, rightFront, timestamp):
            self.leftRear = Types.u8(leftRear)
            self.leftFront = Types.u8(leftFront)
            self.rightRear = Types.u8(rightRear)
            self.rightFront = Types.u8(rightFront)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'IRProximity(leftRear={self.leftRear}, leftFront={self.leftFront}, rightRear={self.rightRear}, rightFront={self.rightFront}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.leftRear == other.leftRear) and (self.leftFront == other.leftFront) and (self.rightRear == other.rightRear) and (self.rightFront == other.rightFront) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(8))
            buffer[0:1] = Types.u8.serialize(self.leftRear)
            buffer[1:2] = Types.u8.serialize(self.leftFront)
            buffer[2:3] = Types.u8.serialize(self.rightRear)
            buffer[3:4] = Types.u8.serialize(self.rightFront)
            buffer[4:8] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            leftRear = Types.u8.deserialize(data[0:1])
            leftFront = Types.u8.deserialize(data[1:2])
            rightRear = Types.u8.deserialize(data[2:3])
            rightFront = Types.u8.deserialize(data[3:4])
            timestamp = Types.time_t.deserialize(data[4:8])
            return cls(leftRear, leftFront, rightRear, rightFront, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 8

    class IRProximity_u16:
        """Struct type
        Received IR signal strength from all sensors with timestamp.

        IRProximity_u16(
            value: u16,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "value": 0,
            "timestamp": 0
        }"""
        data_width = 6

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, value, timestamp):
            self.value = Types.u16(value)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'IRProximity_u16(value={self.value}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.value == other.value) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(6))
            buffer[0:2] = Types.u16.serialize(self.value)
            buffer[2:6] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            value = Types.u16.deserialize(data[0:2])
            timestamp = Types.time_t.deserialize(data[2:6])
            return cls(value, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 6

    class IRMessage:
        """Struct type
        Received IR message with timestamp.

        IRMessage(
            message: u8,
            intensity: u8,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "message": 0,
            "intensity": 0,
            "timestamp": 0
        }"""
        data_width = 6

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, message, intensity, timestamp):
            self.message = Types.u8(message)
            self.intensity = Types.u8(intensity)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'IRMessage(message={self.message}, intensity={self.intensity}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message == other.message) and (self.intensity == other.intensity) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(6))
            buffer[0:1] = Types.u8.serialize(self.message)
            buffer[1:2] = Types.u8.serialize(self.intensity)
            buffer[2:6] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message = Types.u8.deserialize(data[0:1])
            intensity = Types.u8.deserialize(data[1:2])
            timestamp = Types.time_t.deserialize(data[2:6])
            return cls(message, intensity, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 6

    class IRMessageEmit:
        """Struct type
        IR emit channel.

        IRMessageEmit(
            message: u8,
            active: Enum<IRChannelEmitState.Off, IRChannelEmitState.On>
        )

        Example JSON representation:
        {
            "message": 0,
            "active": "On"
        }"""
        data_width = 2

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, message, active):
            self.message = Types.u8(message)
            self.active = Types.IRChannelEmitState(active)

        def __repr__(self):
            return f'IRMessageEmit(message={self.message}, active={self.active})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message == other.message) and (self.active == other.active)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(2))
            buffer[0:1] = Types.u8.serialize(self.message)
            buffer[1:2] = Types.IRChannelEmitState.serialize(self.active)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message = Types.u8.deserialize(data[0:1])
            active = Types.IRChannelEmitState.deserialize(data[1:2])
            return cls(message, active)

        @classmethod
        def expected_length(cls, source):
            return 2

    class RelativePosition:
        """Struct type
        Relative position based on encoders ticks.

        RelativePosition(
            originCounter: u8,
            x: S8_24,
            y: S8_24,
            angleX: S8_24,
            angleY: S8_24,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "originCounter": 0,
            "x": 0.0,
            "y": 0.0,
            "angleX": 0.0,
            "angleY": 0.0,
            "timestamp": 0
        }"""
        data_width = 21

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, originCounter, x, y, angleX, angleY, timestamp):
            self.originCounter = Types.u8(originCounter)
            self.x = Types.S8_24(x)
            self.y = Types.S8_24(y)
            self.angleX = Types.S8_24(angleX)
            self.angleY = Types.S8_24(angleY)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'RelativePosition(originCounter={self.originCounter}, x={self.x}, y={self.y}, angleX={self.angleX}, angleY={self.angleY}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.originCounter == other.originCounter) and (self.x == other.x) and (self.y == other.y) and (self.angleX == other.angleX) and (self.angleY == other.angleY) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(21))
            buffer[0:1] = Types.u8.serialize(self.originCounter)
            buffer[1:5] = Types.S8_24.serialize(self.x)
            buffer[5:9] = Types.S8_24.serialize(self.y)
            buffer[9:13] = Types.S8_24.serialize(self.angleX)
            buffer[13:17] = Types.S8_24.serialize(self.angleY)
            buffer[17:21] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            originCounter = Types.u8.deserialize(data[0:1])
            x = Types.S8_24.deserialize(data[1:5])
            y = Types.S8_24.deserialize(data[5:9])
            angleX = Types.S8_24.deserialize(data[9:13])
            angleY = Types.S8_24.deserialize(data[13:17])
            timestamp = Types.time_t.deserialize(data[17:21])
            return cls(originCounter, x, y, angleX, angleY, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 21

    class WheelsEncoder:
        """Struct type
        Wheels encoder tick counter.

        WheelsEncoder(
            leftWheel: u32,
            rightWheel: u32,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "leftWheel": 0,
            "rightWheel": 0,
            "timestamp": 0
        }"""
        data_width = 12

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, leftWheel, rightWheel, timestamp):
            self.leftWheel = Types.u32(leftWheel)
            self.rightWheel = Types.u32(rightWheel)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'WheelsEncoder(leftWheel={self.leftWheel}, rightWheel={self.rightWheel}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.leftWheel == other.leftWheel) and (self.rightWheel == other.rightWheel) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(12))
            buffer[0:4] = Types.u32.serialize(self.leftWheel)
            buffer[4:8] = Types.u32.serialize(self.rightWheel)
            buffer[8:12] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            leftWheel = Types.u32.deserialize(data[0:4])
            rightWheel = Types.u32.deserialize(data[4:8])
            timestamp = Types.time_t.deserialize(data[8:12])
            return cls(leftWheel, rightWheel, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 12

    class ChargerState:
        """Struct type
        Charger state as connected or disconnected.

        ChargerState(
            state: Enum<ChargerStateEnum.Connected, ChargerStateEnum.Disconnected, ChargerStateEnum.LowPower>,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "state": "LowPower",
            "timestamp": 0
        }"""
        data_width = 5

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, state, timestamp):
            self.state = Types.ChargerStateEnum(state)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'ChargerState(state={self.state}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.state == other.state) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(5))
            buffer[0:1] = Types.ChargerStateEnum.serialize(self.state)
            buffer[1:5] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            state = Types.ChargerStateEnum.deserialize(data[0:1])
            timestamp = Types.time_t.deserialize(data[1:5])
            return cls(state, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 5

    class ColorCode:
        """Struct type
        Recognized color code on a line.

        ColorCode(
            code: u32,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "code": 0,
            "timestamp": 0
        }"""
        data_width = 8

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, code, timestamp):
            self.code = Types.u32(code)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'ColorCode(code={self.code}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.code == other.code) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(8))
            buffer[0:4] = Types.u32.serialize(self.code)
            buffer[4:8] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            code = Types.u32.deserialize(data[0:4])
            timestamp = Types.time_t.deserialize(data[4:8])
            return cls(code, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 8

    class Battery:
        """Struct type
        Battery information as voltage, remaining power etc.

        Battery(
            voltage: u16,
            remainingPower: u8,
            fields: Bitfield<BatteryFieldsEnum.Charging>,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "voltage": 0,
            "remainingPower": 0,
            "fields": "Charging",
            "timestamp": 0
        }"""
        data_width = 8

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, voltage, remainingPower, fields, timestamp):
            self.voltage = Types.u16(voltage)
            self.remainingPower = Types.u8(remainingPower)
            self.fields = Types.BatteryFieldsEnum(fields)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'Battery(voltage={self.voltage}, remainingPower={self.remainingPower}, fields={self.fields}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.voltage == other.voltage) and (self.remainingPower == other.remainingPower) and (self.fields == other.fields) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(8))
            buffer[0:2] = Types.u16.serialize(self.voltage)
            buffer[2:3] = Types.u8.serialize(self.remainingPower)
            buffer[3:4] = Types.BatteryFieldsEnum.serialize(self.fields)
            buffer[4:8] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            voltage = Types.u16.deserialize(data[0:2])
            remainingPower = Types.u8.deserialize(data[2:3])
            fields = Types.BatteryFieldsEnum.deserialize(data[3:4])
            timestamp = Types.time_t.deserialize(data[4:8])
            return cls(voltage, remainingPower, fields, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 8

    class Button:
        """Struct type
        The last button press type.

        Button(
            press: Enum<PressType.Double, PressType.Long, PressType.Max, PressType.Release, PressType.Short>,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "press": "Short",
            "timestamp": 0
        }"""
        data_width = 5

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, press, timestamp):
            self.press = Types.PressType(press)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'Button(press={self.press}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.press == other.press) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(5))
            buffer[0:1] = Types.PressType.serialize(self.press)
            buffer[1:5] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            press = Types.PressType.deserialize(data[0:1])
            timestamp = Types.time_t.deserialize(data[1:5])
            return cls(press, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 5

    class TaskInformation:
        """Struct type
        Task information.

        TaskInformation(
            name: c8,
            priority: u8,
            remainingStack: u32
        )

        Example JSON representation:
        {
            "name": "...",
            "priority": 0,
            "remainingStack": 0
        }"""
        data_width = 13

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, name, priority, remainingStack):
            self.name = Types.c8(name)
            self.priority = Types.u8(priority)
            self.remainingStack = Types.u32(remainingStack)

        def __repr__(self):
            return f'TaskInformation(name={self.name}, priority={self.priority}, remainingStack={self.remainingStack})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.name == other.name) and (self.priority == other.priority) and (self.remainingStack == other.remainingStack)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(13))
            buffer[0:8] = serialize_array(self.name, Types.c8)
            buffer[8:9] = Types.u8.serialize(self.priority)
            buffer[9:13] = Types.u32.serialize(self.remainingStack)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            name = deserialize_array(Types.c8, data[0:8])
            priority = Types.u8.deserialize(data[8:9])
            remainingStack = Types.u32.deserialize(data[9:13])
            return cls(name, priority, remainingStack)

        @classmethod
        def expected_length(cls, source):
            return 13

    class PIDParameters:
        """Struct type
        PID controller parameters.

        PIDParameters(
            P: S8_24,
            I: S8_24,
            D: S8_24
        )

        Example JSON representation:
        {
            "P": 0.0,
            "I": 0.0,
            "D": 0.0
        }"""
        data_width = 12

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, P, I, D):
            self.P = Types.S8_24(P)
            self.I = Types.S8_24(I)
            self.D = Types.S8_24(D)

        def __repr__(self):
            return f'PIDParameters(P={self.P}, I={self.I}, D={self.D})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.P == other.P) and (self.I == other.I) and (self.D == other.D)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(12))
            buffer[0:4] = Types.S8_24.serialize(self.P)
            buffer[4:8] = Types.S8_24.serialize(self.I)
            buffer[8:12] = Types.S8_24.serialize(self.D)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            P = Types.S8_24.deserialize(data[0:4])
            I = Types.S8_24.deserialize(data[4:8])
            D = Types.S8_24.deserialize(data[8:12])
            return cls(P, I, D)

        @classmethod
        def expected_length(cls, source):
            return 12

    class ExternalFlashInformation:
        """Struct type
        External flash information as manufacturer or size.

        ExternalFlashInformation(
            manufacturer: u8,
            type: u8,
            capacity: u32,
            chipCount: u8
        )

        Example JSON representation:
        {
            "manufacturer": 0,
            "type": 0,
            "capacity": 0,
            "chipCount": 0
        }"""
        data_width = 7

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, manufacturer, type, capacity, chipCount):
            self.manufacturer = Types.u8(manufacturer)
            self.type = Types.u8(type)
            self.capacity = Types.u32(capacity)
            self.chipCount = Types.u8(chipCount)

        def __repr__(self):
            return f'ExternalFlashInformation(manufacturer={self.manufacturer}, type={self.type}, capacity={self.capacity}, chipCount={self.chipCount})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.manufacturer == other.manufacturer) and (self.type == other.type) and (self.capacity == other.capacity) and (self.chipCount == other.chipCount)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(7))
            buffer[0:1] = Types.u8.serialize(self.manufacturer)
            buffer[1:2] = Types.u8.serialize(self.type)
            buffer[2:6] = Types.u32.serialize(self.capacity)
            buffer[6:7] = Types.u8.serialize(self.chipCount)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            manufacturer = Types.u8.deserialize(data[0:1])
            type = Types.u8.deserialize(data[1:2])
            capacity = Types.u32.deserialize(data[2:6])
            chipCount = Types.u8.deserialize(data[6:7])
            return cls(manufacturer, type, capacity, chipCount)

        @classmethod
        def expected_length(cls, source):
            return 7

    class SensorRange:
        """Struct type
        Sensor range.

        SensorRange(
            min: u16,
            max: u16
        )

        Example JSON representation:
        {
            "min": 0,
            "max": 0
        }"""
        data_width = 4

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, min, max):
            self.min = Types.u16(min)
            self.max = Types.u16(max)

        def __repr__(self):
            return f'SensorRange(min={self.min}, max={self.max})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.min == other.min) and (self.max == other.max)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(4))
            buffer[0:2] = Types.u16.serialize(self.min)
            buffer[2:4] = Types.u16.serialize(self.max)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            min = Types.u16.deserialize(data[0:2])
            max = Types.u16.deserialize(data[2:4])
            return cls(min, max)

        @classmethod
        def expected_length(cls, source):
            return 4

    class UnsignedRange:
        """Struct type
        Unsigned range

        UnsignedRange(
            min: u16,
            max: u16
        )

        Example JSON representation:
        {
            "min": 0,
            "max": 0
        }"""
        data_width = 4

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, min, max):
            self.min = Types.u16(min)
            self.max = Types.u16(max)

        def __repr__(self):
            return f'UnsignedRange(min={self.min}, max={self.max})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.min == other.min) and (self.max == other.max)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(4))
            buffer[0:2] = Types.u16.serialize(self.min)
            buffer[2:4] = Types.u16.serialize(self.max)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            min = Types.u16.deserialize(data[0:2])
            max = Types.u16.deserialize(data[2:4])
            return cls(min, max)

        @classmethod
        def expected_length(cls, source):
            return 4

    class S8_24Range:
        """Struct type
        S8_24 range

        S8_24Range(
            min: S8_24,
            max: S8_24
        )

        Example JSON representation:
        {
            "min": 0.0,
            "max": 0.0
        }"""
        data_width = 8

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, min, max):
            self.min = Types.S8_24(min)
            self.max = Types.S8_24(max)

        def __repr__(self):
            return f'S8_24Range(min={self.min}, max={self.max})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.min == other.min) and (self.max == other.max)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(8))
            buffer[0:4] = Types.S8_24.serialize(self.min)
            buffer[4:8] = Types.S8_24.serialize(self.max)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            min = Types.S8_24.deserialize(data[0:4])
            max = Types.S8_24.deserialize(data[4:8])
            return cls(min, max)

        @classmethod
        def expected_length(cls, source):
            return 8

    class LineSensorsCalibration:
        """Struct type
        Line sensors dynamic range.

        LineSensorsCalibration(
            sensorsRange: SensorRange(
                min: u16,
                max: u16
            )
        )

        Example JSON representation:
        {
            "sensorsRange": {
                "min": 0,
                "max": 0
            }
        }"""
        data_width = 28

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, sensorsRange):
            self.sensorsRange = list([Types.SensorRange(x) for x in sensorsRange])

        def __repr__(self):
            return f'LineSensorsCalibration(sensorsRange={self.sensorsRange})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.sensorsRange == other.sensorsRange)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(28))
            buffer[0:28] = serialize_array(self.sensorsRange, Types.SensorRange)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            sensorsRange = deserialize_array(Types.SensorRange, data[0:28])
            return cls(sensorsRange)

        @classmethod
        def expected_length(cls, source):
            return 28

    class ColorSensorCalibration:
        """Struct type
        Color sensor channels dynamic range.

        ColorSensorCalibration(
            redRange: SensorRange(
                min: u16,
                max: u16
            ),
            greenRange: SensorRange(
                min: u16,
                max: u16
            ),
            blueRange: SensorRange(
                min: u16,
                max: u16
            )
        )

        Example JSON representation:
        {
            "redRange": {
                "min": 0,
                "max": 0
            },
            "greenRange": {
                "min": 0,
                "max": 0
            },
            "blueRange": {
                "min": 0,
                "max": 0
            }
        }"""
        data_width = 12

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, redRange, greenRange, blueRange):
            self.redRange = Types.SensorRange(redRange)
            self.greenRange = Types.SensorRange(greenRange)
            self.blueRange = Types.SensorRange(blueRange)

        def __repr__(self):
            return f'ColorSensorCalibration(redRange={self.redRange}, greenRange={self.greenRange}, blueRange={self.blueRange})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.redRange == other.redRange) and (self.greenRange == other.greenRange) and (self.blueRange == other.blueRange)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(12))
            buffer[0:4] = Types.SensorRange.serialize(self.redRange)
            buffer[4:8] = Types.SensorRange.serialize(self.greenRange)
            buffer[8:12] = Types.SensorRange.serialize(self.blueRange)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            redRange = Types.SensorRange.deserialize(data[0:4])
            greenRange = Types.SensorRange.deserialize(data[4:8])
            blueRange = Types.SensorRange.deserialize(data[8:12])
            return cls(redRange, greenRange, blueRange)

        @classmethod
        def expected_length(cls, source):
            return 12

    class EncodersCalibration:
        """Struct type
        Encoders calibration.

        EncodersCalibration(
            leftThreshold: u8,
            rightThreshold: u8
        )

        Example JSON representation:
        {
            "leftThreshold": 0,
            "rightThreshold": 0
        }"""
        data_width = 2

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, leftThreshold, rightThreshold):
            self.leftThreshold = Types.u8(leftThreshold)
            self.rightThreshold = Types.u8(rightThreshold)

        def __repr__(self):
            return f'EncodersCalibration(leftThreshold={self.leftThreshold}, rightThreshold={self.rightThreshold})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.leftThreshold == other.leftThreshold) and (self.rightThreshold == other.rightThreshold)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(2))
            buffer[0:1] = Types.u8.serialize(self.leftThreshold)
            buffer[1:2] = Types.u8.serialize(self.rightThreshold)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            leftThreshold = Types.u8.deserialize(data[0:1])
            rightThreshold = Types.u8.deserialize(data[1:2])
            return cls(leftThreshold, rightThreshold)

        @classmethod
        def expected_length(cls, source):
            return 2

    class WheelSpeed:
        """Struct type
        Wheel speed.

        WheelSpeed(
            speed: S8_24,
            approximated: u8
        )

        Example JSON representation:
        {
            "speed": 0.0,
            "approximated": 0
        }"""
        data_width = 5

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, speed, approximated):
            self.speed = Types.S8_24(speed)
            self.approximated = Types.u8(approximated)

        def __repr__(self):
            return f'WheelSpeed(speed={self.speed}, approximated={self.approximated})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.speed == other.speed) and (self.approximated == other.approximated)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(5))
            buffer[0:4] = Types.S8_24.serialize(self.speed)
            buffer[4:5] = Types.u8.serialize(self.approximated)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            speed = Types.S8_24.deserialize(data[0:4])
            approximated = Types.u8.deserialize(data[4:5])
            return cls(speed, approximated)

        @classmethod
        def expected_length(cls, source):
            return 5

    class WheelsSpeed:
        """Struct type
        Wheels speed.

        WheelsSpeed(
            speed: WheelSpeed(
                speed: S8_24,
                approximated: u8
            ),
            timestamp: time_t
        )

        Example JSON representation:
        {
            "speed": {
                "speed": 0.0,
                "approximated": 0
            },
            "timestamp": 0
        }"""
        data_width = 14

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, speed, timestamp):
            self.speed = list([Types.WheelSpeed(x) for x in speed])
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'WheelsSpeed(speed={self.speed}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.speed == other.speed) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(14))
            buffer[0:10] = serialize_array(self.speed, Types.WheelSpeed)
            buffer[10:14] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            speed = deserialize_array(Types.WheelSpeed, data[0:10])
            timestamp = Types.time_t.deserialize(data[10:14])
            return cls(speed, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 14

    class CalibrationStatusLineSensor:
        """Struct type
        Line sensor calibration status.

        CalibrationStatusLineSensor(
            status: Enum<CalibrationStatus.Invalid, CalibrationStatus.Valid>,
            cells: Bitfield<CalibrationRangeStatus.DifferenceTooHigh | CalibrationRangeStatus.DifferenceTooLow | CalibrationRangeStatus.LowerBoundCrossed | CalibrationRangeStatus.UpperBoundCrossed>,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "status": "Valid",
            "cells": "UpperBoundCrossed",
            "timestamp": 0
        }"""
        data_width = 12

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, status, cells, timestamp):
            self.status = Types.CalibrationStatus(status)
            self.cells = list([Types.CalibrationRangeStatus(x) for x in cells])
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'CalibrationStatusLineSensor(status={self.status}, cells={self.cells}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.status == other.status) and (self.cells == other.cells) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(12))
            buffer[0:1] = Types.CalibrationStatus.serialize(self.status)
            buffer[1:8] = serialize_array(self.cells, Types.CalibrationRangeStatus)
            buffer[8:12] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            status = Types.CalibrationStatus.deserialize(data[0:1])
            cells = deserialize_array(Types.CalibrationRangeStatus, data[1:8])
            timestamp = Types.time_t.deserialize(data[8:12])
            return cls(status, cells, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 12

    class CalibrationStatusColorSensor:
        """Struct type
        Line sensor calibration status.

        CalibrationStatusColorSensor(
            status: Enum<CalibrationStatus.Invalid, CalibrationStatus.Valid>,
            red: Bitfield<CalibrationRangeStatus.DifferenceTooHigh | CalibrationRangeStatus.DifferenceTooLow | CalibrationRangeStatus.LowerBoundCrossed | CalibrationRangeStatus.UpperBoundCrossed>,
            green: Bitfield<CalibrationRangeStatus.DifferenceTooHigh | CalibrationRangeStatus.DifferenceTooLow | CalibrationRangeStatus.LowerBoundCrossed | CalibrationRangeStatus.UpperBoundCrossed>,
            blue: Bitfield<CalibrationRangeStatus.DifferenceTooHigh | CalibrationRangeStatus.DifferenceTooLow | CalibrationRangeStatus.LowerBoundCrossed | CalibrationRangeStatus.UpperBoundCrossed>,
            timestamp: time_t
        )

        Example JSON representation:
        {
            "status": "Valid",
            "red": "UpperBoundCrossed",
            "green": "UpperBoundCrossed",
            "blue": "UpperBoundCrossed",
            "timestamp": 0
        }"""
        data_width = 8

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, status, red, green, blue, timestamp):
            self.status = Types.CalibrationStatus(status)
            self.red = Types.CalibrationRangeStatus(red)
            self.green = Types.CalibrationRangeStatus(green)
            self.blue = Types.CalibrationRangeStatus(blue)
            self.timestamp = Types.time_t(timestamp)

        def __repr__(self):
            return f'CalibrationStatusColorSensor(status={self.status}, red={self.red}, green={self.green}, blue={self.blue}, timestamp={self.timestamp})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.status == other.status) and (self.red == other.red) and (self.green == other.green) and (self.blue == other.blue) and (self.timestamp == other.timestamp)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(8))
            buffer[0:1] = Types.CalibrationStatus.serialize(self.status)
            buffer[1:2] = Types.CalibrationRangeStatus.serialize(self.red)
            buffer[2:3] = Types.CalibrationRangeStatus.serialize(self.green)
            buffer[3:4] = Types.CalibrationRangeStatus.serialize(self.blue)
            buffer[4:8] = Types.time_t.serialize(self.timestamp)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            status = Types.CalibrationStatus.deserialize(data[0:1])
            red = Types.CalibrationRangeStatus.deserialize(data[1:2])
            green = Types.CalibrationRangeStatus.deserialize(data[2:3])
            blue = Types.CalibrationRangeStatus.deserialize(data[3:4])
            timestamp = Types.time_t.deserialize(data[4:8])
            return cls(status, red, green, blue, timestamp)

        @classmethod
        def expected_length(cls, source):
            return 8

    class BoardsConfiguration:
        """Struct type
        Boards configuration describes jot15 hw combination. It is used to know what parts are present.

        BoardsConfiguration(
            ledStrip: u8,
            sensorBoard: u8,
            flexStrip: u8,
            bleChip: u8,
            productID: u8
        )

        Example JSON representation:
        {
            "ledStrip": 0,
            "sensorBoard": 0,
            "flexStrip": 0,
            "bleChip": 0,
            "productID": 0
        }"""
        data_width = 5

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, ledStrip, sensorBoard, flexStrip, bleChip, productID):
            self.ledStrip = Types.u8(ledStrip)
            self.sensorBoard = Types.u8(sensorBoard)
            self.flexStrip = Types.u8(flexStrip)
            self.bleChip = Types.u8(bleChip)
            self.productID = Types.u8(productID)

        def __repr__(self):
            return f'BoardsConfiguration(ledStrip={self.ledStrip}, sensorBoard={self.sensorBoard}, flexStrip={self.flexStrip}, bleChip={self.bleChip}, productID={self.productID})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.ledStrip == other.ledStrip) and (self.sensorBoard == other.sensorBoard) and (self.flexStrip == other.flexStrip) and (self.bleChip == other.bleChip) and (self.productID == other.productID)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(5))
            buffer[0:1] = Types.u8.serialize(self.ledStrip)
            buffer[1:2] = Types.u8.serialize(self.sensorBoard)
            buffer[2:3] = Types.u8.serialize(self.flexStrip)
            buffer[3:4] = Types.u8.serialize(self.bleChip)
            buffer[4:5] = Types.u8.serialize(self.productID)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            ledStrip = Types.u8.deserialize(data[0:1])
            sensorBoard = Types.u8.deserialize(data[1:2])
            flexStrip = Types.u8.deserialize(data[2:3])
            bleChip = Types.u8.deserialize(data[3:4])
            productID = Types.u8.deserialize(data[4:5])
            return cls(ledStrip, sensorBoard, flexStrip, bleChip, productID)

        @classmethod
        def expected_length(cls, source):
            return 5

    class DifferentialGeometry:
        """Struct type
        Differential chassis geometry. It allows user to do some transformations like conversion from forward velocity to angular etc.

        DifferentialGeometry(
            axleTrack: S8_24,
            ticksPerMeter: i32,
            ticksPerRad: i32
        )

        Example JSON representation:
        {
            "axleTrack": 0.0,
            "ticksPerMeter": 0,
            "ticksPerRad": 0
        }"""
        data_width = 12

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, axleTrack, ticksPerMeter, ticksPerRad):
            self.axleTrack = Types.S8_24(axleTrack)
            self.ticksPerMeter = Types.i32(ticksPerMeter)
            self.ticksPerRad = Types.i32(ticksPerRad)

        def __repr__(self):
            return f'DifferentialGeometry(axleTrack={self.axleTrack}, ticksPerMeter={self.ticksPerMeter}, ticksPerRad={self.ticksPerRad})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.axleTrack == other.axleTrack) and (self.ticksPerMeter == other.ticksPerMeter) and (self.ticksPerRad == other.ticksPerRad)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(12))
            buffer[0:4] = Types.S8_24.serialize(self.axleTrack)
            buffer[4:8] = Types.i32.serialize(self.ticksPerMeter)
            buffer[8:12] = Types.i32.serialize(self.ticksPerRad)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            axleTrack = Types.S8_24.deserialize(data[0:4])
            ticksPerMeter = Types.i32.deserialize(data[4:8])
            ticksPerRad = Types.i32.deserialize(data[8:12])
            return cls(axleTrack, ticksPerMeter, ticksPerRad)

        @classmethod
        def expected_length(cls, source):
            return 12

    class LineSensorGeometry:
        """Struct type
        Line sensor geometry.

        LineSensorGeometry(
            slitSize: S8_24,
            slitCount: u32,
            x: S8_24,
            y: S8_24
        )

        Example JSON representation:
        {
            "slitSize": 0.0,
            "slitCount": 0,
            "x": 0.0,
            "y": 0.0
        }"""
        data_width = 16

        @classmethod
        def get_data_width(cls) -> int:
            return cls.data_width

        def __init__(self, slitSize, slitCount, x, y):
            self.slitSize = Types.S8_24(slitSize)
            self.slitCount = Types.u32(slitCount)
            self.x = Types.S8_24(x)
            self.y = Types.S8_24(y)

        def __repr__(self):
            return f'LineSensorGeometry(slitSize={self.slitSize}, slitCount={self.slitCount}, x={self.x}, y={self.y})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.slitSize == other.slitSize) and (self.slitCount == other.slitCount) and (self.x == other.x) and (self.y == other.y)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(16))
            buffer[0:4] = Types.S8_24.serialize(self.slitSize)
            buffer[4:8] = Types.u32.serialize(self.slitCount)
            buffer[8:12] = Types.S8_24.serialize(self.x)
            buffer[12:16] = Types.S8_24.serialize(self.y)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            slitSize = Types.S8_24.deserialize(data[0:4])
            slitCount = Types.u32.deserialize(data[4:8])
            x = Types.S8_24.deserialize(data[8:12])
            y = Types.S8_24.deserialize(data[12:16])
            return cls(slitSize, slitCount, x, y)

        @classmethod
        def expected_length(cls, source):
            return 16


class PacketTypes:

    @classmethod
    def get_packet_type_by_message_id(cls, id: int) -> typing.Type[_PacketType] | None:
        type_by_id: dict[int, typing.Type[_PacketType]] = {
            1: PacketTypes.PacketRequest_MemRead,
            2: PacketTypes.PacketResponse_MemRead,
            3: PacketTypes.PacketRequest_MemWrite,
            4: PacketTypes.PacketResponse_MemWrite,
            100: PacketTypes.PacketRequest_MoveStraight,
            101: PacketTypes.PacketResponse_MoveStraight,
            102: PacketTypes.PacketRequest_Rotate,
            103: PacketTypes.PacketResponse_Rotate,
            104: PacketTypes.PacketRequest_Velocity,
            105: PacketTypes.PacketResponse_Velocity,
            106: PacketTypes.PacketRequest_LineNavigation,
            107: PacketTypes.PacketResponse_LineNavigation,
            120: PacketTypes.PacketRequest_StopExecution,
            121: PacketTypes.PacketResponse_StopExecution,
            122: PacketTypes.PacketRequest_WatcherSetup,
            123: PacketTypes.PacketResponse_WatcherSetup,
            124: PacketTypes.PacketRequest_WatcherRegionSetup,
            125: PacketTypes.PacketResponse_WatcherRegionSetup,
            108: PacketTypes.PacketRequest_ExecuteFile,
            109: PacketTypes.PacketResponse_ExecuteFile,
            110: PacketTypes.PacketRequest_SetLED,
            111: PacketTypes.PacketResponse_SetLED,
            112: PacketTypes.PacketRequest_Calibrate,
            113: PacketTypes.PacketResponse_Calibrate,
            114: PacketTypes.PacketRequest_TurnOff,
            115: PacketTypes.PacketResponse_TurnOff,
            116: PacketTypes.PacketRequest_UpdateFirmware,
            117: PacketTypes.PacketResponse_UpdateFirmware,
            118: PacketTypes.PacketRequest_PlayTone,
            119: PacketTypes.PacketResponse_PlayTone,
            126: PacketTypes.PacketRequest_LongRPCExtensionExecute,
            127: PacketTypes.PacketResponse_LongRPCExtensionExecute,
            130: PacketTypes.PacketRequest_SetRNGSeed,
            131: PacketTypes.PacketResponse_SetRNGSeed,
            132: PacketTypes.PacketRequest_SensorsLogging,
            133: PacketTypes.PacketResponse_SensorsLogging,
            134: PacketTypes.PacketRequest_MemoryTest,
            135: PacketTypes.PacketResponse_MemoryTest,
            256: PacketTypes.PacketEvent_PreciseMovementExecutionUpdate,
            257: PacketTypes.PacketEvent_LineNavigationExecutionUpdate,
            266: PacketTypes.PacketEvent_VelocityExecutionState,
            260: PacketTypes.PacketEvent_WatcherDirty,
            263: PacketTypes.PacketEvent_ModuleError,
            258: PacketTypes.PacketEvent_Shutdown,
            259: PacketTypes.PacketEvent_AudioExecutionState,
            261: PacketTypes.PacketEvent_CalibrationStatus,
            262: PacketTypes.PacketEvent_MemoryTestStatus,
            264: PacketTypes.PacketEvent_VirtualMachineExecutionState,
            265: PacketTypes.PacketEvent_SensorsLoggingExecutionUpdate,
        }
        return type_by_id.get(id, None)

    class PacketRequest_MemRead:
        message_id = Types.u16(1)

        def __init__(self, addr, length):
            self.addr = Types.addr_t(addr)
            self.length = Types.size_t(length)

        def __repr__(self):
            return f'PacketRequest_MemRead(message_id={self.message_id}, addr={self.addr}, length={self.length})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.addr == other.addr) and (self.length == other.length)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(8))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.addr_t.serialize(self.addr)
            buffer[6:8] = Types.size_t.serialize(self.length)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(1)
            addr = Types.addr_t.deserialize(data[2:6])
            length = Types.size_t.deserialize(data[6:8])
            return cls(addr, length)

        @classmethod
        def expected_length(cls, source):
            return 8

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return tuple()

    class PacketResponse_MemRead:
        message_id = Types.u16(2)

        def __init__(self, result, length, data):
            self.result = Types.IOResult(result)
            self.length = Types.size_t(length)
            self.data = list([Types.u8(x) for x in data])

        def __repr__(self):
            return f'PacketResponse_MemRead(message_id={self.message_id}, result={self.result}, length={self.length}, data={self.data})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.result == other.result) and (self.length == other.length) and (self.data == other.data)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            vla_data = serialize_array(self.data, Types.u8)
            assert len(vla_data) == getattr(self, 'length')
            buffer = memoryview(bytearray(5+len(vla_data)))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.IOResult.serialize(self.result)
            buffer[3:5] = Types.size_t.serialize(self.length)
            buffer[5:5+len(vla_data)] = serialize_array(self.data, Types.u8)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(2)
            result = Types.IOResult.deserialize(data[2:3])
            length = Types.size_t.deserialize(data[3:5])
            data = deserialize_array(Types.u8, data[5:])
            return cls(result, length, data)

        @classmethod
        def expected_length(cls, source):
            return 5 + getattr(source, 'length', 0)

        def is_response_to(self, request: _PacketType) -> bool:
            return isinstance(request, PacketTypes.PacketRequest_MemRead)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketRequest_MemWrite:
        message_id = Types.u16(3)

        def __init__(self, addr, length, data):
            self.addr = Types.addr_t(addr)
            self.length = Types.size_t(length)
            self.data = list([Types.u8(x) for x in data])

        def __repr__(self):
            return f'PacketRequest_MemWrite(message_id={self.message_id}, addr={self.addr}, length={self.length}, data={self.data})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.addr == other.addr) and (self.length == other.length) and (self.data == other.data)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            vla_data = serialize_array(self.data, Types.u8)
            assert len(vla_data) == getattr(self, 'length')
            buffer = memoryview(bytearray(8+len(vla_data)))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.addr_t.serialize(self.addr)
            buffer[6:8] = Types.size_t.serialize(self.length)
            buffer[8:8+len(vla_data)] = serialize_array(self.data, Types.u8)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(3)
            addr = Types.addr_t.deserialize(data[2:6])
            length = Types.size_t.deserialize(data[6:8])
            data = deserialize_array(Types.u8, data[8:])
            return cls(addr, length, data)

        @classmethod
        def expected_length(cls, source):
            return 8 + getattr(source, 'length', 0)

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return tuple()

    class PacketResponse_MemWrite:
        message_id = Types.u16(4)

        def __init__(self, result):
            self.result = Types.IOResult(result)

        def __repr__(self):
            return f'PacketResponse_MemWrite(message_id={self.message_id}, result={self.result})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.result == other.result)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(3))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.IOResult.serialize(self.result)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(4)
            result = Types.IOResult.deserialize(data[2:3])
            return cls(result)

        @classmethod
        def expected_length(cls, source):
            return 3

        def is_response_to(self, request: _PacketType) -> bool:
            return isinstance(request, PacketTypes.PacketRequest_MemWrite)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketRequest_MoveStraight:
        message_id = Types.u16(100)

        def __init__(self, requestId, distance, speed):
            self.requestId = Types.RequestID(requestId)
            self.distance = Types.S8_24(distance)
            self.speed = Types.S8_24(speed)

        def __repr__(self):
            return f'PacketRequest_MoveStraight(message_id={self.message_id}, requestId={self.requestId}, distance={self.distance}, speed={self.speed})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId) and (self.distance == other.distance) and (self.speed == other.speed)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(14))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            buffer[6:10] = Types.S8_24.serialize(self.distance)
            buffer[10:14] = Types.S8_24.serialize(self.speed)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(100)
            requestId = Types.RequestID.deserialize(data[2:6])
            distance = Types.S8_24.deserialize(data[6:10])
            speed = Types.S8_24.deserialize(data[10:14])
            return cls(requestId, distance, speed)

        @classmethod
        def expected_length(cls, source):
            return 14

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return PacketTypes.PacketEvent_PreciseMovementExecutionUpdate, 

    class PacketResponse_MoveStraight:
        message_id = Types.u16(101)

        def __init__(self, requestId):
            self.requestId = Types.RequestID(requestId)

        def __repr__(self):
            return f'PacketResponse_MoveStraight(message_id={self.message_id}, requestId={self.requestId})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(6))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(101)
            requestId = Types.RequestID.deserialize(data[2:6])
            return cls(requestId)

        @classmethod
        def expected_length(cls, source):
            return 6

        def is_response_to(self, request: _PacketType) -> bool:
            if not hasattr(request, 'requestId'):
                return False
            if request.requestId != self.requestId:
                return False
            return isinstance(request, PacketTypes.PacketRequest_MoveStraight)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketRequest_Rotate:
        message_id = Types.u16(102)

        def __init__(self, requestId, angle, speed):
            self.requestId = Types.RequestID(requestId)
            self.angle = Types.S8_24(angle)
            self.speed = Types.S8_24(speed)

        def __repr__(self):
            return f'PacketRequest_Rotate(message_id={self.message_id}, requestId={self.requestId}, angle={self.angle}, speed={self.speed})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId) and (self.angle == other.angle) and (self.speed == other.speed)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(14))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            buffer[6:10] = Types.S8_24.serialize(self.angle)
            buffer[10:14] = Types.S8_24.serialize(self.speed)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(102)
            requestId = Types.RequestID.deserialize(data[2:6])
            angle = Types.S8_24.deserialize(data[6:10])
            speed = Types.S8_24.deserialize(data[10:14])
            return cls(requestId, angle, speed)

        @classmethod
        def expected_length(cls, source):
            return 14

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return PacketTypes.PacketEvent_PreciseMovementExecutionUpdate, 

    class PacketResponse_Rotate:
        message_id = Types.u16(103)

        def __init__(self, requestId):
            self.requestId = Types.RequestID(requestId)

        def __repr__(self):
            return f'PacketResponse_Rotate(message_id={self.message_id}, requestId={self.requestId})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(6))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(103)
            requestId = Types.RequestID.deserialize(data[2:6])
            return cls(requestId)

        @classmethod
        def expected_length(cls, source):
            return 6

        def is_response_to(self, request: _PacketType) -> bool:
            if not hasattr(request, 'requestId'):
                return False
            if request.requestId != self.requestId:
                return False
            return isinstance(request, PacketTypes.PacketRequest_Rotate)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketRequest_Velocity:
        message_id = Types.u16(104)

        def __init__(self, requestId, linearSpeed, rotationSpeed, durationTime):
            self.requestId = Types.RequestID(requestId)
            self.linearSpeed = Types.S8_24(linearSpeed)
            self.rotationSpeed = Types.S8_24(rotationSpeed)
            self.durationTime = Types.i32(durationTime)

        def __repr__(self):
            return f'PacketRequest_Velocity(message_id={self.message_id}, requestId={self.requestId}, linearSpeed={self.linearSpeed}, rotationSpeed={self.rotationSpeed}, durationTime={self.durationTime})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId) and (self.linearSpeed == other.linearSpeed) and (self.rotationSpeed == other.rotationSpeed) and (self.durationTime == other.durationTime)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(18))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            buffer[6:10] = Types.S8_24.serialize(self.linearSpeed)
            buffer[10:14] = Types.S8_24.serialize(self.rotationSpeed)
            buffer[14:18] = Types.i32.serialize(self.durationTime)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(104)
            requestId = Types.RequestID.deserialize(data[2:6])
            linearSpeed = Types.S8_24.deserialize(data[6:10])
            rotationSpeed = Types.S8_24.deserialize(data[10:14])
            durationTime = Types.i32.deserialize(data[14:18])
            return cls(requestId, linearSpeed, rotationSpeed, durationTime)

        @classmethod
        def expected_length(cls, source):
            return 18

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return PacketTypes.PacketEvent_VelocityExecutionState, 

    class PacketResponse_Velocity:
        message_id = Types.u16(105)

        def __init__(self, requestId):
            self.requestId = Types.RequestID(requestId)

        def __repr__(self):
            return f'PacketResponse_Velocity(message_id={self.message_id}, requestId={self.requestId})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(6))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(105)
            requestId = Types.RequestID.deserialize(data[2:6])
            return cls(requestId)

        @classmethod
        def expected_length(cls, source):
            return 6

        def is_response_to(self, request: _PacketType) -> bool:
            if not hasattr(request, 'requestId'):
                return False
            if request.requestId != self.requestId:
                return False
            return isinstance(request, PacketTypes.PacketRequest_Velocity)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketRequest_LineNavigation:
        message_id = Types.u16(106)

        def __init__(self, requestId, direction, action):
            self.requestId = Types.RequestID(requestId)
            self.direction = Types.IntersectionDirection(direction)
            self.action = Types.LineNavigationAction(action)

        def __repr__(self):
            return f'PacketRequest_LineNavigation(message_id={self.message_id}, requestId={self.requestId}, direction={self.direction}, action={self.action})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId) and (self.direction == other.direction) and (self.action == other.action)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(8))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            buffer[6:7] = Types.IntersectionDirection.serialize(self.direction)
            buffer[7:8] = Types.LineNavigationAction.serialize(self.action)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(106)
            requestId = Types.RequestID.deserialize(data[2:6])
            direction = Types.IntersectionDirection.deserialize(data[6:7])
            action = Types.LineNavigationAction.deserialize(data[7:8])
            return cls(requestId, direction, action)

        @classmethod
        def expected_length(cls, source):
            return 8

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return PacketTypes.PacketEvent_LineNavigationExecutionUpdate, 

    class PacketResponse_LineNavigation:
        message_id = Types.u16(107)

        def __init__(self, requestId):
            self.requestId = Types.RequestID(requestId)

        def __repr__(self):
            return f'PacketResponse_LineNavigation(message_id={self.message_id}, requestId={self.requestId})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(6))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(107)
            requestId = Types.RequestID.deserialize(data[2:6])
            return cls(requestId)

        @classmethod
        def expected_length(cls, source):
            return 6

        def is_response_to(self, request: _PacketType) -> bool:
            if not hasattr(request, 'requestId'):
                return False
            if request.requestId != self.requestId:
                return False
            return isinstance(request, PacketTypes.PacketRequest_LineNavigation)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketRequest_StopExecution:
        message_id = Types.u16(120)

        def __init__(self, requestId):
            self.requestId = Types.RequestID(requestId)

        def __repr__(self):
            return f'PacketRequest_StopExecution(message_id={self.message_id}, requestId={self.requestId})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(6))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(120)
            requestId = Types.RequestID.deserialize(data[2:6])
            return cls(requestId)

        @classmethod
        def expected_length(cls, source):
            return 6

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return PacketTypes.PacketEvent_AudioExecutionState, PacketTypes.PacketEvent_VirtualMachineExecutionState, PacketTypes.PacketEvent_PreciseMovementExecutionUpdate, PacketTypes.PacketEvent_LineNavigationExecutionUpdate, 

    class PacketResponse_StopExecution:
        message_id = Types.u16(121)

        def __init__(self, requestId):
            self.requestId = Types.RequestID(requestId)

        def __repr__(self):
            return f'PacketResponse_StopExecution(message_id={self.message_id}, requestId={self.requestId})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(6))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(121)
            requestId = Types.RequestID.deserialize(data[2:6])
            return cls(requestId)

        @classmethod
        def expected_length(cls, source):
            return 6

        def is_response_to(self, request: _PacketType) -> bool:
            if not hasattr(request, 'requestId'):
                return False
            if request.requestId != self.requestId:
                return False
            return isinstance(request, PacketTypes.PacketRequest_StopExecution)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketRequest_WatcherSetup:
        message_id = Types.u16(122)

        def __init__(self, watcherID, flags, notificationPeriodMin, notificationPeriodMax):
            self.watcherID = Types.u8(watcherID)
            self.flags = Types.WatcherFlags(flags)
            self.notificationPeriodMin = Types.u16(notificationPeriodMin)
            self.notificationPeriodMax = Types.u16(notificationPeriodMax)

        def __repr__(self):
            return f'PacketRequest_WatcherSetup(message_id={self.message_id}, watcherID={self.watcherID}, flags={self.flags}, notificationPeriodMin={self.notificationPeriodMin}, notificationPeriodMax={self.notificationPeriodMax})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.watcherID == other.watcherID) and (self.flags == other.flags) and (self.notificationPeriodMin == other.notificationPeriodMin) and (self.notificationPeriodMax == other.notificationPeriodMax)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(8))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.u8.serialize(self.watcherID)
            buffer[3:4] = Types.WatcherFlags.serialize(self.flags)
            buffer[4:6] = Types.u16.serialize(self.notificationPeriodMin)
            buffer[6:8] = Types.u16.serialize(self.notificationPeriodMax)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(122)
            watcherID = Types.u8.deserialize(data[2:3])
            flags = Types.WatcherFlags.deserialize(data[3:4])
            notificationPeriodMin = Types.u16.deserialize(data[4:6])
            notificationPeriodMax = Types.u16.deserialize(data[6:8])
            return cls(watcherID, flags, notificationPeriodMin, notificationPeriodMax)

        @classmethod
        def expected_length(cls, source):
            return 8

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return PacketTypes.PacketEvent_WatcherDirty, 

    class PacketResponse_WatcherSetup:
        message_id = Types.u16(123)

        def __init__(self, callStatus):
            self.callStatus = Types.CallStatus(callStatus)

        def __repr__(self):
            return f'PacketResponse_WatcherSetup(message_id={self.message_id}, callStatus={self.callStatus})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.callStatus == other.callStatus)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(3))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.CallStatus.serialize(self.callStatus)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(123)
            callStatus = Types.CallStatus.deserialize(data[2:3])
            return cls(callStatus)

        @classmethod
        def expected_length(cls, source):
            return 3

        def is_response_to(self, request: _PacketType) -> bool:
            return isinstance(request, PacketTypes.PacketRequest_WatcherSetup)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketRequest_WatcherRegionSetup:
        message_id = Types.u16(124)

        def __init__(self, watcherID, regionID, address, size, flags):
            self.watcherID = Types.u8(watcherID)
            self.regionID = Types.u8(regionID)
            self.address = Types.u16(address)
            self.size = Types.u8(size)
            self.flags = Types.WatcherRegionFlags(flags)

        def __repr__(self):
            return f'PacketRequest_WatcherRegionSetup(message_id={self.message_id}, watcherID={self.watcherID}, regionID={self.regionID}, address={self.address}, size={self.size}, flags={self.flags})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.watcherID == other.watcherID) and (self.regionID == other.regionID) and (self.address == other.address) and (self.size == other.size) and (self.flags == other.flags)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(8))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.u8.serialize(self.watcherID)
            buffer[3:4] = Types.u8.serialize(self.regionID)
            buffer[4:6] = Types.u16.serialize(self.address)
            buffer[6:7] = Types.u8.serialize(self.size)
            buffer[7:8] = Types.WatcherRegionFlags.serialize(self.flags)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(124)
            watcherID = Types.u8.deserialize(data[2:3])
            regionID = Types.u8.deserialize(data[3:4])
            address = Types.u16.deserialize(data[4:6])
            size = Types.u8.deserialize(data[6:7])
            flags = Types.WatcherRegionFlags.deserialize(data[7:8])
            return cls(watcherID, regionID, address, size, flags)

        @classmethod
        def expected_length(cls, source):
            return 8

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return PacketTypes.PacketEvent_WatcherDirty, 

    class PacketResponse_WatcherRegionSetup:
        message_id = Types.u16(125)

        def __init__(self, callStatus):
            self.callStatus = Types.CallStatus(callStatus)

        def __repr__(self):
            return f'PacketResponse_WatcherRegionSetup(message_id={self.message_id}, callStatus={self.callStatus})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.callStatus == other.callStatus)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(3))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.CallStatus.serialize(self.callStatus)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(125)
            callStatus = Types.CallStatus.deserialize(data[2:3])
            return cls(callStatus)

        @classmethod
        def expected_length(cls, source):
            return 3

        def is_response_to(self, request: _PacketType) -> bool:
            return isinstance(request, PacketTypes.PacketRequest_WatcherRegionSetup)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketRequest_ExecuteFile:
        message_id = Types.u16(108)

        def __init__(self, requestId, path):
            self.requestId = Types.RequestID(requestId)
            self.path = Types.c8(path)

        def __repr__(self):
            return f'PacketRequest_ExecuteFile(message_id={self.message_id}, requestId={self.requestId}, path={self.path})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId) and (self.path == other.path)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            vla_data = serialize_array(self.path, Types.c8)
            buffer = memoryview(bytearray(6+len(vla_data)))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            buffer[6:6+len(vla_data)] = serialize_array(self.path, Types.c8)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(108)
            requestId = Types.RequestID.deserialize(data[2:6])
            path = deserialize_array(Types.c8, data[6:])
            return cls(requestId, path)

        @classmethod
        def expected_length(cls, source):
            return 6 + getattr(source, 'None', 0)

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return PacketTypes.PacketEvent_VirtualMachineExecutionState, PacketTypes.PacketEvent_AudioExecutionState, 

    class PacketResponse_ExecuteFile:
        message_id = Types.u16(109)

        def __init__(self, requestId, callStatus):
            self.requestId = Types.RequestID(requestId)
            self.callStatus = Types.CallStatus(callStatus)

        def __repr__(self):
            return f'PacketResponse_ExecuteFile(message_id={self.message_id}, requestId={self.requestId}, callStatus={self.callStatus})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId) and (self.callStatus == other.callStatus)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(7))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            buffer[6:7] = Types.CallStatus.serialize(self.callStatus)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(109)
            requestId = Types.RequestID.deserialize(data[2:6])
            callStatus = Types.CallStatus.deserialize(data[6:7])
            return cls(requestId, callStatus)

        @classmethod
        def expected_length(cls, source):
            return 7

        def is_response_to(self, request: _PacketType) -> bool:
            if not hasattr(request, 'requestId'):
                return False
            if request.requestId != self.requestId:
                return False
            return isinstance(request, PacketTypes.PacketRequest_ExecuteFile)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketRequest_SetLED:
        message_id = Types.u16(110)

        def __init__(self, ledsMask, red, green, blue, alpha):
            self.ledsMask = Types.LEDsMask(ledsMask)
            self.red = Types.u8(red)
            self.green = Types.u8(green)
            self.blue = Types.u8(blue)
            self.alpha = Types.u8(alpha)

        def __repr__(self):
            return f'PacketRequest_SetLED(message_id={self.message_id}, ledsMask={self.ledsMask}, red={self.red}, green={self.green}, blue={self.blue}, alpha={self.alpha})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.ledsMask == other.ledsMask) and (self.red == other.red) and (self.green == other.green) and (self.blue == other.blue) and (self.alpha == other.alpha)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(8))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:4] = Types.LEDsMask.serialize(self.ledsMask)
            buffer[4:5] = Types.u8.serialize(self.red)
            buffer[5:6] = Types.u8.serialize(self.green)
            buffer[6:7] = Types.u8.serialize(self.blue)
            buffer[7:8] = Types.u8.serialize(self.alpha)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(110)
            ledsMask = Types.LEDsMask.deserialize(data[2:4])
            red = Types.u8.deserialize(data[4:5])
            green = Types.u8.deserialize(data[5:6])
            blue = Types.u8.deserialize(data[6:7])
            alpha = Types.u8.deserialize(data[7:8])
            return cls(ledsMask, red, green, blue, alpha)

        @classmethod
        def expected_length(cls, source):
            return 8

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return tuple()

    class PacketResponse_SetLED:
        message_id = Types.u16(111)

        def __init__(self, callStatus):
            self.callStatus = Types.CallStatus(callStatus)

        def __repr__(self):
            return f'PacketResponse_SetLED(message_id={self.message_id}, callStatus={self.callStatus})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.callStatus == other.callStatus)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(3))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.CallStatus.serialize(self.callStatus)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(111)
            callStatus = Types.CallStatus.deserialize(data[2:3])
            return cls(callStatus)

        @classmethod
        def expected_length(cls, source):
            return 3

        def is_response_to(self, request: _PacketType) -> bool:
            return isinstance(request, PacketTypes.PacketRequest_SetLED)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketRequest_Calibrate:
        message_id = Types.u16(112)

        def __init__(self, type):
            self.type = Types.CalibrationType(type)

        def __repr__(self):
            return f'PacketRequest_Calibrate(message_id={self.message_id}, type={self.type})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.type == other.type)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(3))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.CalibrationType.serialize(self.type)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(112)
            type = Types.CalibrationType.deserialize(data[2:3])
            return cls(type)

        @classmethod
        def expected_length(cls, source):
            return 3

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return PacketTypes.PacketEvent_CalibrationStatus, 

    class PacketResponse_Calibrate:
        message_id = Types.u16(113)

        def __init__(self, callStatus):
            self.callStatus = Types.CallStatus(callStatus)

        def __repr__(self):
            return f'PacketResponse_Calibrate(message_id={self.message_id}, callStatus={self.callStatus})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.callStatus == other.callStatus)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(3))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.CallStatus.serialize(self.callStatus)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(113)
            callStatus = Types.CallStatus.deserialize(data[2:3])
            return cls(callStatus)

        @classmethod
        def expected_length(cls, source):
            return 3

        def is_response_to(self, request: _PacketType) -> bool:
            return isinstance(request, PacketTypes.PacketRequest_Calibrate)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketRequest_TurnOff:
        message_id = Types.u16(114)

        def __init__(self):
            pass

        def __repr__(self):
            return f'PacketRequest_TurnOff(message_id={self.message_id})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(2))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(114)
            return cls()

        @classmethod
        def expected_length(cls, source):
            return 2

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return tuple()

    class PacketResponse_TurnOff:
        message_id = Types.u16(115)

        def __init__(self, callStatus):
            self.callStatus = Types.CallStatus(callStatus)

        def __repr__(self):
            return f'PacketResponse_TurnOff(message_id={self.message_id}, callStatus={self.callStatus})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.callStatus == other.callStatus)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(3))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.CallStatus.serialize(self.callStatus)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(115)
            callStatus = Types.CallStatus.deserialize(data[2:3])
            return cls(callStatus)

        @classmethod
        def expected_length(cls, source):
            return 3

        def is_response_to(self, request: _PacketType) -> bool:
            return isinstance(request, PacketTypes.PacketRequest_TurnOff)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketRequest_UpdateFirmware:
        message_id = Types.u16(116)

        def __init__(self, target, source):
            self.target = Types.FirmwareUpdateTargetEnum(target)
            self.source = Types.FirmwareUpdateSourceEnum(source)

        def __repr__(self):
            return f'PacketRequest_UpdateFirmware(message_id={self.message_id}, target={self.target}, source={self.source})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.target == other.target) and (self.source == other.source)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(4))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.FirmwareUpdateTargetEnum.serialize(self.target)
            buffer[3:4] = Types.FirmwareUpdateSourceEnum.serialize(self.source)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(116)
            target = Types.FirmwareUpdateTargetEnum.deserialize(data[2:3])
            source = Types.FirmwareUpdateSourceEnum.deserialize(data[3:4])
            return cls(target, source)

        @classmethod
        def expected_length(cls, source):
            return 4

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return tuple()

    class PacketResponse_UpdateFirmware:
        message_id = Types.u16(117)

        def __init__(self, callStatus):
            self.callStatus = Types.CallStatus(callStatus)

        def __repr__(self):
            return f'PacketResponse_UpdateFirmware(message_id={self.message_id}, callStatus={self.callStatus})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.callStatus == other.callStatus)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(3))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.CallStatus.serialize(self.callStatus)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(117)
            callStatus = Types.CallStatus.deserialize(data[2:3])
            return cls(callStatus)

        @classmethod
        def expected_length(cls, source):
            return 3

        def is_response_to(self, request: _PacketType) -> bool:
            return isinstance(request, PacketTypes.PacketRequest_UpdateFirmware)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketRequest_PlayTone:
        message_id = Types.u16(118)

        def __init__(self, requestId, frequency, duration, volume):
            self.requestId = Types.RequestID(requestId)
            self.frequency = Types.u16(frequency)
            self.duration = Types.u16(duration)
            self.volume = Types.u8(volume)

        def __repr__(self):
            return f'PacketRequest_PlayTone(message_id={self.message_id}, requestId={self.requestId}, frequency={self.frequency}, duration={self.duration}, volume={self.volume})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId) and (self.frequency == other.frequency) and (self.duration == other.duration) and (self.volume == other.volume)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(11))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            buffer[6:8] = Types.u16.serialize(self.frequency)
            buffer[8:10] = Types.u16.serialize(self.duration)
            buffer[10:11] = Types.u8.serialize(self.volume)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(118)
            requestId = Types.RequestID.deserialize(data[2:6])
            frequency = Types.u16.deserialize(data[6:8])
            duration = Types.u16.deserialize(data[8:10])
            volume = Types.u8.deserialize(data[10:11])
            return cls(requestId, frequency, duration, volume)

        @classmethod
        def expected_length(cls, source):
            return 11

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return PacketTypes.PacketEvent_AudioExecutionState, 

    class PacketResponse_PlayTone:
        message_id = Types.u16(119)

        def __init__(self, requestId):
            self.requestId = Types.RequestID(requestId)

        def __repr__(self):
            return f'PacketResponse_PlayTone(message_id={self.message_id}, requestId={self.requestId})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(6))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(119)
            requestId = Types.RequestID.deserialize(data[2:6])
            return cls(requestId)

        @classmethod
        def expected_length(cls, source):
            return 6

        def is_response_to(self, request: _PacketType) -> bool:
            if not hasattr(request, 'requestId'):
                return False
            if request.requestId != self.requestId:
                return False
            return isinstance(request, PacketTypes.PacketRequest_PlayTone)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketRequest_LongRPCExtensionExecute:
        message_id = Types.u16(126)

        def __init__(self, dataLength, dataCRC):
            self.dataLength = Types.size_t(dataLength)
            self.dataCRC = Types.u32(dataCRC)

        def __repr__(self):
            return f'PacketRequest_LongRPCExtensionExecute(message_id={self.message_id}, dataLength={self.dataLength}, dataCRC={self.dataCRC})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.dataLength == other.dataLength) and (self.dataCRC == other.dataCRC)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(8))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:4] = Types.size_t.serialize(self.dataLength)
            buffer[4:8] = Types.u32.serialize(self.dataCRC)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(126)
            dataLength = Types.size_t.deserialize(data[2:4])
            dataCRC = Types.u32.deserialize(data[4:8])
            return cls(dataLength, dataCRC)

        @classmethod
        def expected_length(cls, source):
            return 8

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return tuple()

    class PacketResponse_LongRPCExtensionExecute:
        message_id = Types.u16(127)

        def __init__(self, callStatus, dataLength, dataCRC):
            self.callStatus = Types.CallStatus(callStatus)
            self.dataLength = Types.size_t(dataLength)
            self.dataCRC = Types.u32(dataCRC)

        def __repr__(self):
            return f'PacketResponse_LongRPCExtensionExecute(message_id={self.message_id}, callStatus={self.callStatus}, dataLength={self.dataLength}, dataCRC={self.dataCRC})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.callStatus == other.callStatus) and (self.dataLength == other.dataLength) and (self.dataCRC == other.dataCRC)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(9))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.CallStatus.serialize(self.callStatus)
            buffer[3:5] = Types.size_t.serialize(self.dataLength)
            buffer[5:9] = Types.u32.serialize(self.dataCRC)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(127)
            callStatus = Types.CallStatus.deserialize(data[2:3])
            dataLength = Types.size_t.deserialize(data[3:5])
            dataCRC = Types.u32.deserialize(data[5:9])
            return cls(callStatus, dataLength, dataCRC)

        @classmethod
        def expected_length(cls, source):
            return 9

        def is_response_to(self, request: _PacketType) -> bool:
            return isinstance(request, PacketTypes.PacketRequest_LongRPCExtensionExecute)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketRequest_SetRNGSeed:
        message_id = Types.u16(130)

        def __init__(self, seed):
            self.seed = Types.u32(seed)

        def __repr__(self):
            return f'PacketRequest_SetRNGSeed(message_id={self.message_id}, seed={self.seed})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.seed == other.seed)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(6))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.u32.serialize(self.seed)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(130)
            seed = Types.u32.deserialize(data[2:6])
            return cls(seed)

        @classmethod
        def expected_length(cls, source):
            return 6

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return tuple()

    class PacketResponse_SetRNGSeed:
        message_id = Types.u16(131)

        def __init__(self, callStatus):
            self.callStatus = Types.CallStatus(callStatus)

        def __repr__(self):
            return f'PacketResponse_SetRNGSeed(message_id={self.message_id}, callStatus={self.callStatus})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.callStatus == other.callStatus)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(3))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.CallStatus.serialize(self.callStatus)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(131)
            callStatus = Types.CallStatus.deserialize(data[2:3])
            return cls(callStatus)

        @classmethod
        def expected_length(cls, source):
            return 3

        def is_response_to(self, request: _PacketType) -> bool:
            return isinstance(request, PacketTypes.PacketRequest_SetRNGSeed)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketRequest_SensorsLogging:
        message_id = Types.u16(132)

        def __init__(self, newState):
            self.newState = Types.LoggingState(newState)

        def __repr__(self):
            return f'PacketRequest_SensorsLogging(message_id={self.message_id}, newState={self.newState})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.newState == other.newState)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(3))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.LoggingState.serialize(self.newState)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(132)
            newState = Types.LoggingState.deserialize(data[2:3])
            return cls(newState)

        @classmethod
        def expected_length(cls, source):
            return 3

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return PacketTypes.PacketEvent_SensorsLoggingExecutionUpdate, 

    class PacketResponse_SensorsLogging:
        message_id = Types.u16(133)

        def __init__(self, callStatus):
            self.callStatus = Types.CallStatus(callStatus)

        def __repr__(self):
            return f'PacketResponse_SensorsLogging(message_id={self.message_id}, callStatus={self.callStatus})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.callStatus == other.callStatus)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(3))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.CallStatus.serialize(self.callStatus)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(133)
            callStatus = Types.CallStatus.deserialize(data[2:3])
            return cls(callStatus)

        @classmethod
        def expected_length(cls, source):
            return 3

        def is_response_to(self, request: _PacketType) -> bool:
            return isinstance(request, PacketTypes.PacketRequest_SensorsLogging)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketRequest_MemoryTest:
        message_id = Types.u16(134)

        def __init__(self, testType):
            self.testType = Types.MemoryTestTypes(testType)

        def __repr__(self):
            return f'PacketRequest_MemoryTest(message_id={self.message_id}, testType={self.testType})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.testType == other.testType)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(3))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.MemoryTestTypes.serialize(self.testType)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(134)
            testType = Types.MemoryTestTypes.deserialize(data[2:3])
            return cls(testType)

        @classmethod
        def expected_length(cls, source):
            return 3

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

        @property
        def associated_events(self):
            return PacketTypes.PacketEvent_MemoryTestStatus, 

    class PacketResponse_MemoryTest:
        message_id = Types.u16(135)

        def __init__(self, callStatus):
            self.callStatus = Types.CallStatus(callStatus)

        def __repr__(self):
            return f'PacketResponse_MemoryTest(message_id={self.message_id}, callStatus={self.callStatus})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.callStatus == other.callStatus)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(3))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.CallStatus.serialize(self.callStatus)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(135)
            callStatus = Types.CallStatus.deserialize(data[2:3])
            return cls(callStatus)

        @classmethod
        def expected_length(cls, source):
            return 3

        def is_response_to(self, request: _PacketType) -> bool:
            return isinstance(request, PacketTypes.PacketRequest_MemoryTest)

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketEvent_PreciseMovementExecutionUpdate:
        message_id = Types.u16(256)

        def __init__(self, requestId, executionState, overshotTime, overshotDistance, maxSpeed):
            self.requestId = Types.RequestID(requestId)
            self.executionState = Types.ExecutionStateEnum(executionState)
            self.overshotTime = Types.S8_24(overshotTime)
            self.overshotDistance = Types.S8_24(overshotDistance)
            self.maxSpeed = Types.S8_24(maxSpeed)

        def __repr__(self):
            return f'PacketEvent_PreciseMovementExecutionUpdate(message_id={self.message_id}, requestId={self.requestId}, executionState={self.executionState}, overshotTime={self.overshotTime}, overshotDistance={self.overshotDistance}, maxSpeed={self.maxSpeed})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId) and (self.executionState == other.executionState) and (self.overshotTime == other.overshotTime) and (self.overshotDistance == other.overshotDistance) and (self.maxSpeed == other.maxSpeed)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(19))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            buffer[6:7] = Types.ExecutionStateEnum.serialize(self.executionState)
            buffer[7:11] = Types.S8_24.serialize(self.overshotTime)
            buffer[11:15] = Types.S8_24.serialize(self.overshotDistance)
            buffer[15:19] = Types.S8_24.serialize(self.maxSpeed)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(256)
            requestId = Types.RequestID.deserialize(data[2:6])
            executionState = Types.ExecutionStateEnum.deserialize(data[6:7])
            overshotTime = Types.S8_24.deserialize(data[7:11])
            overshotDistance = Types.S8_24.deserialize(data[11:15])
            maxSpeed = Types.S8_24.deserialize(data[15:19])
            return cls(requestId, executionState, overshotTime, overshotDistance, maxSpeed)

        @classmethod
        def expected_length(cls, source):
            return 19

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            if not hasattr(request, 'requestId'):
                return False
            if request.requestId != self.requestId:
                return False
            return isinstance(request, PacketTypes.PacketRequest_MoveStraight) or isinstance(request, PacketTypes.PacketRequest_Rotate) or isinstance(request, PacketTypes.PacketRequest_StopExecution)

    class PacketEvent_LineNavigationExecutionUpdate:
        message_id = Types.u16(257)

        def __init__(self, requestId, executionState, intersection):
            self.requestId = Types.RequestID(requestId)
            self.executionState = Types.ExecutionStateEnum(executionState)
            self.intersection = Types.IntersectionBitmap(intersection)

        def __repr__(self):
            return f'PacketEvent_LineNavigationExecutionUpdate(message_id={self.message_id}, requestId={self.requestId}, executionState={self.executionState}, intersection={self.intersection})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId) and (self.executionState == other.executionState) and (self.intersection == other.intersection)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(8))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            buffer[6:7] = Types.ExecutionStateEnum.serialize(self.executionState)
            buffer[7:8] = Types.IntersectionBitmap.serialize(self.intersection)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(257)
            requestId = Types.RequestID.deserialize(data[2:6])
            executionState = Types.ExecutionStateEnum.deserialize(data[6:7])
            intersection = Types.IntersectionBitmap.deserialize(data[7:8])
            return cls(requestId, executionState, intersection)

        @classmethod
        def expected_length(cls, source):
            return 8

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            if not hasattr(request, 'requestId'):
                return False
            if request.requestId != self.requestId:
                return False
            return isinstance(request, PacketTypes.PacketRequest_LineNavigation) or isinstance(request, PacketTypes.PacketRequest_StopExecution)

    class PacketEvent_VelocityExecutionState:
        message_id = Types.u16(266)

        def __init__(self, requestId, executionState):
            self.requestId = Types.RequestID(requestId)
            self.executionState = Types.ExecutionStateEnum(executionState)

        def __repr__(self):
            return f'PacketEvent_VelocityExecutionState(message_id={self.message_id}, requestId={self.requestId}, executionState={self.executionState})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId) and (self.executionState == other.executionState)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(7))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            buffer[6:7] = Types.ExecutionStateEnum.serialize(self.executionState)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(266)
            requestId = Types.RequestID.deserialize(data[2:6])
            executionState = Types.ExecutionStateEnum.deserialize(data[6:7])
            return cls(requestId, executionState)

        @classmethod
        def expected_length(cls, source):
            return 7

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            if not hasattr(request, 'requestId'):
                return False
            if request.requestId != self.requestId:
                return False
            return isinstance(request, PacketTypes.PacketRequest_Velocity)

    class PacketEvent_WatcherDirty:
        message_id = Types.u16(260)

        def __init__(self, id, data):
            self.id = Types.u8(id)
            self.data = list([Types.u8(x) for x in data])

        def __repr__(self):
            return f'PacketEvent_WatcherDirty(message_id={self.message_id}, id={self.id}, data={self.data})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.id == other.id) and (self.data == other.data)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            vla_data = serialize_array(self.data, Types.u8)
            buffer = memoryview(bytearray(3+len(vla_data)))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.u8.serialize(self.id)
            buffer[3:3+len(vla_data)] = serialize_array(self.data, Types.u8)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(260)
            id = Types.u8.deserialize(data[2:3])
            data = deserialize_array(Types.u8, data[3:])
            return cls(id, data)

        @classmethod
        def expected_length(cls, source):
            return 3 + getattr(source, 'None', 0)

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            if not hasattr(request, 'watcherID'):
                return False
            if request.watcherID != self.id:
                return False
            return isinstance(request, PacketTypes.PacketRequest_WatcherSetup) or isinstance(request, PacketTypes.PacketRequest_WatcherRegionSetup)

    class PacketEvent_ModuleError:
        message_id = Types.u16(263)

        def __init__(self, moduleID, errorCode):
            self.moduleID = Types.ErrorModuleIDs(moduleID)
            self.errorCode = Types.u32(errorCode)

        def __repr__(self):
            return f'PacketEvent_ModuleError(message_id={self.message_id}, moduleID={self.moduleID}, errorCode={self.errorCode})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.moduleID == other.moduleID) and (self.errorCode == other.errorCode)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(7))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.ErrorModuleIDs.serialize(self.moduleID)
            buffer[3:7] = Types.u32.serialize(self.errorCode)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(263)
            moduleID = Types.ErrorModuleIDs.deserialize(data[2:3])
            errorCode = Types.u32.deserialize(data[3:7])
            return cls(moduleID, errorCode)

        @classmethod
        def expected_length(cls, source):
            return 7

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketEvent_Shutdown:
        message_id = Types.u16(258)

        def __init__(self, source):
            self.source = Types.ShutdownSource(source)

        def __repr__(self):
            return f'PacketEvent_Shutdown(message_id={self.message_id}, source={self.source})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.source == other.source)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(3))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.ShutdownSource.serialize(self.source)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(258)
            source = Types.ShutdownSource.deserialize(data[2:3])
            return cls(source)

        @classmethod
        def expected_length(cls, source):
            return 3

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return False

    class PacketEvent_AudioExecutionState:
        message_id = Types.u16(259)

        def __init__(self, requestId, executionState):
            self.requestId = Types.RequestID(requestId)
            self.executionState = Types.ExecutionStateEnum(executionState)

        def __repr__(self):
            return f'PacketEvent_AudioExecutionState(message_id={self.message_id}, requestId={self.requestId}, executionState={self.executionState})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId) and (self.executionState == other.executionState)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(7))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            buffer[6:7] = Types.ExecutionStateEnum.serialize(self.executionState)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(259)
            requestId = Types.RequestID.deserialize(data[2:6])
            executionState = Types.ExecutionStateEnum.deserialize(data[6:7])
            return cls(requestId, executionState)

        @classmethod
        def expected_length(cls, source):
            return 7

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            if not hasattr(request, 'requestId'):
                return False
            if request.requestId != self.requestId:
                return False
            return isinstance(request, PacketTypes.PacketRequest_StopExecution) or isinstance(request, PacketTypes.PacketRequest_ExecuteFile) or isinstance(request, PacketTypes.PacketRequest_PlayTone)

    class PacketEvent_CalibrationStatus:
        message_id = Types.u16(261)

        def __init__(self, status):
            self.status = Types.CalibrationResultEnum(status)

        def __repr__(self):
            return f'PacketEvent_CalibrationStatus(message_id={self.message_id}, status={self.status})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.status == other.status)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(3))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.CalibrationResultEnum.serialize(self.status)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(261)
            status = Types.CalibrationResultEnum.deserialize(data[2:3])
            return cls(status)

        @classmethod
        def expected_length(cls, source):
            return 3

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return isinstance(request, PacketTypes.PacketRequest_Calibrate)

    class PacketEvent_MemoryTestStatus:
        message_id = Types.u16(262)

        def __init__(self, executionState, progress, flashID, address, fields):
            self.executionState = Types.ExecutionStateEnum(executionState)
            self.progress = Types.u8(progress)
            self.flashID = Types.u8(flashID)
            self.address = Types.addr_t(address)
            self.fields = Types.MemoryTestFields(fields)

        def __repr__(self):
            return f'PacketEvent_MemoryTestStatus(message_id={self.message_id}, executionState={self.executionState}, progress={self.progress}, flashID={self.flashID}, address={self.address}, fields={self.fields})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.executionState == other.executionState) and (self.progress == other.progress) and (self.flashID == other.flashID) and (self.address == other.address) and (self.fields == other.fields)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(10))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.ExecutionStateEnum.serialize(self.executionState)
            buffer[3:4] = Types.u8.serialize(self.progress)
            buffer[4:5] = Types.u8.serialize(self.flashID)
            buffer[5:9] = Types.addr_t.serialize(self.address)
            buffer[9:10] = Types.MemoryTestFields.serialize(self.fields)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(262)
            executionState = Types.ExecutionStateEnum.deserialize(data[2:3])
            progress = Types.u8.deserialize(data[3:4])
            flashID = Types.u8.deserialize(data[4:5])
            address = Types.addr_t.deserialize(data[5:9])
            fields = Types.MemoryTestFields.deserialize(data[9:10])
            return cls(executionState, progress, flashID, address, fields)

        @classmethod
        def expected_length(cls, source):
            return 10

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return isinstance(request, PacketTypes.PacketRequest_MemoryTest)

    class PacketEvent_VirtualMachineExecutionState:
        message_id = Types.u16(264)

        def __init__(self, requestId, executionState):
            self.requestId = Types.RequestID(requestId)
            self.executionState = Types.ExecutionStateEnum(executionState)

        def __repr__(self):
            return f'PacketEvent_VirtualMachineExecutionState(message_id={self.message_id}, requestId={self.requestId}, executionState={self.executionState})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.requestId == other.requestId) and (self.executionState == other.executionState)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(7))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:6] = Types.RequestID.serialize(self.requestId)
            buffer[6:7] = Types.ExecutionStateEnum.serialize(self.executionState)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(264)
            requestId = Types.RequestID.deserialize(data[2:6])
            executionState = Types.ExecutionStateEnum.deserialize(data[6:7])
            return cls(requestId, executionState)

        @classmethod
        def expected_length(cls, source):
            return 7

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            if not hasattr(request, 'requestId'):
                return False
            if request.requestId != self.requestId:
                return False
            return isinstance(request, PacketTypes.PacketRequest_StopExecution) or isinstance(request, PacketTypes.PacketRequest_ExecuteFile)

    class PacketEvent_SensorsLoggingExecutionUpdate:
        message_id = Types.u16(265)

        def __init__(self, executionState):
            self.executionState = Types.ExecutionStateEnum(executionState)

        def __repr__(self):
            return f'PacketEvent_SensorsLoggingExecutionUpdate(message_id={self.message_id}, executionState={self.executionState})'

        def __eq__(self, other):
            if type(self) is not type(other):
                return False
            return (self.message_id == other.message_id) and (self.executionState == other.executionState)

        def __str__(self):
            return f'<{repr(self)}>'

        def serialize(self) -> bytes:
            buffer = memoryview(bytearray(3))
            buffer[0:2] = Types.u16.serialize(self.message_id)
            buffer[2:3] = Types.ExecutionStateEnum.serialize(self.executionState)
            return bytes(buffer)

        @classmethod
        def deserialize(cls, data):
            message_id = Types.u16.deserialize(data[0:2])
            assert message_id == int(265)
            executionState = Types.ExecutionStateEnum.deserialize(data[2:3])
            return cls(executionState)

        @classmethod
        def expected_length(cls, source):
            return 3

        def is_response_to(self, request: _PacketType) -> bool:
            return False

        def is_event_of(self, request: _PacketType) -> bool:
            return isinstance(request, PacketTypes.PacketRequest_SensorsLogging)


class VirtualMemory:
    hwConfiguration = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.u8,
        address=65575,
    )
    fwVersion = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.Version,
        address=65580,
    )
    fwCommitHash = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.c8,
        address=65584,
    )
    fwBuildType = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.c8,
        address=65598,
    )
    serialNumber = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.u8,
        address=65616,
    )
    watchersInfo = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.WatcherInfo,
        address=65651,
    )
    protocolHash = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.c8,
        address=65653,
    )
    lineSensorsPaper = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.LineWithRAW_8bit,
        address=0,
    )
    lineSensorsScreen = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.LineWithRAW_8bit,
        address=28,
    )
    colorSensorData = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.ColorSensorData,
        address=56,
    )
    processedColor = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.ProcessedRGBColor,
        address=69,
    )
    surfaceProximityData = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.SurfaceProximityData,
        address=80,
    )
    lineColor = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.LineColor,
        address=86,
    )
    colorCode = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.ColorCode,
        address=92,
    )
    surfaceColor = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.SurfaceColor,
        address=100,
    )
    surfaceType = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.Surface,
        address=108,
    )
    pickupDetection = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.PickupDetection,
        address=113,
    )
    irProximity = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.IRProximity,
        address=118,
    )
    irMessageLeftRear = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.IRMessage,
        address=126,
    )
    irMessageLeftFront = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.IRMessage,
        address=132,
    )
    irMessageRightRear = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.IRMessage,
        address=138,
    )
    irMessageRightFront = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.IRMessage,
        address=144,
    )
    wheelsEncoder = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.WheelsEncoder,
        address=150,
    )
    relativePosition = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.RelativePosition,
        address=162,
    )
    chargerState = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.ChargerState,
        address=183,
    )
    batteryState = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.Battery,
        address=188,
    )
    button = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.Button,
        address=196,
    )
    watcherUpdateCounters = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.u8,
        address=1024,
    )
    deviceName = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.c8,
        address=16384,
    )
    audioVolume = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.u8,
        address=16401,
    )
    ledsBrightness = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.u8,
        address=16402,
    )
    accountType = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.AccountTypeEnum,
        address=16403,
    )
    behaviour = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.BehaviourTypeEnum,
        address=16404,
    )
    irMessageLeftRearEmitting = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.IRMessageEmit,
        address=16405,
    )
    irMessageLeftFrontEmitting = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.IRMessageEmit,
        address=16407,
    )
    irMessageRightRearEmitting = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.IRMessageEmit,
        address=16409,
    )
    irMessageRightFrontEmitting = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.IRMessageEmit,
        address=16411,
    )
    virtualMachineSharedRegisters = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.u8,
        address=16413,
    )
    lineNavigationSpeed = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.S8_24,
        address=16421,
    )
    chargeRate = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.u8,
        address=16425,
    )
    buttonOverride = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.ButtonOverrideEnum,
        address=16426,
    )
    speedPID = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.PIDParameters,
        address=16438,
    )
    lineNavigationPID = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.PIDParameters,
        address=16462,
    )
    bleAdvertisingInterval = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.UnsignedRange,
        address=16474,
    )
    qaTrackLog = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.u8,
        address=16482,
    )
    colorCodeExecution = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.ColorCodeExecution,
        address=16483,
    )
    longRPCExtensionData = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.u8,
        address=24576,
    )
    testMode = PropertyMetadata(
        is_readable=True,
        is_writable=True,
        type=Types.TestModeFields,
        address=28672,
    )
    bootloaderVersion = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.Version,
        address=65536,
    )
    bootloaderCommitHash = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.c8,
        address=65540,
    )
    bootloaderFields = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.BootloaderFields,
        address=65554,
    )
    bootloaderErrorCode = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.BootloaderErrorCodes,
        address=65559,
    )
    bootloaderPress = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.time_t,
        address=65555,
    )
    keyVariant = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.EncryptionKeyVariant,
        address=65560,
    )
    keyFingerPrint = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.u8,
        address=65561,
    )
    productType = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.ProductTypeEnum,
        address=65573,
    )
    productRevision = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.u8,
        address=65574,
    )
    plasticColor = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.PlasticColor,
        address=65579,
    )
    bluetoothVersion = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.Version,
        address=65632,
    )
    bluetoothInitializedCode = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.BluetoothInitializedCode,
        address=65636,
    )
    bluetoothAddress = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.u8,
        address=65637,
    )
    bluetoothUpdateStatus = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.BluetoothUpdateErrorCodes,
        address=65643,
    )
    externalFlashInformation = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.ExternalFlashInformation,
        address=65644,
    )
    lineSensorsPaperCalibration = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.LineSensorsCalibration,
        address=65667,
    )
    lineSensorsScreenCalibration = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.LineSensorsCalibration,
        address=65695,
    )
    colorSensorPaperCalibration = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.ColorSensorCalibration,
        address=65723,
    )
    colorSensorScreenCalibration = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.ColorSensorCalibration,
        address=65735,
    )
    encodersCalibration = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.EncodersCalibration,
        address=65747,
    )
    colorSensorType = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.c8,
        address=65749,
    )
    boardsConfiguration = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.BoardsConfiguration,
        address=65765,
    )
    chassisGeometry = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.DifferentialGeometry,
        address=65770,
    )
    lineSensorGeometry = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.LineSensorGeometry,
        address=65782,
    )
    tasksInformation = PropertyMetadata(
        is_readable=True,
        is_writable=False,
        type=Types.TaskInformation,
        address=73728,
    )


class AsyncControl:

    @property
    def packet_size_max(self) -> int:
        return self._channel.packet_size_max

    def __init__(self, channel: _Channel) -> None:
        self._channel = channel
        self._rpc_lock = RLock()
        self._request_counter = 0

    def MemRead(self, addr: int | Types.addr_t, length: int | Types.size_t) -> RpcCall[PacketTypes.PacketResponse_MemRead, typing.Never]:
        '''Virtual memory read. It supports variable and whole read from an entry or segments. Entry is a singular logic object in the memory, segments are collections of entries. Read is atomic. Unclaimed/unused memory by the firmware is filled with zeroes. Memory has been read before returning the result of the operation, meaning memory can be changed after firmware returns read data.

        :param addr:             Virtual memory address.
        :param length:           Size of read.

        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_MemRead, typing.Never]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_MemRead(addr, length)
        return self._rpc(request, PacketTypes.PacketResponse_MemRead)

    def MemWrite(self, addr: int | Types.addr_t, length: int | Types.size_t, data: str | bytes) -> RpcCall[PacketTypes.PacketResponse_MemWrite, typing.Never]:
        '''Virtual memory write. Entire entries have to be written in a single write operation except entries with permitted partial writes. Write is done atomically. Response to the operation is returned after writing the memory, meaning the memory should be present for consecutive reads after this operation compeletes.

        :param addr:             Virtual memory address.
        :param length:           Size of data to be written in the virtual memory.
        :param data:             New virtual memory data written at the address.

        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_MemWrite, typing.Never]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_MemWrite(addr, length, data)
        return self._rpc(request, PacketTypes.PacketResponse_MemWrite)

    def MoveStraight(self, requestId: int | Types.RequestID, distance: float | Types.S8_24, speed: float | Types.S8_24) -> RpcCall[PacketTypes.PacketResponse_MoveStraight, PacketTypes.PacketEvent_PreciseMovementExecutionUpdate]:
        '''Move robot along a straight line. The function returns as soon as movement is queued, but may not have started executing yet. Note that if both distance and speed are negative, the resulting movement is forward.

        :param requestId:        Unique request identifier. Returned in PreciseMovementExecutionUpdate event.
        :param distance:         Distance to travel in meters. When negative, robot moves backwards.
        :param speed:            Average speed of the movement in meters per second. When negative, robot moves backwards.

        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_MoveStraight, PacketTypes.PacketEvent_PreciseMovementExecutionUpdate]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_MoveStraight(requestId, distance, speed)
        return self._rpc(request, PacketTypes.PacketResponse_MoveStraight)

    def Rotate(self, requestId: int | Types.RequestID, angle: float | Types.S8_24, speed: float | Types.S8_24) -> RpcCall[PacketTypes.PacketResponse_Rotate, PacketTypes.PacketEvent_PreciseMovementExecutionUpdate]:
        '''Rotate around vertical axis to a specified angle. The function returns as soon as movement is queued, but may not have started executing yet.

        :param requestId:        Unique request identifier. Returned in PreciseMovementExecutionUpdate event.
        :param angle:            Rotation angle in radians (counter-clockwise when positive and clockwise when negative).
        :param speed:            Average rotation speed in radians per second (if negative, reverse the direction given by angle.

        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_Rotate, PacketTypes.PacketEvent_PreciseMovementExecutionUpdate]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_Rotate(requestId, angle, speed)
        return self._rpc(request, PacketTypes.PacketResponse_Rotate)

    def Velocity(self, requestId: int | Types.RequestID, linearSpeed: float | Types.S8_24, rotationSpeed: float | Types.S8_24, durationTime: int | Types.i32) -> RpcCall[PacketTypes.PacketResponse_Velocity, PacketTypes.PacketEvent_VelocityExecutionState]:
        '''Set forward and rotation velocity. Setting expiration and waiting for it to expire can cause lag in movement or sudden snaps, prefer setting expiration to multiple of the expected duration (2x, 3x, ...) and replace it with another movement just in time - this applies to cases where chaining velocity is wanted. One-shot change in velocity can remain with exact expiration time. Cancelling this movement modification is still possible and can exhibit aforementioned behavior, but resets the speed(s) to the default.

        :param requestId:        Unique request identifier used to cancel this speed(s) modification.
        :param linearSpeed:      Linear speed in m/s.
        :param rotationSpeed:    Rotation speed in rad/s.
        :param durationTime:     Time for which velocity is maintained. For infinite use -1. The best practise is to set shorter duration and keep calling it in a loop instead infinite or long duration. It serves as safety feature when connection is lost robot stops instead drop from a surface.

        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_Velocity, PacketTypes.PacketEvent_VelocityExecutionState]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_Velocity(requestId, linearSpeed, rotationSpeed, durationTime)
        return self._rpc(request, PacketTypes.PacketResponse_Velocity)

    def LineNavigation(self, requestId: int | Types.RequestID, direction: Types.IntersectionDirection, action: Types.LineNavigationAction) -> RpcCall[PacketTypes.PacketResponse_LineNavigation, PacketTypes.PacketEvent_LineNavigationExecutionUpdate]:
        '''Line navigation is capable to follow lines, recognize intersections and turn in chosen direction on them.

        :param requestId:        Unique request identifier. Returned in LineNavigationExecutionUpdate event.
        :param direction:        Direction in which line navigation aligns.
        :param action:           Action taken after direction alignment.

        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_LineNavigation, PacketTypes.PacketEvent_LineNavigationExecutionUpdate]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_LineNavigation(requestId, direction, action)
        return self._rpc(request, PacketTypes.PacketResponse_LineNavigation)

    def StopExecution(self, requestId: int | Types.RequestID) -> RpcCall[PacketTypes.PacketResponse_StopExecution, PacketTypes.PacketEvent_AudioExecutionState | PacketTypes.PacketEvent_VirtualMachineExecutionState | PacketTypes.PacketEvent_PreciseMovementExecutionUpdate | PacketTypes.PacketEvent_LineNavigationExecutionUpdate]:
        '''Stop execution. It can be audio playback, movement etc.

        :param requestId:        Unique identifier of a request which will be stopped. To stop all execution use 0.

        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_StopExecution, PacketTypes.PacketEvent_AudioExecutionState | PacketTypes.PacketEvent_VirtualMachineExecutionState | PacketTypes.PacketEvent_PreciseMovementExecutionUpdate | PacketTypes.PacketEvent_LineNavigationExecutionUpdate]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_StopExecution(requestId)
        return self._rpc(request, PacketTypes.PacketResponse_StopExecution)

    def WatcherSetup(self, watcherID: int | Types.u8, flags: Types.WatcherFlags, notificationPeriodMin: int | Types.u16, notificationPeriodMax: int | Types.u16) -> RpcCall[PacketTypes.PacketResponse_WatcherSetup, PacketTypes.PacketEvent_WatcherDirty]:
        '''Watcher setup (flags and notification period). After enabling the watcher using 'flags', device keeps emitting WatcherDirty unless **explicitly disabled**.

        In cases where firmware is detached from controlling authority and controlling authority crashes or otherwise experiences a loss of control, the controlling authority must disable the watcher or otherwise reset this device.

        :param watcherID:        Watcher identifier. WatcherDirty will emit using this id, therefore use it to cross-reference incoming WatcherDirty in case of multiple registered emitters.
        :param flags:            Enable/disable flag.
        :param notificationPeriodMin: Watcher data emissions are throttled to this period. Meaning the watcher cannot emit unless this period has elapsed. To disable throttling, set it to 0.
        :param notificationPeriodMax: Clone of the latest watcher data is sent when there was no change to the sector in the specified period. To disable this feature, set it to 0.

        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_WatcherSetup, PacketTypes.PacketEvent_WatcherDirty]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_WatcherSetup(watcherID, flags, notificationPeriodMin, notificationPeriodMax)
        return self._rpc(request, PacketTypes.PacketResponse_WatcherSetup)

    def WatcherRegionSetup(self, watcherID: int | Types.u8, regionID: int | Types.u8, address: int | Types.u16, size: int | Types.u8, flags: Types.WatcherRegionFlags) -> RpcCall[PacketTypes.PacketResponse_WatcherRegionSetup, PacketTypes.PacketEvent_WatcherDirty]:
        '''Watcher region setup as address, size and flags. Emission does not start unless WatcherSetup is invoked with an appropriate Enable flag.

        :param watcherID:        Watcher identifier. Must be equal to the corresponding WatcherSetup.watcherID in order to apply changes correctly.
        :param regionID:         Watcher memory region identifier. IDs are limited to the amount of regions available in WatcherInfo. If the purpose is to use a single watcher, set it to 0.
        :param address:          Start address of the memory region. On purpose it is clamped to the first 16k. Addresses beyond 2^14, are not considered observable.
        :param size:             Size of the memory region. On purpose it is clamped to allow watcher watch over up to 256B. Frequently observable memory regions are clumped together, that said if the requirement is to observe large amount of memory, register multiple watchers.
        :param flags:            Memory region flags. For the most use-cases should be 0 or otherwise empty.

        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_WatcherRegionSetup, PacketTypes.PacketEvent_WatcherDirty]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_WatcherRegionSetup(watcherID, regionID, address, size, flags)
        return self._rpc(request, PacketTypes.PacketResponse_WatcherRegionSetup)

    def ExecuteFile(self, requestId: int | Types.RequestID, path: str | bytes) -> RpcCall[PacketTypes.PacketResponse_ExecuteFile, PacketTypes.PacketEvent_VirtualMachineExecutionState | PacketTypes.PacketEvent_AudioExecutionState]:
        '''Execute file like audio file, virtual machine program etc.

        :param requestId:        Unique request identifier. Returned in ExecutionState event.
        :param path:             File path. It has to be terminated with null character.

        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_ExecuteFile, PacketTypes.PacketEvent_VirtualMachineExecutionState | PacketTypes.PacketEvent_AudioExecutionState]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_ExecuteFile(requestId, path)
        return self._rpc(request, PacketTypes.PacketResponse_ExecuteFile)

    def SetLED(self, ledsMask: Types.LEDsMask, red: int | Types.u8, green: int | Types.u8, blue: int | Types.u8, alpha: int | Types.u8) -> RpcCall[PacketTypes.PacketResponse_SetLED, typing.Never]:
        '''Set LEDs brightness.

        :param ledsMask:         LEDs mask. Bits set to one specify on which LEDs following parameters will be aplied.
        :param red:              Red channel value
        :param green:            Green channel value
        :param blue:             Blue channel value
        :param alpha:            Alpha channel

        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_SetLED, typing.Never]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_SetLED(ledsMask, red, green, blue, alpha)
        return self._rpc(request, PacketTypes.PacketResponse_SetLED)

    def Calibrate(self, type: Types.CalibrationType) -> RpcCall[PacketTypes.PacketResponse_Calibrate, PacketTypes.PacketEvent_CalibrationStatus]:
        '''Request to calibrate sensors.

        :param type:             TODO: Do we want to use the same enum as used in the old protocol?

        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_Calibrate, PacketTypes.PacketEvent_CalibrationStatus]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_Calibrate(type)
        return self._rpc(request, PacketTypes.PacketResponse_Calibrate)

    def TurnOff(self) -> RpcCall[PacketTypes.PacketResponse_TurnOff, typing.Never]:
        '''Request to turn off.


        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_TurnOff, typing.Never]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_TurnOff()
        return self._rpc(request, PacketTypes.PacketResponse_TurnOff)

    def UpdateFirmware(self, target: Types.FirmwareUpdateTargetEnum, source: Types.FirmwareUpdateSourceEnum) -> RpcCall[PacketTypes.PacketResponse_UpdateFirmware, typing.Never]:
        '''Request to update firmware.

        :param target:           Update target as main MCU or an external one.
        :param source:           Update source as file system or special recovery location.

        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_UpdateFirmware, typing.Never]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_UpdateFirmware(target, source)
        return self._rpc(request, PacketTypes.PacketResponse_UpdateFirmware)

    def PlayTone(self, requestId: int | Types.RequestID, frequency: int | Types.u16, duration: int | Types.u16, volume: int | Types.u8) -> RpcCall[PacketTypes.PacketResponse_PlayTone, PacketTypes.PacketEvent_AudioExecutionState]:
        '''Play tone.

        :param requestId:        Unique request identifier. Returned in ExecutionState event.
        :param frequency:        Tone frequency in hertz
        :param duration:         Tone duration in ms
        :param volume:           Tone volume

        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_PlayTone, PacketTypes.PacketEvent_AudioExecutionState]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_PlayTone(requestId, frequency, duration, volume)
        return self._rpc(request, PacketTypes.PacketResponse_PlayTone)

    def LongRPCExtensionExecute(self, dataLength: int | Types.size_t, dataCRC: int | Types.u32) -> RpcCall[PacketTypes.PacketResponse_LongRPCExtensionExecute, typing.Never]:
        '''Execute preloaded RPC call from the virtual memory.

        :param dataLength:       RPC call data length.
        :param dataCRC:          RPC call data CRC to verify theirs integrity.

        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_LongRPCExtensionExecute, typing.Never]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_LongRPCExtensionExecute(dataLength, dataCRC)
        return self._rpc(request, PacketTypes.PacketResponse_LongRPCExtensionExecute)

    def SetRNGSeed(self, seed: int | Types.u32) -> RpcCall[PacketTypes.PacketResponse_SetRNGSeed, typing.Never]:
        '''Set random generator seed.

        :param seed:             Any integer to be used as the internal RNG pseudogenerator seed for blockly.

        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_SetRNGSeed, typing.Never]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_SetRNGSeed(seed)
        return self._rpc(request, PacketTypes.PacketResponse_SetRNGSeed)

    def SensorsLogging(self, newState: Types.LoggingState) -> RpcCall[PacketTypes.PacketResponse_SensorsLogging, PacketTypes.PacketEvent_SensorsLoggingExecutionUpdate]:
        '''Turn sensors logging on or off.

        :param newState:         New sensors logging state.

        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_SensorsLogging, PacketTypes.PacketEvent_SensorsLoggingExecutionUpdate]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_SensorsLogging(newState)
        return self._rpc(request, PacketTypes.PacketResponse_SensorsLogging)

    def MemoryTest(self, testType: Types.MemoryTestTypes) -> RpcCall[PacketTypes.PacketResponse_MemoryTest, PacketTypes.PacketEvent_MemoryTestStatus]:
        '''Start external flash memories test.

        :param testType:         Test type as full, short etc.

        :return:                 Instance of `RpcCall[PacketTypes.PacketResponse_MemoryTest, PacketTypes.PacketEvent_MemoryTestStatus]` that can be either awaited to get the RPC response or used as async context manager providing async iterator to get the response and associated events
        '''

        request = PacketTypes.PacketRequest_MemoryTest(testType)
        return self._rpc(request, PacketTypes.PacketResponse_MemoryTest)

    @contextlib.asynccontextmanager
    async def _rpc(self, request: _PacketType, response_type: type[_PacketType]) -> typing.AsyncIterator[tuple[_PacketType, typing.AsyncIterator[_PacketType]]]:
        length = max(len(request.serialize()), response_type.expected_length(request))
        logger.debug('Executing RPC', request_len=length, request=request)
        async with self._channel.open_session() as events_session:
            async with self._rpc_lock, self._channel.open_session() as response_session:
                logger.debug('Writting request')
                if length > self._channel.packet_size_max:
                    await self._long_rpc(request, response_type)
                else:
                    await response_session.write(request.serialize())
                logger.debug('expecting response')
                async for message in self._receive(response_session):
                    if message.is_response_to(request):
                        response = message
                        break
                logger.debug('got rpc response', response=response)

            async def _event_generator():
                logger.debug('expecting events')
                async for message in self._receive(events_session):
                    if message.is_event_of(request):
                        logger.debug('got event', event=message)
                        yield message
            event_generator = _event_generator()
            try:
                yield response, event_generator
            finally:
                await event_generator.aclose()

    async def _long_rpc[T: _PacketType](self, request: _PacketType, response_type: type[T]) -> T:
        data = request.serialize()
        chunk_size = self._channel.packet_size_max - 8
        logger.debug('executing long RPC', chunk_size=chunk_size)
        for chunk_start in range(0, len(data), chunk_size):
            logger.debug('writting long rpc request chunk', chunk_start=chunk_start)
            chunk_result_wr = await self.MemWrite(Types.addr_t(24576)+chunk_start, min(chunk_size, len(data)-chunk_start), bytes(data[chunk_start:chunk_start+chunk_size]))
            assert chunk_result_wr.result == Types.IOResult.Success
        result = await self.LongRPCExtensionExecute(Types.size_t(len(data)), Types.u32(crc32(data)))
        assert result.callStatus == Types.CallStatus.CallSuccess
        chunk_size = self._channel.packet_size_max - 5
        result_data = memoryview(bytearray(result.dataLength))
        for chunk_start in range(0, result.dataLength, chunk_size):
            logger.debug('reading long rpc response chunk', chunk_start=chunk_start)
            this_chunk_size = min(chunk_size, result.dataLength-chunk_start)
            chunk_result_rd = await self.MemRead(Types.addr_t(24576)+chunk_start, this_chunk_size)
            assert chunk_result_rd.result == Types.IOResult.Success
            result_data[chunk_start:chunk_start+this_chunk_size] = bytes(chunk_result_rd.data)
        assert crc32(result_data) == result.dataCRC
        return response_type.deserialize(bytes(result_data))

    async def _receive(self, session: _Session) -> typing.AsyncIterator[_PacketType]:
        async for message_bytes in session.read():
            message_id = Types.u16.deserialize(message_bytes[:2])
            packet_type = PacketTypes.get_packet_type_by_message_id(message_id)
            logger.debug('received packet', message_id=message_id, packet_type=packet_type)
            if packet_type:
                yield packet_type.deserialize(message_bytes)

    def get_next_request_id(self) -> int:
        self._request_counter += 1
        source = b'\2'  # 2 is for BLE source
        counter = int.to_bytes(self._request_counter, length=3, byteorder='big').ljust(3, b'\0')
        return int.from_bytes(source + counter)
