Make UART flush function consistent (#748)

See also https://github.com/esphome/esphome/commit/78be9d29376d5fdcff81874540c540eb80a338f6
This commit is contained in:
Otto Winter
2019-10-17 16:54:38 +02:00
committed by GitHub
parent e15071228e
commit 78c1adafcd
4 changed files with 9 additions and 6 deletions
+5 -4
View File
@@ -77,16 +77,17 @@ void MHZ19Component::abc_disable() {
}
bool MHZ19Component::mhz19_write_command_(const uint8_t *command, uint8_t *response) {
this->flush();
// Empty RX Buffer
while (this->available())
this->read();
this->write_array(command, MHZ19_REQUEST_LENGTH);
this->write_byte(mhz19_checksum(command));
this->flush();
if (response == nullptr)
return true;
bool ret = this->read_array(response, MHZ19_RESPONSE_LENGTH);
this->flush();
return ret;
return this->read_array(response, MHZ19_RESPONSE_LENGTH);
}
float MHZ19Component::get_setup_priority() const { return setup_priority::DATA; }
void MHZ19Component::dump_config() {