Skip to content

Commit b39ec3a

Browse files
authored
fix: 未打开设备时交互异常 (#36)
1 parent 209d520 commit b39ec3a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

adapter/drv_rtt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ static void segger_rtt_check(void)
8585
struct rt_serial_rx_fifo *rx_fifo;
8686
rx_fifo = (struct rt_serial_rx_fifo *)_serial_jlink_rtt.serial_rx;
8787
RT_ASSERT(rx_fifo != RT_NULL);
88-
while (SEGGER_RTT_HasKey())
88+
while (SEGGER_RTT_HasKey() && (_serial_jlink_rtt.parent.open_flag & RT_DEVICE_OFLAG_OPEN))
8989
{
9090
rt_ringbuffer_putchar(&(rx_fifo->rb), SEGGER_RTT_GetKey());
9191
rt_hw_serial_isr(&_serial_jlink_rtt, RT_SERIAL_EVENT_RX_IND);
9292
}
9393
#else //RT_USING_SERIAL_V1
94-
while (SEGGER_RTT_HasKey())
94+
while (SEGGER_RTT_HasKey() && (_serial_jlink_rtt.parent.open_flag & RT_DEVICE_OFLAG_OPEN))
9595
{
9696
rt_hw_serial_isr(&_serial_jlink_rtt, RT_SERIAL_EVENT_RX_IND);
9797
}

0 commit comments

Comments
 (0)