Skip to content

Commit 0617b25

Browse files
joerchankartben
authored andcommitted
drivers: modem: Add helper function to send data on modem cmd iface
Add helper function to send data on modem command handler interface. This makes sure that when verbose logging is enabled all data is actually logged. Signed-off-by: Joakim Andersson <joerchan@gmail.com>
1 parent 8cea4ce commit 0617b25

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

drivers/modem/modem_cmd_handler.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,20 @@ int modem_cmd_handler_update_cmds(struct modem_cmd_handler_data *data,
486486
return 0;
487487
}
488488

489+
int modem_cmd_send_data_nolock(struct modem_iface *iface,
490+
const uint8_t *buf, size_t len)
491+
{
492+
#if defined(CONFIG_MODEM_CONTEXT_VERBOSE_DEBUG)
493+
if (len > 256) {
494+
/* Truncate the message, since too long log messages gets dropped somewhere. */
495+
LOG_HEXDUMP_DBG(buf, 256, "SENT DIRECT DATA (truncated)");
496+
} else {
497+
LOG_HEXDUMP_DBG(buf, len, "SENT DIRECT DATA");
498+
}
499+
#endif
500+
return iface->write(iface, buf, len);
501+
}
502+
489503
int modem_cmd_send_ext(struct modem_iface *iface,
490504
struct modem_cmd_handler *handler,
491505
const struct modem_cmd *handler_cmds,

drivers/modem/modem_cmd_handler.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,18 @@ int modem_cmd_handler_update_cmds(struct modem_cmd_handler_data *data,
158158
size_t handler_cmds_len,
159159
bool reset_error_flag);
160160

161+
/**
162+
* @brief send data directly to interface w/o TX lock.
163+
*
164+
* This function just writes directly to the modem interface.
165+
* Recommended to use to get verbose logging for all data sent to the interface.
166+
* @param iface: interface to use
167+
* @param buf: send buffer (not NULL terminated)
168+
* @param len: length of send buffer.
169+
*/
170+
int modem_cmd_send_data_nolock(struct modem_iface *iface,
171+
const uint8_t *buf, size_t len);
172+
161173
/**
162174
* @brief send AT command to interface with behavior defined by flags
163175
*

0 commit comments

Comments
 (0)