Allow UART debug configuration with no after: definition (#2753)

This commit is contained in:
Maurice Makaay 2021-11-18 22:41:26 +01:00 committed by GitHub
parent 448e1690aa
commit 9e1c3e8f01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -94,17 +94,21 @@ UART_DIRECTIONS = {
"BOTH": UARTDirection.UART_DIRECTION_BOTH,
}
AFTER_DEFAULTS = {CONF_BYTES: 256, CONF_TIMEOUT: "100ms"}
DEBUG_SCHEMA = cv.Schema(
{
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(UARTDebugger),
cv.Optional(CONF_DIRECTION, default="BOTH"): cv.enum(
UART_DIRECTIONS, upper=True
),
cv.Optional(CONF_AFTER): cv.Schema(
cv.Optional(CONF_AFTER, default=AFTER_DEFAULTS): cv.Schema(
{
cv.Optional(CONF_BYTES, default=256): cv.validate_bytes,
cv.Optional(
CONF_TIMEOUT, default="100ms"
CONF_BYTES, default=AFTER_DEFAULTS[CONF_BYTES]
): cv.validate_bytes,
cv.Optional(
CONF_TIMEOUT, default=AFTER_DEFAULTS[CONF_TIMEOUT]
): cv.positive_time_period_milliseconds,
cv.Optional(CONF_DELIMITER): cv.templatable(validate_raw_data),
}

View file

@ -39,6 +39,12 @@ uart:
tx_pin: GPIO22
rx_pin: GPIO23
baud_rate: 115200
# Specifically added for testing debug with no after: definition.
debug:
dummy_receiver: false
direction: rx
sequence:
- lambda: UARTDebug::log_hex(direction, bytes, ':');
ota:
safe_mode: True