don't send commands to the AC while reading data from the AC. (#20352)

on some units it can take around 250ms to reply to a request, by which
time we're shoving another command to the unit. if this happens, the
unit gives up and starts replying to the new command, which can again
take 250ms. in this situation effectively nothing gets through.

avoid this by checking if we're in the parser state machine. this also
gives us timeout handling.

tested on 4 different AC units. one which was unusable before is now
functioning as expected, and the other 3 appear just as functional as
they were before.
This commit is contained in:
David Gwynne 2023-12-30 18:14:56 +10:00 committed by GitHub
parent a0f6b7f1a3
commit de0c39582f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -329,6 +329,7 @@ enum miel_hvac_parser_state {
struct miel_hvac_parser {
enum miel_hvac_parser_state
p_state;
uint8_t p_tmo;
uint8_t p_type;
uint8_t p_sum;
uint8_t p_len;
@ -386,6 +387,7 @@ miel_hvac_parse(struct miel_hvac_softc *sc, uint8_t byte)
/* reset state */
p->p_sum = 0;
p->p_tmo = 0;
nstate = MIEL_HVAC_P_TYPE;
break;
@ -1234,8 +1236,20 @@ miel_hvac_tick(struct miel_hvac_softc *sc)
MIEL_HVAC_REQUEST_STAGE,
};
struct miel_hvac_parser *p = &sc->sc_parser;
unsigned int i;
if (p->p_state != MIEL_HVAC_P_START) {
if (p->p_tmo) {
AddLog(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME
": read timeout"));
sc->sc_parser.p_state = MIEL_HVAC_P_START;
} else {
p->p_tmo = 1;
return;
}
}
if (miel_hvac_update_pending(sc)) {
struct miel_hvac_msg_update *update = &sc->sc_update;