mirror of
https://github.com/esphome/esphome.git
synced 2026-10-22 05:46:12 +00:00
Add the frame collision cases and zone numbers to the LD2450 loopback harness
The template now injects footer bytes inside payloads, cut frames, a bogus length and garbage before a frame, and the driver prints number states so the zone readback can be checked without a radar.
This commit is contained in:
@@ -27,3 +27,16 @@ blocks), then `txsum.py LOGFILE` lists the TX frames per step; diff the summarie
|
||||
own commands back and logs `Invalid status` for each, which is harmless. The boot readback of the baud rate select
|
||||
comes from the UART setting, so a second build at `baud: "9600"` checks the flash table lookup.
|
||||
Results: https://github.com/esphome/esphome/pull/21349#issuecomment-6332320026
|
||||
|
||||
## Frame splitter collisions (#21357)
|
||||
|
||||
The loopback template also carries the zone 1 numbers and seven collision buttons: a periodic frame with the
|
||||
command footer inside target 1, zone acks with `55 CC` and with `04 03 02 01` inside the coordinates, a periodic
|
||||
frame cut after 12 bytes followed by a zone ack, a frame missing its last byte followed by a complete one, a bogus
|
||||
255 byte length then a frame, and garbage then a frame. Judge by the state updates plus the `Handling Periodic` and
|
||||
`Handling Ack` lines. Through a real radar the set zone ack is sometimes corrupted by the radar itself (its tail
|
||||
replaced by the periodic frame it was sending, for example `04 03 03 03 00 ... 55 CC`), so count readbacks over at
|
||||
least 24 selects per build and read the raw bytes with `uart: debug: direction: RX` (`!extend` the package's uart
|
||||
id) before blaming the parser; the API log stream drops lines under that dump volume, so some misses stay
|
||||
unclassified.
|
||||
Results: https://github.com/esphome/esphome/pull/21357#issuecomment-6333244886
|
||||
|
||||
@@ -14,6 +14,7 @@ from aioesphomeapi import (
|
||||
APIClient,
|
||||
ButtonInfo,
|
||||
LogLevel,
|
||||
NumberState,
|
||||
SelectInfo,
|
||||
SelectState,
|
||||
SensorInfo,
|
||||
@@ -49,6 +50,8 @@ async def run(c: APIClient, log) -> None:
|
||||
missing = " (missing)" if getattr(s, "missing_state", False) else ""
|
||||
if isinstance(s, TextSensorState):
|
||||
print(f"{stamp()} TXT {e.name} = {s.state!r}{missing}", flush=True)
|
||||
elif isinstance(s, NumberState):
|
||||
print(f"{stamp()} NUM {e.name} = {s.state:.0f}{missing}", flush=True)
|
||||
elif isinstance(s, SelectState):
|
||||
print(f"{stamp()} SEL {e.name} = {s.state!r}{missing}", flush=True)
|
||||
elif (
|
||||
|
||||
@@ -160,3 +160,99 @@ button:
|
||||
name: Set Baud Bogus By Name
|
||||
on_press:
|
||||
- lambda: id(radar).set_baud_rate("Bogus");
|
||||
# target 1 at x 772, y 258: bytes 04 03 02 01 are the command footer
|
||||
- platform: template
|
||||
name: Frame CmdFooter In Payload
|
||||
on_press:
|
||||
- uart.write:
|
||||
id: radar_uart
|
||||
data: [0xAA, 0xFF, 0x03, 0x00,
|
||||
0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x64, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x55, 0xCC]
|
||||
# zone ack, type Detection, zone 1 x1 = 0xCC55: bytes 55 CC are the periodic footer
|
||||
- platform: template
|
||||
name: Zone Ack DataFooter In Payload
|
||||
on_press:
|
||||
- uart.write:
|
||||
id: radar_uart
|
||||
data: [0xFD, 0xFC, 0xFB, 0xFA, 0x1E, 0x00, 0xC1, 0x01, 0x00, 0x00, 0x01, 0x00,
|
||||
0x55, 0xCC, 0xC8, 0x00, 0xDC, 0x05, 0xB8, 0x0B, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x03, 0x02, 0x01]
|
||||
# zone ack, type Filter, zone 1 x1 = 0x0304 and y1 = 0x0102: bytes 04 03 02 01 are the command footer
|
||||
- platform: template
|
||||
name: Zone Ack CmdFooter In Payload
|
||||
on_press:
|
||||
- uart.write:
|
||||
id: radar_uart
|
||||
data: [0xFD, 0xFC, 0xFB, 0xFA, 0x1E, 0x00, 0xC1, 0x01, 0x00, 0x00, 0x02, 0x00,
|
||||
0x04, 0x03, 0x02, 0x01, 0xDC, 0x05, 0xB8, 0x0B, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x03, 0x02, 0x01]
|
||||
# a periodic frame cut after 12 bytes, then a complete zone ack (type Disabled, zeros)
|
||||
- platform: template
|
||||
name: Cut Frame Then Zone Ack
|
||||
on_press:
|
||||
- uart.write:
|
||||
id: radar_uart
|
||||
data: [0xAA, 0xFF, 0x03, 0x00, 0x00, 0x00, 0xE8, 0x83, 0x14, 0x00, 0x64, 0x00,
|
||||
0xFD, 0xFC, 0xFB, 0xFA, 0x1E, 0x00, 0xC1, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x03, 0x02, 0x01]
|
||||
# a periodic frame missing its last byte, then a complete one (target 1 moving away)
|
||||
- platform: template
|
||||
name: Cut Frame Then Frame
|
||||
on_press:
|
||||
- uart.write:
|
||||
id: radar_uart
|
||||
data: [0xAA, 0xFF, 0x03, 0x00,
|
||||
0x00, 0x00, 0xE8, 0x83, 0x14, 0x00, 0x64, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x55,
|
||||
0xAA, 0xFF, 0x03, 0x00,
|
||||
0x00, 0x00, 0xE8, 0x83, 0x14, 0x80, 0x64, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x55, 0xCC]
|
||||
# a command header claiming a 255 byte payload, then a complete periodic frame (target 1 stationary)
|
||||
- platform: template
|
||||
name: Bogus Length Then Frame
|
||||
on_press:
|
||||
- uart.write:
|
||||
id: radar_uart
|
||||
data: [0xFD, 0xFC, 0xFB, 0xFA, 0xFF, 0x00,
|
||||
0xAA, 0xFF, 0x03, 0x00,
|
||||
0x00, 0x00, 0xE8, 0x83, 0x00, 0x00, 0x64, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x55, 0xCC]
|
||||
# five garbage bytes, then a complete periodic frame (target 1 approaching)
|
||||
- platform: template
|
||||
name: Garbage Then Frame
|
||||
on_press:
|
||||
- uart.write:
|
||||
id: radar_uart
|
||||
data: [0x01, 0x02, 0x03, 0x42, 0x99,
|
||||
0xAA, 0xFF, 0x03, 0x00,
|
||||
0x00, 0x00, 0xE8, 0x83, 0x14, 0x00, 0x64, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x55, 0xCC]
|
||||
|
||||
number:
|
||||
- platform: ld2450
|
||||
presence_timeout:
|
||||
name: Presence Timeout
|
||||
zone_1:
|
||||
x1:
|
||||
name: Z1 X1
|
||||
y1:
|
||||
name: Z1 Y1
|
||||
x2:
|
||||
name: Z1 X2
|
||||
y2:
|
||||
name: Z1 Y2
|
||||
|
||||
Reference in New Issue
Block a user