Merge remote-tracking branch 'upstream/dev' into integration

# Conflicts:
#	tests/integration/fixtures/uart_mock_ld2450.yaml
#	tests/integration/test_uart_mock_ld2450.py
This commit is contained in:
J. Nick Koston
2026-03-08 14:57:36 -10:00
4 changed files with 27 additions and 28 deletions
+1 -1
View File
@@ -14,6 +14,7 @@ from esphome.const import (
CONF_BOARD,
CONF_COMPONENTS,
CONF_DISABLED,
CONF_ENABLE_FULL_PRINTF,
CONF_ENABLE_OTA_ROLLBACK,
CONF_ESPHOME,
CONF_FRAMEWORK,
@@ -954,7 +955,6 @@ CONF_HEAP_IN_IRAM = "heap_in_iram"
CONF_LOOP_TASK_STACK_SIZE = "loop_task_stack_size"
CONF_USE_FULL_CERTIFICATE_BUNDLE = "use_full_certificate_bundle"
CONF_DISABLE_DEBUG_STUBS = "disable_debug_stubs"
CONF_ENABLE_FULL_PRINTF = "enable_full_printf"
CONF_DISABLE_OCD_AWARE = "disable_ocd_aware"
CONF_DISABLE_USB_SERIAL_JTAG_SECONDARY = "disable_usb_serial_jtag_secondary"
CONF_DISABLE_DEV_NULL_VFS = "disable_dev_null_vfs"
+1
View File
@@ -356,6 +356,7 @@ CONF_EFFECT = "effect"
CONF_EFFECTS = "effects"
CONF_ELSE = "else"
CONF_ENABLE_BTM = "enable_btm"
CONF_ENABLE_FULL_PRINTF = "enable_full_printf"
CONF_ENABLE_IPV6 = "enable_ipv6"
CONF_ENABLE_ON_BOOT = "enable_on_boot"
CONF_ENABLE_OTA_ROLLBACK = "enable_ota_rollback"
@@ -93,12 +93,17 @@ uart_mock:
- delay: 100ms
inject_rx: [0xAA, 0xFF, 0x03, 0x00, 0x01, 0x02, 0x03, 0x04]
# Phase 4 (t=600ms): Overflow - inject 50 bytes of 0xFF (MAX_LINE_LENGTH=45)
# Phase 4 (t=600ms): Overflow - inject 75 bytes of 0xFF (MAX_LINE_LENGTH=45)
# Buffer has 15 bytes from phases 2+3.
# Overflow math: need 29 bytes to fill positions 15-43 (buffer_pos_=44),
# then byte 30 at position 44 = MAX_LINE_LENGTH-1 triggers overflow.
# After overflow, buffer_pos_ = 0. Remaining 0xFF bytes accumulate
# until another overflow or until valid data arrives.
# readline_() stores bytes while buffer_pos_ < 44. When buffer_pos_ == 44,
# the next byte triggers overflow: logs warning, resets buffer_pos_ to 0,
# and discards that byte.
#
# First overflow: 29 bytes fill positions 15-43 (buffer_pos_=44), byte 30
# triggers overflow (discarded). Total consumed: 30 bytes.
# Second overflow: 44 bytes fill positions 0-43 (buffer_pos_=44), byte 45
# triggers overflow (discarded). Total consumed: 30+45 = 75 bytes.
# After both overflows, buffer_pos_ = 0 (clean state for recovery frame).
- delay: 200ms
inject_rx:
[
@@ -107,6 +112,9 @@ uart_mock:
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
]
# Phase 5 (t=700ms): Valid frame after overflow - recovery test
+12 -22
View File
@@ -189,26 +189,16 @@ async def test_uart_mock_ld2450(
# Recovery frame values (Phase 5, after overflow):
# Target 1: X=300, Y=400, Distance=500, Speed=30 (moving away)
# target_count=1, moving=1, still=0
recovery_idx = next(
i
for i, v in enumerate(collector.sensor_states["target_1_distance"])
if v == pytest.approx(500.0, abs=1.0)
#
# Note: throttle filters cause sensor lists to have different lengths,
# so we check each value appeared somewhere rather than using a shared index.
assert (
pytest.approx(500.0, abs=1.0)
in collector.sensor_states["target_1_distance"]
)
assert collector.sensor_states["target_1_x"][recovery_idx] == pytest.approx(
300.0
)
assert collector.sensor_states["target_1_y"][recovery_idx] == pytest.approx(
400.0
)
assert collector.sensor_states["target_1_speed"][recovery_idx] == pytest.approx(
30.0
)
assert collector.sensor_states["target_count"][recovery_idx] == pytest.approx(
1.0
)
assert collector.sensor_states["moving_target_count"][
recovery_idx
] == pytest.approx(1.0)
assert collector.sensor_states["still_target_count"][
recovery_idx
] == pytest.approx(0.0)
assert pytest.approx(300.0) in collector.sensor_states["target_1_x"]
assert pytest.approx(400.0) in collector.sensor_states["target_1_y"]
assert pytest.approx(30.0) in collector.sensor_states["target_1_speed"]
assert pytest.approx(1.0) in collector.sensor_states["target_count"]
assert pytest.approx(1.0) in collector.sensor_states["moving_target_count"]
assert pytest.approx(0.0) in collector.sensor_states["still_target_count"]