mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 01:08:03 +01:00
Fix senseair component uart read timeout (#2658)
Co-authored-by: DAVe3283 <DAVe3283+GitHub@gmail.com> Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Co-authored-by: Chua Jun Chieh <junchieh.chua@softspace.com.my>
This commit is contained in:
parent
57bdc2b885
commit
df68403b6d
1 changed files with 7 additions and 3 deletions
|
@ -141,12 +141,16 @@ void SenseAirComponent::abc_get_period() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SenseAirComponent::senseair_write_command_(const uint8_t *command, uint8_t *response, uint8_t response_length) {
|
bool SenseAirComponent::senseair_write_command_(const uint8_t *command, uint8_t *response, uint8_t response_length) {
|
||||||
|
// Verify we have somewhere to store the response
|
||||||
|
if (response == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Write wake up byte required by some S8 sensor models
|
||||||
|
this->write_byte(0);
|
||||||
this->flush();
|
this->flush();
|
||||||
|
delay(5);
|
||||||
this->write_array(command, SENSEAIR_REQUEST_LENGTH);
|
this->write_array(command, SENSEAIR_REQUEST_LENGTH);
|
||||||
|
|
||||||
if (response == nullptr)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
bool ret = this->read_array(response, response_length);
|
bool ret = this->read_array(response, response_length);
|
||||||
this->flush();
|
this->flush();
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in a new issue