Merge pull request #17033 from thomashargrove/s8

Fix for error on first command sent to S8 module
This commit is contained in:
Theo Arends 2022-11-10 09:50:15 +01:00 committed by GitHub
commit 0033766b93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 10 deletions

View File

@ -70,7 +70,7 @@ void Senseair250ms(void) // Every 250 mSec
if (data_ready) {
uint8_t error = SenseairModbus->Receive16BitRegister(&value);
if (error) {
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir response error %d"), error);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir read register %02X gave response error %d"), (uint16_t)start_addresses[senseair_read_state], error);
} else {
switch(senseair_read_state) {
case 0: // 0x1A (26) READ_TYPE_LOW - S8: fe 04 02 01 77 ec 92
@ -104,15 +104,16 @@ void Senseair250ms(void) // Every 250 mSec
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir temp adjustment %d"), value);
break;
}
}
senseair_read_state++;
if (2 == senseair_type) { // S8
if (3 == senseair_read_state) {
senseair_read_state = 1;
}
} else { // K30, K70
if (sizeof(start_addresses) == senseair_read_state) {
senseair_read_state = 1;
senseair_read_state++;
if (2 == senseair_type) { // S8
if (3 == senseair_read_state) {
senseair_read_state = 1;
}
} else { // K30, K70
if (sizeof(start_addresses) == senseair_read_state) {
senseair_read_state = 1;
}
}
}
}