mirror of
https://github.com/esphome/esphome.git
synced 2025-03-15 15:18:16 +00:00
mhz19: flush TX queue before reading reply
otherwise there might not be reply to ready since not all data might be sent over TX line Signed-off-by: Igor Mammedov <imammedo@redhat.com>
This commit is contained in:
parent
fd6e49f94d
commit
8d45dff31b
@ -53,12 +53,12 @@ void MHZ19Component::update() {
|
|||||||
bool MHZ19Component::mhz19_write_command_(const uint8_t *command, uint8_t *response) {
|
bool MHZ19Component::mhz19_write_command_(const uint8_t *command, uint8_t *response) {
|
||||||
this->write_array(command, MHZ19_REQUEST_LENGTH);
|
this->write_array(command, MHZ19_REQUEST_LENGTH);
|
||||||
this->write_byte(mhz19_checksum(command));
|
this->write_byte(mhz19_checksum(command));
|
||||||
|
this->flush();
|
||||||
|
|
||||||
if (response == nullptr)
|
if (response == nullptr)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
bool ret = this->read_array(response, MHZ19_RESPONSE_LENGTH);
|
bool ret = this->read_array(response, MHZ19_RESPONSE_LENGTH);
|
||||||
this->flush();
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
float MHZ19Component::get_setup_priority() const { return setup_priority::DATA; }
|
float MHZ19Component::get_setup_priority() const { return setup_priority::DATA; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user