Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
宁楠萍
rt-thread
提交
3a5d9e73
R
rt-thread
项目概览
宁楠萍
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
3a5d9e73
编写于
9月 14, 2018
作者:
B
Bernard Xiong
提交者:
GitHub
9月 14, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1807 from Lawlieta/at
fix at receive data issue
上级
0aa4b72b
3302ef9d
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
42 addition
and
21 deletion
+42
-21
components/net/at/at_socket/at_socket.c
components/net/at/at_socket/at_socket.c
+18
-9
components/net/at/include/at.h
components/net/at/include/at.h
+4
-4
components/net/at/src/at_client.c
components/net/at/src/at_client.c
+20
-8
未找到文件。
components/net/at/at_socket/at_socket.c
浏览文件 @
3a5d9e73
...
...
@@ -513,6 +513,7 @@ static void at_closed_notice_cb(int socket, at_socket_evt_t event, const char *b
sock
->
state
=
AT_SOCKET_CLOSED
;
rt_sem_release
(
sock
->
recv_notice
);
}
int
at_connect
(
int
socket
,
const
struct
sockaddr
*
name
,
socklen_t
namelen
)
{
struct
at_socket
*
sock
;
...
...
@@ -611,7 +612,13 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f
sock
->
state
=
AT_SOCKET_CONNECT
;
}
if
(
sock
->
state
!=
AT_SOCKET_CONNECT
)
/* socket passively closed, receive function return 0 */
if
(
sock
->
state
==
AT_SOCKET_CLOSED
)
{
result
=
0
;
goto
__exit
;
}
else
if
(
sock
->
state
!=
AT_SOCKET_CONNECT
)
{
LOG_E
(
"received data error, current socket (%d) state (%d) is error."
,
socket
,
sock
->
state
);
result
=
-
1
;
...
...
@@ -664,7 +671,7 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f
else
{
LOG_D
(
"received data exit, current socket (%d) is closed by remote."
,
socket
);
result
=
-
1
;
result
=
0
;
goto
__exit
;
}
}
...
...
@@ -672,17 +679,19 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f
__exit:
if
(
result
<
0
)
{
at_do_event_changes
(
sock
,
AT_EVENT_ERROR
,
RT_TRUE
);
}
else
if
(
recv_len
>
0
)
{
result
=
recv_len
;
if
(
recv_len
)
{
at_do_event_changes
(
sock
,
AT_EVENT_RECV
,
RT_FALSE
);
if
(
!
rt_slist_isempty
(
&
sock
->
recvpkt_list
))
{
at_do_event_changes
(
sock
,
AT_EVENT_RECV
,
RT_TRUE
);
}
}
else
{
at_do_event_changes
(
sock
,
AT_EVENT_ERROR
,
RT_TRUE
);
}
return
result
;
...
...
components/net/at/include/at.h
浏览文件 @
3a5d9e73
...
...
@@ -32,8 +32,8 @@
extern
"C"
{
#endif
#define AT_SW_VERSION "1.
0.1
"
#define AT_SW_VERSION_NUM 0x10
0
00
#define AT_SW_VERSION "1.
1.0
"
#define AT_SW_VERSION_NUM 0x10
1
00
#define DBG_ENABLE
#define DBG_SECTION_NAME "AT"
...
...
@@ -231,7 +231,7 @@ int at_client_obj_wait_connect(at_client_t client, rt_uint32_t timeout);
/* AT client send or receive data */
rt_size_t
at_client_obj_send
(
at_client_t
client
,
const
char
*
buf
,
rt_size_t
size
);
rt_size_t
at_client_obj_recv
(
at_client_t
client
,
char
*
buf
,
rt_size_t
size
);
rt_size_t
at_client_obj_recv
(
at_client_t
client
,
char
*
buf
,
rt_size_t
size
,
rt_int32_t
timeout
);
/* set AT client a line end sign */
void
at_obj_set_end_sign
(
at_client_t
client
,
char
ch
);
...
...
@@ -263,7 +263,7 @@ int at_resp_parse_line_args_by_kw(at_response_t resp, const char *keyword, const
#define at_exec_cmd(resp, ...) at_obj_exec_cmd(at_client_get_first(), resp, __VA_ARGS__)
#define at_client_wait_connect(timeout) at_client_obj_wait_connect(at_client_get_first(), timeout)
#define at_client_send(buf, size) at_client_obj_send(at_client_get_first(), buf, size)
#define at_client_recv(buf, size
) at_client_obj_recv(at_client_get_first(), buf, size
)
#define at_client_recv(buf, size
, timeout) at_client_obj_recv(at_client_get_first(), buf, size, timeout
)
#define at_set_end_sign(ch) at_obj_set_end_sign(at_client_get_first(), ch)
#define at_set_urc_table(urc_table, table_sz) at_obj_set_urc_table(at_client_get_first(), urc_table, table_sz)
...
...
components/net/at/src/at_client.c
浏览文件 @
3a5d9e73
...
...
@@ -425,17 +425,22 @@ rt_size_t at_client_obj_send(at_client_t client, const char *buf, rt_size_t size
return
rt_device_write
(
client
->
device
,
0
,
buf
,
size
);
}
static
char
at_client_getchar
(
at_client_t
clien
t
)
static
rt_err_t
at_client_getchar
(
at_client_t
client
,
char
*
ch
,
rt_int32_t
timeou
t
)
{
char
ch
;
rt_err_t
result
=
RT_EOK
;
while
(
rt_device_read
(
client
->
device
,
0
,
&
ch
,
1
)
==
0
)
while
(
rt_device_read
(
client
->
device
,
0
,
ch
,
1
)
==
0
)
{
rt_sem_control
(
client
->
rx_notice
,
RT_IPC_CMD_RESET
,
RT_NULL
);
rt_sem_take
(
client
->
rx_notice
,
RT_WAITING_FOREVER
);
result
=
rt_sem_take
(
client
->
rx_notice
,
rt_tick_from_millisecond
(
timeout
));
if
(
result
!=
RT_EOK
)
{
return
result
;
}
}
return
ch
;
return
RT_EOK
;
}
/**
...
...
@@ -444,15 +449,17 @@ static char at_client_getchar(at_client_t client)
* @param client current AT client object
* @param buf receive data buffer
* @param size receive fixed data size
* @param timeout receive data timeout (ms)
*
* @note this function can only be used in execution function of URC data
*
* @return >0: receive data size
* =0: receive failed
*/
rt_size_t
at_client_obj_recv
(
at_client_t
client
,
char
*
buf
,
rt_size_t
size
)
rt_size_t
at_client_obj_recv
(
at_client_t
client
,
char
*
buf
,
rt_size_t
size
,
rt_int32_t
timeout
)
{
rt_size_t
read_idx
=
0
;
rt_err_t
result
=
RT_EOK
;
char
ch
;
RT_ASSERT
(
buf
);
...
...
@@ -467,7 +474,12 @@ rt_size_t at_client_obj_recv(at_client_t client, char *buf, rt_size_t size)
{
if
(
read_idx
<
size
)
{
ch
=
at_client_getchar
(
client
);
result
=
at_client_getchar
(
client
,
&
ch
,
timeout
);
if
(
result
!=
RT_EOK
)
{
LOG_E
(
"AT Client receive failed, uart device get data error(%d)"
,
result
);
return
0
;
}
buf
[
read_idx
++
]
=
ch
;
}
...
...
@@ -610,7 +622,7 @@ static int at_recv_readline(at_client_t client)
while
(
1
)
{
ch
=
at_client_getchar
(
client
);
at_client_getchar
(
client
,
&
ch
,
RT_WAITING_FOREVER
);
if
(
read_len
<
client
->
recv_bufsz
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录