add dump raw option
parent
c9bbbd574c
commit
6240f5455f
|
|
@ -8,6 +8,7 @@ DEPENDENCIES = ["uart"]
|
|||
|
||||
CONF_RECEIVE_TIMEOUT = "receive_timeout"
|
||||
CONF_SHOW_LOG = "show_log"
|
||||
CONF_DUMP_RAW = "dump_raw"
|
||||
CONF_CUSTOM_PATTERN = "custom_pattern"
|
||||
|
||||
# Define the namespace and the Hub component class
|
||||
|
|
@ -28,6 +29,7 @@ CONFIG_SCHEMA = cv.All(
|
|||
cv.GenerateID(): cv.declare_id(DlmsPushComponent),
|
||||
cv.Optional(CONF_RECEIVE_TIMEOUT, default="50ms"): cv.positive_time_period_milliseconds,
|
||||
cv.Optional(CONF_SHOW_LOG, default=False): cv.boolean,
|
||||
cv.Optional(CONF_DUMP_RAW, default=False): cv.boolean,
|
||||
cv.Optional(CONF_CUSTOM_PATTERN, default=""): cv.string,
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -96,6 +96,20 @@ void DlmsPushComponent::process_frame_() {
|
|||
ESP_LOGD(TAG, "PUSH frame size: %zu bytes", this->rx_buffer_len_);
|
||||
}
|
||||
|
||||
if (this->dump_raw_) {
|
||||
ESP_LOGD(TAG, "--- BEGIN RAW DUMP ---");
|
||||
for (size_t i = 0; i < this->rx_buffer_len_; i += 32) {
|
||||
std::string line;
|
||||
for (size_t j = 0; j < 32 && (i + j) < this->rx_buffer_len_; j++) {
|
||||
char buf[4];
|
||||
snprintf(buf, sizeof(buf), "%02X ", this->rx_buffer_[i + j]);
|
||||
line += buf;
|
||||
}
|
||||
ESP_LOGD(TAG, "%04X: %s", (unsigned int)i, line.c_str());
|
||||
}
|
||||
ESP_LOGD(TAG, "--- END RAW DUMP ---");
|
||||
}
|
||||
|
||||
auto callback = [this](const char *obis_code, float float_val, const char *str_val, bool is_numeric) {
|
||||
this->on_data_parsed_(obis_code, float_val, str_val, is_numeric);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ class DlmsPushComponent : public Component, public uart::UARTDevice {
|
|||
|
||||
uint32_t receive_timeout_ms_{50};
|
||||
bool show_log_{false};
|
||||
bool cump_raw_{false};
|
||||
std::string custom_pattern_{""};
|
||||
|
||||
static const size_t MAX_RX_BUFFER_SIZE = 2048;
|
||||
|
|
|
|||
Loading…
Reference in New Issue