diff --git a/include/zephyr/modem/cmux.h b/include/zephyr/modem/cmux.h index 4562cb544d9..58959d6136b 100644 --- a/include/zephyr/modem/cmux.h +++ b/include/zephyr/modem/cmux.h @@ -63,10 +63,7 @@ enum modem_cmux_state { enum modem_cmux_receive_state { MODEM_CMUX_RECEIVE_STATE_SOF = 0, - MODEM_CMUX_RECEIVE_STATE_RESYNC_0, - MODEM_CMUX_RECEIVE_STATE_RESYNC_1, - MODEM_CMUX_RECEIVE_STATE_RESYNC_2, - MODEM_CMUX_RECEIVE_STATE_RESYNC_3, + MODEM_CMUX_RECEIVE_STATE_RESYNC, MODEM_CMUX_RECEIVE_STATE_ADDRESS, MODEM_CMUX_RECEIVE_STATE_ADDRESS_CONT, MODEM_CMUX_RECEIVE_STATE_CONTROL, diff --git a/subsys/modem/modem_cmux.c b/subsys/modem/modem_cmux.c index 258f969c498..472d1a7149a 100644 --- a/subsys/modem/modem_cmux.c +++ b/subsys/modem/modem_cmux.c @@ -642,13 +642,6 @@ static void modem_cmux_on_frame(struct modem_cmux *cmux) modem_cmux_on_dlci_frame(cmux); } -static void modem_cmux_transmit_resync(struct modem_cmux *cmux) -{ - static const uint8_t resync[3] = {0xF9, 0xF9, 0xF9}; - - modem_pipe_transmit(cmux->pipe, resync, sizeof(resync)); -} - static void modem_cmux_process_received_byte(struct modem_cmux *cmux, uint8_t byte) { uint8_t fcs; @@ -656,46 +649,23 @@ static void modem_cmux_process_received_byte(struct modem_cmux *cmux, uint8_t by switch (cmux->receive_state) { case MODEM_CMUX_RECEIVE_STATE_SOF: if (byte == 0xF9) { - cmux->receive_state = MODEM_CMUX_RECEIVE_STATE_ADDRESS; + cmux->receive_state = MODEM_CMUX_RECEIVE_STATE_RESYNC; break; } - modem_cmux_transmit_resync(cmux); - cmux->receive_state = MODEM_CMUX_RECEIVE_STATE_RESYNC_0; - break; - - case MODEM_CMUX_RECEIVE_STATE_RESYNC_0: - if (byte == 0xF9) { - cmux->receive_state = MODEM_CMUX_RECEIVE_STATE_RESYNC_1; - } - - break; - - case MODEM_CMUX_RECEIVE_STATE_RESYNC_1: - if (byte == 0xF9) { - cmux->receive_state = MODEM_CMUX_RECEIVE_STATE_RESYNC_2; - } else { - modem_cmux_transmit_resync(cmux); - cmux->receive_state = MODEM_CMUX_RECEIVE_STATE_RESYNC_0; - } - break; - case MODEM_CMUX_RECEIVE_STATE_RESYNC_2: - if (byte == 0xF9) { - cmux->receive_state = MODEM_CMUX_RECEIVE_STATE_RESYNC_3; - } else { - modem_cmux_transmit_resync(cmux); - cmux->receive_state = MODEM_CMUX_RECEIVE_STATE_RESYNC_0; - } - - break; - - case MODEM_CMUX_RECEIVE_STATE_RESYNC_3: + case MODEM_CMUX_RECEIVE_STATE_RESYNC: + /* + * Allow any number of consequtive flags (0xF9). + * 0xF9 could also be a valid address field for DLCI 62. + */ if (byte == 0xF9) { break; } + __fallthrough; + case MODEM_CMUX_RECEIVE_STATE_ADDRESS: /* Initialize */ cmux->receive_buf_len = 0;