Skip to content

Commit 32b1140

Browse files
zakportmmahadevan108
authored andcommitted
mgmt: smp: shell: Respond on uart shell device when changed at runtime
Responses are currently set to the shell device that was configured in the device tree. The shell_uart driver allows for changing it's device during runtime which leads to a situation where we recieve packets on one device and respond on another. This patch causes smp_shell_tx_raw to use the shell_uart device Signed-off-by: Zak Portnoy <[email protected]>
1 parent 50ab695 commit 32b1140

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

subsys/mgmt/mcumgr/transport/src/smp_shell.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ static struct smp_transport smp_shell_transport;
3939

4040
static struct mcumgr_serial_rx_ctxt smp_shell_rx_ctxt;
4141

42+
static const struct shell_uart_common *shell_uart;
43+
4244
#ifdef CONFIG_SMP_CLIENT
4345
static struct smp_client_transport_entry smp_client_transport;
4446
#endif
@@ -210,11 +212,10 @@ static uint16_t smp_shell_get_mtu(const struct net_buf *nb)
210212

211213
static int smp_shell_tx_raw(const void *data, int len)
212214
{
213-
static const struct device *const sh_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_shell_uart));
214215
const uint8_t *out = data;
215216

216217
while ((out != NULL) && (len != 0)) {
217-
uart_poll_out(sh_dev, *out);
218+
uart_poll_out(shell_uart->dev, *out);
218219
++out;
219220
--len;
220221
}
@@ -226,6 +227,7 @@ static int smp_shell_tx_pkt(struct net_buf *nb)
226227
{
227228
int rc;
228229

230+
shell_uart = (struct shell_uart_common *)shell_backend_uart_get_ptr()->iface->ctx;
229231
rc = mcumgr_serial_tx_pkt(nb->data, nb->len, smp_shell_tx_raw);
230232
smp_packet_free(nb);
231233

0 commit comments

Comments
 (0)