mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 18:56:38 +00:00
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:
parent
a0f6b7f1a3
commit
de0c39582f
@ -329,6 +329,7 @@ enum miel_hvac_parser_state {
|
|||||||
struct miel_hvac_parser {
|
struct miel_hvac_parser {
|
||||||
enum miel_hvac_parser_state
|
enum miel_hvac_parser_state
|
||||||
p_state;
|
p_state;
|
||||||
|
uint8_t p_tmo;
|
||||||
uint8_t p_type;
|
uint8_t p_type;
|
||||||
uint8_t p_sum;
|
uint8_t p_sum;
|
||||||
uint8_t p_len;
|
uint8_t p_len;
|
||||||
@ -386,6 +387,7 @@ miel_hvac_parse(struct miel_hvac_softc *sc, uint8_t byte)
|
|||||||
|
|
||||||
/* reset state */
|
/* reset state */
|
||||||
p->p_sum = 0;
|
p->p_sum = 0;
|
||||||
|
p->p_tmo = 0;
|
||||||
|
|
||||||
nstate = MIEL_HVAC_P_TYPE;
|
nstate = MIEL_HVAC_P_TYPE;
|
||||||
break;
|
break;
|
||||||
@ -1234,8 +1236,20 @@ miel_hvac_tick(struct miel_hvac_softc *sc)
|
|||||||
MIEL_HVAC_REQUEST_STAGE,
|
MIEL_HVAC_REQUEST_STAGE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct miel_hvac_parser *p = &sc->sc_parser;
|
||||||
unsigned int i;
|
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)) {
|
if (miel_hvac_update_pending(sc)) {
|
||||||
struct miel_hvac_msg_update *update = &sc->sc_update;
|
struct miel_hvac_msg_update *update = &sc->sc_update;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user