2 #ifdef USE_UART_DEBUGGER 12 static const char *
const TAG =
"uart_debug";
42 this->
bytes_.push_back(byte);
88 while (this->available() && count--) {
89 this->read_byte(&data);
105 size_t len = bytes.size();
107 for (
size_t i = 0; i <
len; i++) {
111 sprintf(buf,
"%02X", bytes[i]);
114 ESP_LOGD(TAG,
"%s", res.c_str());
125 size_t len = bytes.size();
127 for (
size_t i = 0; i <
len; i++) {
130 }
else if (bytes[i] == 8) {
132 }
else if (bytes[i] == 9) {
134 }
else if (bytes[i] == 10) {
136 }
else if (bytes[i] == 11) {
138 }
else if (bytes[i] == 12) {
140 }
else if (bytes[i] == 13) {
142 }
else if (bytes[i] == 27) {
144 }
else if (bytes[i] == 34) {
146 }
else if (bytes[i] == 39) {
148 }
else if (bytes[i] == 92) {
150 }
else if (bytes[i] < 32 || bytes[i] > 127) {
151 sprintf(buf,
"\\x%02X", bytes[i]);
158 ESP_LOGD(TAG,
"%s", res.c_str());
164 size_t len = bytes.size();
170 for (
size_t i = 0; i <
len; i++) {
176 ESP_LOGD(TAG,
"%s", res.c_str());
182 size_t len = bytes.size();
189 for (
size_t i = 0; i <
len; i++) {
193 sprintf(buf,
"0b" BYTE_TO_BINARY_PATTERN
" (0x%02X)", BYTE_TO_BINARY(bytes[i]), bytes[i]);
196 ESP_LOGD(TAG,
"%s", res.c_str());
void trigger_after_timeout_()
static void log_string(UARTDirection direction, std::vector< uint8_t > bytes)
Log the bytes as string values, escaping unprintable characters.
bool is_my_direction_(UARTDirection direction)
UARTDirection for_direction_
static void log_binary(UARTDirection direction, std::vector< uint8_t > bytes, uint8_t separator)
Log the bytes as '<binary> (<hex>)' values, separated by the provided separator.
void trigger_after_bytes_()
uint32_t IRAM_ATTR HOT millis()
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
static void log_hex(UARTDirection direction, std::vector< uint8_t > bytes, uint8_t separator)
Log the bytes as hex values, separated by the provided separator character.
void store_byte_(UARTDirection direction, uint8_t byte)
std::vector< uint8_t > bytes_
UARTDebugger(UARTComponent *parent)
UARTDirection last_direction_
void trigger_after_direction_change_(UARTDirection direction)
size_t after_delimiter_pos_
void trigger_after_delimiter_(uint8_t byte)
std::string to_string(int value)
Implementation of SPI Controller mode.
std::vector< uint8_t > bytes
void add_debug_callback(std::function< void(UARTDirection, uint8_t)> &&callback)
static void log_int(UARTDirection direction, std::vector< uint8_t > bytes, uint8_t separator)
Log the bytes as integer values, separated by the provided separator character.
bool has_buffered_bytes_()
void IRAM_ATTR HOT delay(uint32_t ms)
std::vector< uint8_t > after_delimiter_