11/*
2- * Copyright (c) 2006-2024 RT-Thread Development Team
2+ * Copyright (c) 2006-2025 RT-Thread Development Team
33 *
44 * SPDX-License-Identifier: Apache-2.0
55 *
1111 * 2021-03-17 Meco Man fix a buf of leaking memory
1212 * 2021-07-14 Sszl fix a buf of leaking memory
1313 * 2025-01-02 dongly support SERIAL_V2
14+ * 2025-04-18 RyanCw support New SERIAL_V2
1415 */
1516
1617#include <at.h>
@@ -225,7 +226,8 @@ int at_resp_parse_line_args(at_response_t resp, rt_size_t resp_line, const char
225226 RT_ASSERT (resp );
226227 RT_ASSERT (resp_expr );
227228
228- if ((resp_line_buf = at_resp_get_line (resp , resp_line )) == RT_NULL )
229+ resp_line_buf = at_resp_get_line (resp , resp_line );
230+ if (resp_line_buf == RT_NULL )
229231 {
230232 return -1 ;
231233 }
@@ -259,7 +261,8 @@ int at_resp_parse_line_args_by_kw(at_response_t resp, const char *keyword, const
259261 RT_ASSERT (resp );
260262 RT_ASSERT (resp_expr );
261263
262- if ((resp_line_buf = at_resp_get_line_by_kw (resp , keyword )) == RT_NULL )
264+ resp_line_buf = at_resp_get_line_by_kw (resp , keyword );
265+ if (resp_line_buf == RT_NULL )
263266 {
264267 return -1 ;
265268 }
@@ -541,7 +544,7 @@ static rt_err_t at_client_getchar(at_client_t client, char *ch, rt_int32_t timeo
541544{
542545 rt_err_t result = RT_EOK ;
543546
544- #if (!defined(RT_USING_SERIAL_V2 ) || RT_VER_NUM < 0x50200 )
547+ #if (!defined(RT_USING_SERIAL_V2 ))
545548 while (rt_device_read (client -> device , 0 , ch , 1 ) == 0 )
546549 {
547550 result = rt_sem_take (client -> rx_notice , rt_tick_from_millisecond (timeout ));
@@ -592,7 +595,7 @@ rt_size_t at_client_obj_recv(at_client_t client, char *buf, rt_size_t size, rt_i
592595 return 0 ;
593596 }
594597
595- #if (!defined(RT_USING_SERIAL_V2 ) || RT_VER_NUM < 0x50200 )
598+ #if (!defined(RT_USING_SERIAL_V2 ))
596599 while (size )
597600 {
598601 rt_size_t read_len ;
@@ -800,7 +803,8 @@ static int at_recv_readline(at_client_t client)
800803 }
801804
802805 /* is newline or URC data */
803- if ((client -> urc = get_urc_obj (client )) != RT_NULL || (ch == '\n' && last_ch == '\r' )
806+ client -> urc = get_urc_obj (client );
807+ if (client -> urc != RT_NULL || (ch == '\n' && last_ch == '\r' )
804808 || (client -> end_sign != 0 && ch == client -> end_sign ))
805809 {
806810 if (is_full )
@@ -897,7 +901,7 @@ static void client_parser(at_client_t client)
897901 }
898902}
899903
900- #if (!defined(RT_USING_SERIAL_V2 ) || RT_VER_NUM < 0x50200 )
904+ #if (!defined(RT_USING_SERIAL_V2 ))
901905static rt_err_t at_client_rx_ind (rt_device_t dev , rt_size_t size )
902906{
903907 int idx = 0 ;
@@ -955,7 +959,7 @@ static int at_client_para_init(at_client_t client)
955959 goto __exit ;
956960 }
957961
958- #if (!defined(RT_USING_SERIAL_V2 ) || RT_VER_NUM < 0x50200 )
962+ #if (!defined(RT_USING_SERIAL_V2 ))
959963 rt_snprintf (name , RT_NAME_MAX , "%s%d" , AT_CLIENT_SEM_NAME , at_client_num );
960964 client -> rx_notice = rt_sem_create (name , 0 , RT_IPC_FLAG_FIFO );
961965 if (client -> rx_notice == RT_NULL )
@@ -983,7 +987,8 @@ static int at_client_para_init(at_client_t client)
983987 (void (* )(void * parameter ))client_parser ,
984988 client ,
985989 1024 + 512 ,
986- RT_THREAD_PRIORITY_MAX / 3 - 1 ,
990+ 6 ,
991+ /* RT_THREAD_PRIORITY_MAX / 3 - 1,*/
987992 5 );
988993 if (client -> parser == RT_NULL )
989994 {
@@ -998,7 +1003,7 @@ static int at_client_para_init(at_client_t client)
9981003 rt_mutex_delete (client -> lock );
9991004 }
10001005
1001- #if (!defined(RT_USING_SERIAL_V2 ) || RT_VER_NUM < 0x50200 )
1006+ #if (!defined(RT_USING_SERIAL_V2 ))
10021007 if (client -> rx_notice )
10031008 {
10041009 rt_sem_delete (client -> rx_notice );
@@ -1081,7 +1086,7 @@ int at_client_init(const char *dev_name, rt_size_t recv_bufsz, rt_size_t send_bu
10811086 if (client -> device )
10821087 {
10831088 RT_ASSERT (client -> device -> type == RT_Device_Class_Char );
1084- #if (!defined(RT_USING_SERIAL_V2 ) || RT_VER_NUM < 0x50200 )
1089+ #if (!defined(RT_USING_SERIAL_V2 ))
10851090 rt_device_set_rx_indicate (client -> device , at_client_rx_ind );
10861091
10871092#ifdef RT_USING_SERIAL_V2
0 commit comments