modem: cmux: improve frame debug logging
- Add the frame data length to the frame header log. - Log the dropped frames as well. Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
This commit is contained in:
parent
15cc3ff0d6
commit
e7805f8d72
1 changed files with 25 additions and 9 deletions
|
|
@ -126,18 +126,22 @@ static const char *modem_cmux_frame_type_to_str(enum modem_cmux_frame_types fram
|
|||
return "";
|
||||
}
|
||||
|
||||
static void modem_cmux_log_frame(const struct modem_cmux_frame *frame,
|
||||
const char *action, size_t hexdump_len)
|
||||
{
|
||||
LOG_DBG("%s ch:%u cr:%u pf:%u type:%s dlen:%u", action, frame->dlci_address,
|
||||
frame->cr, frame->pf, modem_cmux_frame_type_to_str(frame->type), frame->data_len);
|
||||
LOG_HEXDUMP_DBG(frame->data, hexdump_len, "data:");
|
||||
}
|
||||
|
||||
static void modem_cmux_log_transmit_frame(const struct modem_cmux_frame *frame)
|
||||
{
|
||||
LOG_DBG("ch:%u,cr:%u,pf:%u,type:%s", frame->dlci_address, frame->cr, frame->pf,
|
||||
modem_cmux_frame_type_to_str(frame->type));
|
||||
LOG_HEXDUMP_DBG(frame->data, frame->data_len, "data:");
|
||||
modem_cmux_log_frame(frame, "tx", frame->data_len);
|
||||
}
|
||||
|
||||
static void modem_cmux_log_received_frame(const struct modem_cmux_frame *frame)
|
||||
{
|
||||
LOG_DBG("ch:%u,cr:%u,pf:%u,type:%s", frame->dlci_address, frame->cr, frame->pf,
|
||||
modem_cmux_frame_type_to_str(frame->type));
|
||||
LOG_HEXDUMP_DBG(frame->data, frame->data_len, "data:");
|
||||
modem_cmux_log_frame(frame, "rcvd", frame->data_len);
|
||||
}
|
||||
|
||||
static const char *modem_cmux_command_type_to_str(enum modem_cmux_command_types command_type)
|
||||
|
|
@ -652,6 +656,19 @@ static void modem_cmux_on_frame(struct modem_cmux *cmux)
|
|||
}
|
||||
}
|
||||
|
||||
static void modem_cmux_drop_frame(struct modem_cmux *cmux)
|
||||
{
|
||||
LOG_WRN("Dropped frame");
|
||||
cmux->receive_state = MODEM_CMUX_RECEIVE_STATE_SOF;
|
||||
|
||||
#if defined(CONFIG_MODEM_CMUX_LOG_LEVEL_DBG)
|
||||
struct modem_cmux_frame *frame = &cmux->frame;
|
||||
|
||||
frame->data = cmux->receive_buf;
|
||||
modem_cmux_log_frame(frame, "dropped", MIN(frame->data_len, cmux->receive_buf_size));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void modem_cmux_process_received_byte(struct modem_cmux *cmux, uint8_t byte)
|
||||
{
|
||||
uint8_t fcs;
|
||||
|
|
@ -797,15 +814,14 @@ static void modem_cmux_process_received_byte(struct modem_cmux *cmux, uint8_t by
|
|||
break;
|
||||
|
||||
case MODEM_CMUX_RECEIVE_STATE_DROP:
|
||||
LOG_WRN("Dropped frame");
|
||||
cmux->receive_state = MODEM_CMUX_RECEIVE_STATE_SOF;
|
||||
modem_cmux_drop_frame(cmux);
|
||||
break;
|
||||
|
||||
case MODEM_CMUX_RECEIVE_STATE_EOF:
|
||||
/* Validate byte is EOF */
|
||||
if (byte != 0xF9) {
|
||||
/* Unexpected byte */
|
||||
cmux->receive_state = MODEM_CMUX_RECEIVE_STATE_SOF;
|
||||
modem_cmux_drop_frame(cmux);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue