SenseAir: flush input buffer on read error (#1017)

* SenseAir: flush input buffer on read error

* SenseAir: flush input buffer on read error - fix typo

* SenseAir: flush input buffer on read error - fix formating

* SenseAir: flush input buffer on read error - fix formating2

* SenseAir: flush input buffer on read error - fix formating3

* SenseAir: flush input buffer on read error - fix formating4

* Update esphome/components/senseair/senseair.cpp

* Update esphome/components/senseair/senseair.cpp

Co-authored-by: Guillermo Ruffino <glm.net@gmail.com>
This commit is contained in:
Christian Ferbar 2020-06-14 01:26:41 +02:00 committed by GitHub
parent b650704877
commit 35a2258f12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,8 +18,19 @@ void SenseAirComponent::update() {
} }
if (response[0] != 0xFE || response[1] != 0x04) { if (response[0] != 0xFE || response[1] != 0x04) {
ESP_LOGW(TAG, "Invalid preamble from SenseAir!"); ESP_LOGW(TAG, "Invalid preamble from SenseAir! %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x",
response[0], response[1], response[2], response[3], response[4], response[5], response[6], response[7],
response[8], response[9], response[10], response[11], response[12]);
this->status_set_warning(); this->status_set_warning();
while (this->available()) {
unsigned char b;
if (this->read_byte(&b)) {
ESP_LOGD(TAG, " ... %02x", b);
} else {
ESP_LOGD(TAG, " ... nothing read");
}
}
return; return;
} }