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 Jesse Hills
parent 6226dae05c
commit d30e2f2a4f
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A
2 changed files with 13 additions and 3 deletions

View file

@ -94,17 +94,21 @@ UART_DIRECTIONS = {
"BOTH": UARTDirection.UART_DIRECTION_BOTH, "BOTH": UARTDirection.UART_DIRECTION_BOTH,
} }
AFTER_DEFAULTS = {CONF_BYTES: 256, CONF_TIMEOUT: "100ms"}
DEBUG_SCHEMA = cv.Schema( DEBUG_SCHEMA = cv.Schema(
{ {
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(UARTDebugger), cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(UARTDebugger),
cv.Optional(CONF_DIRECTION, default="BOTH"): cv.enum( cv.Optional(CONF_DIRECTION, default="BOTH"): cv.enum(
UART_DIRECTIONS, upper=True 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( 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.positive_time_period_milliseconds,
cv.Optional(CONF_DELIMITER): cv.templatable(validate_raw_data), cv.Optional(CONF_DELIMITER): cv.templatable(validate_raw_data),
} }

View file

@ -39,6 +39,12 @@ uart:
tx_pin: GPIO22 tx_pin: GPIO22
rx_pin: GPIO23 rx_pin: GPIO23
baud_rate: 115200 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: ota:
safe_mode: True safe_mode: True