From db5c44532933f2aa45832cd8a4f0683daed2cedd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20H=C3=A4drich?= Date: Mon, 19 Jan 2026 19:40:39 +0100 Subject: [PATCH 1/3] Use the `block`-Parameter to wait --- dali/DALI/gear/gear_action.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/dali/DALI/gear/gear_action.py b/dali/DALI/gear/gear_action.py index e8d8962..e7bd763 100644 --- a/dali/DALI/gear/gear_action.py +++ b/dali/DALI/gear/gear_action.py @@ -111,12 +111,8 @@ def write_gear_frame_and_wait( logger.debug("write gear frame and wait for finish") frame = address_byte << 8 | opcode_byte dali.transmit( - DaliFrame(length=DaliFrameLength.GEAR, data=frame, send_twice=send_twice) + DaliFrame(length=DaliFrameLength.GEAR, data=frame, send_twice=send_twice), block=True ) - dali.get(DaliTimeout.DEFAULT.value) - while True: - if dali.data == frame: - break @typechecked From d50afe89a50e4d353790cd08bb6d39cc1a45ee7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20H=C3=A4drich?= Date: Mon, 19 Jan 2026 19:41:36 +0100 Subject: [PATCH 2/3] Fix enumeration --- dali/DALI/gear/gear_enumerate.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dali/DALI/gear/gear_enumerate.py b/dali/DALI/gear/gear_enumerate.py index 891cbc6..f431353 100644 --- a/dali/DALI/gear/gear_enumerate.py +++ b/dali/DALI/gear/gear_enumerate.py @@ -12,12 +12,13 @@ def prepare_bus(dali: DaliInterface) -> None: # INITIALISE ALL - write_gear_frame_and_wait(dali, GearSpecialCommandOpcode.INITIALISE, 0, True) + write_gear_frame_and_wait(dali, GearSpecialCommandOpcode.INITIALISE, 0xFF, True) def clear_short_addresses(dali: DaliInterface) -> None: set_gear_dtr0(dali, 0xFF) address = GearAddress() + address.broadcast() write_gear_frame_and_wait( dali, address.byte, GearConfigureCommandOpcode.SET_SHORT_ADDRESS, True ) @@ -26,6 +27,7 @@ def clear_short_addresses(dali: DaliInterface) -> None: def remove_from_all_groups(dali: DaliInterface) -> None: for group in range(DaliMax.GEAR_GROUP): address = GearAddress() + address.broadcast() write_gear_frame_and_wait( dali, address.byte, GearConfigureCommandOpcode.REMOVE_GROUP + group, True ) @@ -50,7 +52,7 @@ def set_search_address(dali: DaliInterface, search: int) -> None: def compare(dali: DaliInterface) -> bool: data = GearSpecialCommandOpcode.COMPARE << 8 - result = dali.query_reply(DaliFrame(length=DaliFrameLength.Gear, data=data)) + result = dali.query_reply(DaliFrame(length=DaliFrameLength.GEAR, data=data)) return result.length == DaliFrameLength.BACKWARD @@ -75,9 +77,7 @@ def set_short_address(dali: DaliInterface, new_short_address: int) -> bool: GearSpecialCommandOpcode.PROGRAM_SHORT_ADDRESS, ((new_short_address << 1) | 1), ) - data = DeviceSpecialCommandOpcode.VERIFY_SHORT_ADDRESS << 8 + ( - new_short_address & 0xFF - ) + data = (GearSpecialCommandOpcode.VERIFY_SHORT_ADDRESS << 8) | ((new_short_address << 1) | 1) result = dali.query_reply(DaliFrame(length=DaliFrameLength.GEAR, data=data)) if result.length == DaliFrameLength.BACKWARD: write_gear_frame(dali, GearSpecialCommandOpcode.WITHDRAW) From a6a58d096f4c55636e2da67f28b41fd00cd380e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20H=C3=A4drich?= Date: Mon, 19 Jan 2026 19:58:55 +0100 Subject: [PATCH 3/3] Fix linter findings --- dali/DALI/gear/gear_action.py | 4 +--- dali/DALI/gear/gear_enumerate.py | 8 ++------ dali/DALI/gear/gear_query.py | 3 +-- tests/cli/test_device_query.py | 1 - tests/cli/test_device_special.py | 1 - tests/cli/test_gear_basic.py | 1 - tests/cli/test_gear_configure.py | 1 - tests/cli/test_gear_special.py | 1 - 8 files changed, 4 insertions(+), 16 deletions(-) diff --git a/dali/DALI/gear/gear_action.py b/dali/DALI/gear/gear_action.py index e7bd763..d496bce 100644 --- a/dali/DALI/gear/gear_action.py +++ b/dali/DALI/gear/gear_action.py @@ -110,9 +110,7 @@ def write_gear_frame_and_wait( ) -> None: logger.debug("write gear frame and wait for finish") frame = address_byte << 8 | opcode_byte - dali.transmit( - DaliFrame(length=DaliFrameLength.GEAR, data=frame, send_twice=send_twice), block=True - ) + dali.transmit(DaliFrame(length=DaliFrameLength.GEAR, data=frame, send_twice=send_twice), block=True) @typechecked diff --git a/dali/DALI/gear/gear_enumerate.py b/dali/DALI/gear/gear_enumerate.py index f431353..abb7948 100644 --- a/dali/DALI/gear/gear_enumerate.py +++ b/dali/DALI/gear/gear_enumerate.py @@ -19,18 +19,14 @@ def clear_short_addresses(dali: DaliInterface) -> None: set_gear_dtr0(dali, 0xFF) address = GearAddress() address.broadcast() - write_gear_frame_and_wait( - dali, address.byte, GearConfigureCommandOpcode.SET_SHORT_ADDRESS, True - ) + write_gear_frame_and_wait(dali, address.byte, GearConfigureCommandOpcode.SET_SHORT_ADDRESS, True) def remove_from_all_groups(dali: DaliInterface) -> None: for group in range(DaliMax.GEAR_GROUP): address = GearAddress() address.broadcast() - write_gear_frame_and_wait( - dali, address.byte, GearConfigureCommandOpcode.REMOVE_GROUP + group, True - ) + write_gear_frame_and_wait(dali, address.byte, GearConfigureCommandOpcode.REMOVE_GROUP + group, True) def request_new_random_addresses(dali: DaliInterface) -> None: diff --git a/dali/DALI/gear/gear_query.py b/dali/DALI/gear/gear_query.py index 09b766b..7f6bc81 100644 --- a/dali/DALI/gear/gear_query.py +++ b/dali/DALI/gear/gear_query.py @@ -1,9 +1,8 @@ """Control gear query command implementations.""" import click -from dali_interface import DaliInterface - from dali.DALI.device.device_query import device_address_option +from dali_interface import DaliInterface from .gear_action import query_gear_and_display_reply, query_gear_value from .gear_opcode import GearQueryCommandOpcode diff --git a/tests/cli/test_device_query.py b/tests/cli/test_device_query.py index f6500d0..5f494a5 100644 --- a/tests/cli/test_device_query.py +++ b/tests/cli/test_device_query.py @@ -2,7 +2,6 @@ import pytest from click.testing import CliRunner - from dali.DALI.system.constants import DaliMax from dali.dali_cli import cli diff --git a/tests/cli/test_device_special.py b/tests/cli/test_device_special.py index 2437f41..e446e98 100644 --- a/tests/cli/test_device_special.py +++ b/tests/cli/test_device_special.py @@ -2,7 +2,6 @@ import pytest from click.testing import CliRunner - from dali.dali_cli import cli diff --git a/tests/cli/test_gear_basic.py b/tests/cli/test_gear_basic.py index d5f5a2c..b733072 100644 --- a/tests/cli/test_gear_basic.py +++ b/tests/cli/test_gear_basic.py @@ -2,7 +2,6 @@ import pytest from click.testing import CliRunner - from dali.dali_cli import cli diff --git a/tests/cli/test_gear_configure.py b/tests/cli/test_gear_configure.py index ba4ad83..7dff8f4 100644 --- a/tests/cli/test_gear_configure.py +++ b/tests/cli/test_gear_configure.py @@ -2,7 +2,6 @@ import pytest from click.testing import CliRunner - from dali.dali_cli import cli diff --git a/tests/cli/test_gear_special.py b/tests/cli/test_gear_special.py index f6a8557..fcfc653 100644 --- a/tests/cli/test_gear_special.py +++ b/tests/cli/test_gear_special.py @@ -2,7 +2,6 @@ import pytest from click.testing import CliRunner - from dali.dali_cli import cli