more errors fixed

This commit is contained in:
Guido Schreuder 2024-02-19 23:22:57 +01:00
parent 55183c0383
commit 0efa34f32f
4 changed files with 12 additions and 17 deletions

View file

@ -217,7 +217,7 @@ void Ebus::process_received_char(unsigned char received_byte) {
this->handle_response_(this->receiving_telegram_);
}
void Ebus::add_send_response_handler(const std::function<uint8_t(Telegram &, uint8_t *)>& send_response_handler) {
void Ebus::add_send_response_handler(const std::function<uint8_t(Telegram &, uint8_t *)> &send_response_handler) {
send_response_handlers_.push_back(send_response_handler);
}

View file

@ -22,27 +22,21 @@ class Elf {
class Ebus {
public:
void set_primary_address(uint8_t primary_address) {
this->primary_address_ = primary_address;
}
void set_max_tries(uint8_t max_tries) {
this->max_tries_ = max_tries;
}
void set_max_lock_counter(uint8_t max_lock_counter) {
this->max_lock_counter_ = max_lock_counter;
}
void set_primary_address(uint8_t primary_address) { this->primary_address_ = primary_address; }
void set_max_tries(uint8_t max_tries) { this->max_tries_ = max_tries; }
void set_max_lock_counter(uint8_t max_lock_counter) { this->max_lock_counter_ = max_lock_counter; }
void set_uart_send_function(std::function<void(const char *, int16_t)> uart_send) {
this->uart_send_ = std::move(uart_send);
}
void set_queue_received_telegram_function(std::function<void(Telegram &telegram)> queue_received_telegram) {
this->queue_received_telegram_ = std::move(queue_received_telegram);
}
void set_dequeue_command_function(const std::function<bool(void *const)>& dequeue_command) {
void set_dequeue_command_function(const std::function<bool(void *const)> &dequeue_command) {
this->dequeue_command_ = dequeue_command;
}
void process_received_char(unsigned char received_byte);
void add_send_response_handler(const std::function<uint8_t(Telegram &, uint8_t *)>& send_response_handler);
void add_send_response_handler(const std::function<uint8_t(Telegram &, uint8_t *)> &send_response_handler);
protected:
uint8_t primary_address_;

View file

@ -89,7 +89,7 @@ void EbusComponent::setup_uart_() {
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 2,
.use_ref_tick = true,
.source_clk = UART_SCLK_REF_TICK,
};
ESP_ERROR_CHECK(uart_param_config(this->uart_num_, &uart_config));

View file

@ -79,13 +79,14 @@ uint8_t Telegram::get_response_crc() { return this->response_buffer_[RESPONSE_OF
void Telegram::push_response_data(uint8_t cr) {
this->push_buffer_(cr, response_buffer_, &response_buffer_pos_, &response_rolling_crc_,
RESPONSE_OFFSET + get_response_nn());
RESPONSE_OFFSET + get_response_nn());
}
bool Telegram::is_response_complete() {
return (this->state_ > TelegramState::waitForSyn || this->state_ == TelegramState::endCompleted) &&
(this->response_buffer_pos_ > RESPONSE_OFFSET) &&
(this->response_buffer_pos_ == (RESPONSE_OFFSET + this->get_response_nn() + 1)) && !this->wait_for_escaped_char_;
(this->response_buffer_pos_ == (RESPONSE_OFFSET + this->get_response_nn() + 1)) &&
!this->wait_for_escaped_char_;
}
bool Telegram::is_response_valid() {
@ -94,8 +95,8 @@ bool Telegram::is_response_valid() {
bool Telegram::is_request_complete() {
return (this->state_ > TelegramState::waitForSyn || this->state_ == TelegramState::endCompleted) &&
(this->request_buffer_pos_ > OFFSET_DATA) && (this->request_buffer_pos_ == (OFFSET_DATA + this->get_nn() + 1)) &&
!this->wait_for_escaped_char_;
(this->request_buffer_pos_ > OFFSET_DATA) &&
(this->request_buffer_pos_ == (OFFSET_DATA + this->get_nn() + 1)) && !this->wait_for_escaped_char_;
}
bool Telegram::is_request_valid() {
return this->is_request_complete() && this->get_request_crc() == this->request_rolling_crc_;