From 3d9174a12498e87ad18861fcb0e377869798bc5e Mon Sep 17 00:00:00 2001 From: Andrey Date: Thu, 1 Oct 2026 22:40:19 +0300 Subject: [PATCH] =?UTF-8?q?fix(ump):=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5?= =?UTF-8?q?=D1=80=D0=B6=D0=B0=D1=82=D1=8C=20=D0=B8=D0=BD=D0=B4=D0=B5=D0=BA?= =?UTF-8?q?=D1=81=D0=BD=D0=BE=D0=B5=20=D1=87=D1=82=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D0=B5=D0=B9=20=D0=9F=D0=9C67?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/set_devices/ump_logger.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/python/set_devices/ump_logger.py b/python/set_devices/ump_logger.py index 1ecb4f1..01004d7 100644 --- a/python/set_devices/ump_logger.py +++ b/python/set_devices/ump_logger.py @@ -68,17 +68,20 @@ FIELDS = ( ) -def request(controller: int, function: int, address: int, value: int) -> bytes: +def request(controller: int, function: int, address: int, value: int, *, record_words: int = WORDS) -> bytes: if not 0 <= controller <= 255 or not 0 <= value <= 65535: raise ValueError('Недопустимый адрес контроллера или значение') + if record_words not in (40, 42): + raise ValueError('Неверный размер записи логгера') + capacity = {40: 800, 42: 760}[record_words] if function == 3: valid = ((address == BASE and value == 16) or (address == DATA and 1 <= value <= 120 and (value % WORDS == 0 or value in (42, 84))) or (address == LIVE and value == 124) or (address == EMU_CONTROL and value == 4) or (address == FAST_CAPABILITY and value == 4) - or (FAST_DATA <= address < FAST_DATA + CAPACITY * WORDS - and (address - FAST_DATA) % WORDS == 0 - and 1 <= value <= 120 and value % WORDS == 0 - and address + value <= FAST_DATA + CAPACITY * WORDS)) + or (FAST_DATA <= address < FAST_DATA + capacity * record_words + and (address - FAST_DATA) % record_words == 0 + and 1 <= value <= 120 and value % record_words == 0 + and address + value <= FAST_DATA + capacity * record_words)) else: valid = function == 6 and (address in (BASE, BASE + 1, BASE + 2, BASE + 3) or (address == EMU_CONTROL + 2 and value in (0, 1)))