add VBANCMDPacketError to exception hierarchy

raise them when we fail to validate incoming packets.

add VbanRTRequestHeader post_init to validate the provided bps value.

VbanRTSubscribeHeader and VbanRTRequestHeader properties now return int type. They are then directly packed into the header.
This commit is contained in:
2026-03-09 05:19:41 +00:00
parent 98ec9b715f
commit 242401e294
4 changed files with 116 additions and 60 deletions

View File

@@ -3,7 +3,8 @@ import threading
import time
from .enums import NBS
from .error import VBANCMDConnectionError
from .error import VBANCMDConnectionError, VBANCMDPacketError
from .packet.enums import SubProtocols
from .packet.headers import (
HEADER_SIZE,
VbanRTPacket,
@@ -81,8 +82,13 @@ class Producer(threading.Thread):
try:
header = VbanRTResponseHeader.from_bytes(data[:HEADER_SIZE])
except ValueError as e:
self.logger.debug(f'Error parsing response packet: {e}')
except VBANCMDPacketError as e:
match e.protocol:
case SubProtocols.SERVICE:
# Silently ignore periodic SERVICE packets unrelated to vban-cmd
pass
case _:
self.logger.debug(f'Error parsing response packet: {e}')
continue
match header.format_nbs: