Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dgr6878
rt-thread
提交
108b85f2
R
rt-thread
项目概览
dgr6878
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
5
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,发现更多精彩内容 >>
提交
108b85f2
编写于
8月 24, 2019
作者:
Lawlieta
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[network][at] Fix the end sign "\r\n" conversion error,and at_server_send、at_server_recv function
Signed-off-by:
chenyong
<
1521761801@qq.com
>
上级
61f151f4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
104 addition
and
9 deletion
+104
-9
components/net/at/include/at.h
components/net/at/include/at.h
+3
-1
components/net/at/src/at_cli.c
components/net/at/src/at_cli.c
+8
-2
components/net/at/src/at_server.c
components/net/at/src/at_server.c
+93
-6
未找到文件。
components/net/at/include/at.h
浏览文件 @
108b85f2
...
...
@@ -96,7 +96,7 @@ struct at_server
rt_device_t
device
;
at_status_t
status
;
char
(
*
get_char
)(
void
);
rt_err_t
(
*
get_char
)(
struct
at_server
*
server
,
char
*
ch
,
rt_int32_t
timeout
);
rt_bool_t
echo_mode
;
char
recv_buffer
[
AT_SERVER_RECV_BUFF_LEN
];
...
...
@@ -194,6 +194,8 @@ int at_server_init(void);
void
at_server_printf
(
const
char
*
format
,
...);
void
at_server_printfln
(
const
char
*
format
,
...);
void
at_server_print_result
(
at_result_t
result
);
rt_size_t
at_server_send
(
at_server_t
server
,
const
char
*
buf
,
rt_size_t
size
);
rt_size_t
at_server_recv
(
at_server_t
server
,
char
*
buf
,
rt_size_t
size
,
rt_int32_t
timeout
);
/* AT server request arguments parse */
int
at_req_parse_args
(
const
char
*
req_args
,
const
char
*
req_expr
,
...);
...
...
components/net/at/src/at_cli.c
浏览文件 @
108b85f2
...
...
@@ -100,6 +100,12 @@ void at_cli_deinit(void)
}
#ifdef AT_USING_SERVER
static
rt_err_t
at_server_console_getchar
(
struct
at_server
*
server
,
char
*
ch
,
rt_int32_t
timeout
)
{
*
ch
=
console_getchar
();
return
RT_EOK
;
}
static
void
server_cli_parser
(
void
)
{
extern
at_server_t
at_get_server
(
void
);
...
...
@@ -107,7 +113,7 @@ static void server_cli_parser(void)
at_server_t
server
=
at_get_server
();
rt_base_t
int_lvl
;
static
rt_device_t
device_bak
;
static
char
(
*
getchar_bak
)(
void
);
static
rt_err_t
(
*
getchar_bak
)(
struct
at_server
*
server
,
char
*
ch
,
rt_int32_t
timeout
);
static
char
endmark_back
[
AT_END_MARK_LEN
];
/* backup server device and getchar function */
...
...
@@ -122,7 +128,7 @@ static void server_cli_parser(void)
/* setup server device as console device */
server
->
device
=
rt_console_get_device
();
server
->
get_char
=
console_getchar
;
server
->
get_char
=
at_server_
console_getchar
;
memset
(
server
->
end_mark
,
0x00
,
AT_END_MARK_LEN
);
server
->
end_mark
[
0
]
=
'\r'
;
...
...
components/net/at/src/at_server.c
浏览文件 @
108b85f2
...
...
@@ -167,6 +167,79 @@ void rt_at_server_print_all_cmd(void)
}
}
/**
* Send data to AT Client by uart device.
*
* @param server current AT server object
* @param buf send data buffer
* @param size send fixed data size
*
* @return >0: send data size
* =0: send failed
*/
rt_size_t
at_server_send
(
at_server_t
server
,
const
char
*
buf
,
rt_size_t
size
)
{
RT_ASSERT
(
buf
);
if
(
server
==
RT_NULL
)
{
LOG_E
(
"input AT Server object is NULL, please create or get AT Server object!"
);
return
0
;
}
return
rt_device_write
(
server
->
device
,
0
,
buf
,
size
);
}
/**
* AT Server receive fixed-length data.
*
* @param client current AT Server 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 AT commands
*
* @return >0: receive data size
* =0: receive failed
*/
rt_size_t
at_server_recv
(
at_server_t
server
,
char
*
buf
,
rt_size_t
size
,
rt_int32_t
timeout
)
{
rt_size_t
read_idx
=
0
;
rt_err_t
result
=
RT_EOK
;
char
ch
=
0
;
RT_ASSERT
(
buf
);
if
(
server
==
RT_NULL
)
{
LOG_E
(
"input AT Server object is NULL, please create or get AT Server object!"
);
return
0
;
}
while
(
1
)
{
if
(
read_idx
<
size
)
{
/* check get data value */
result
=
server
->
get_char
(
server
,
&
ch
,
timeout
);
if
(
result
!=
RT_EOK
)
{
LOG_E
(
"AT Server receive failed, uart device get data error."
);
return
0
;
}
buf
[
read_idx
++
]
=
ch
;
}
else
{
break
;
}
}
return
read_idx
;
}
at_server_t
at_get_server
(
void
)
{
RT_ASSERT
(
at_server_local
);
...
...
@@ -339,17 +412,21 @@ static rt_err_t at_cmd_get_name(const char *cmd_buffer, char *cmd_name)
return
-
RT_ERROR
;
}
static
char
at_server_gerchar
(
void
)
static
rt_err_t
at_server_gerchar
(
at_server_t
server
,
char
*
ch
,
rt_int32_t
timeout
)
{
char
ch
;
rt_err_t
result
=
RT_EOK
;
while
(
rt_device_read
(
at_server_local
->
device
,
0
,
&
ch
,
1
)
==
0
)
while
(
rt_device_read
(
at_server_local
->
device
,
0
,
ch
,
1
)
==
0
)
{
rt_sem_control
(
at_server_local
->
rx_notice
,
RT_IPC_CMD_RESET
,
RT_NULL
);
rt_sem_take
(
at_server_local
->
rx_notice
,
RT_WAITING_FOREVER
);
result
=
rt_sem_take
(
at_server_local
->
rx_notice
,
rt_tick_from_millisecond
(
timeout
));
if
(
result
!=
RT_EOK
)
{
return
result
;
}
}
return
ch
;
return
result
;
}
static
void
server_parser
(
at_server_t
server
)
...
...
@@ -365,14 +442,24 @@ static void server_parser(at_server_t server)
RT_ASSERT
(
server
);
RT_ASSERT
(
server
->
status
!=
AT_STATUS_UNINITIALIZED
);
while
(
ESC_KEY
!=
(
ch
=
server
->
get_char
())
)
while
(
1
)
{
server
->
get_char
(
server
,
&
ch
,
RT_WAITING_FOREVER
);
if
(
ESC_KEY
==
ch
)
{
break
;
}
if
(
server
->
echo_mode
)
{
if
(
ch
==
AT_CMD_CR
||
(
ch
==
AT_CMD_LF
&&
last_ch
!=
AT_CMD_CR
))
{
at_server_printf
(
"%c%c"
,
AT_CMD_CR
,
AT_CMD_LF
);
}
else
if
(
ch
==
AT_CMD_LF
)
{
// skip the end sign check
}
else
if
(
ch
==
BACKSPACE_KEY
||
ch
==
DELECT_KEY
)
{
if
(
server
->
cur_recv_len
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录