Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: at_host: Write AT responses to correct UART device #20242

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/at_host/at_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,28 @@
#else
static const struct device *const uart_dev = DEVICE_DT_GET(DT_NODELABEL(uart0));
#endif

#if DT_HAS_CHOSEN(zephyr_log_uart)
static const bool host_uart_is_log_uart = \

Check warning on line 44 in lib/at_host/at_host.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LINE_CONTINUATIONS

lib/at_host/at_host.c:44 Avoid unnecessary line continuations
(uart_dev == DEVICE_DT_GET(DT_CHOSEN(zephyr_log_uart)));
Comment on lines +44 to +45
Copy link
Contributor

@eivindj-nordic eivindj-nordic Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is within 100 chars, no need to split it.

Suggested change
static const bool host_uart_is_log_uart = \
(uart_dev == DEVICE_DT_GET(DT_CHOSEN(zephyr_log_uart)));
static const bool host_uart_is_log_uart = (uart_dev == DEVICE_DT_GET(DT_CHOSEN(zephyr_log_uart)));

#elif DT_HAS_CHOSEN(zephyr_console)
static const bool host_uart_is_log_uart = \

Check warning on line 47 in lib/at_host/at_host.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LINE_CONTINUATIONS

lib/at_host/at_host.c:47 Avoid unnecessary line continuations
(uart_dev == DEVICE_DT_GET(DT_CHOSEN(zephyr_console)));
Comment on lines +47 to +48
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static const bool host_uart_is_log_uart = \
(uart_dev == DEVICE_DT_GET(DT_CHOSEN(zephyr_console)));
static const bool host_uart_is_log_uart = (uart_dev == DEVICE_DT_GET(DT_CHOSEN(zephyr_console)));

#else
static const bool host_uart_is_log_uart = false;

Check failure on line 50 in lib/at_host/at_host.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

INITIALISED_STATIC

lib/at_host/at_host.c:50 do not initialise statics to false
#endif

static bool at_buf_busy; /* Guards at_buf while processing a command */
static char at_buf[AT_BUF_SIZE]; /* AT command and modem response buffer */
static struct k_work_q at_host_work_q;
static struct k_work cmd_send_work;

static inline void write_uart_string(const char *str)
{
if (IS_ENABLED(CONFIG_LOG_BACKEND_UART)) {
if (host_uart_is_log_uart && IS_ENABLED(CONFIG_LOG_BACKEND_UART)) {
/* The chosen UART device is also the UART log backend device, so that's
* where the AT response must go.

Check warning on line 62 in lib/at_host/at_host.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

BLOCK_COMMENT_STYLE

lib/at_host/at_host.c:62 Block comments should align the * on each line
*/
LOG_RAW("%s", str);
return;
}
Expand Down Expand Up @@ -233,7 +247,6 @@
int err;
enum term_modes mode = CONFIG_AT_HOST_TERMINATION;


/* Choosing the termination mode */
if (mode < MODE_COUNT) {
term_mode = mode;
Expand Down
Loading