Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
逝缘~
rt-thread
提交
efc536af
R
rt-thread
项目概览
逝缘~
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
efc536af
编写于
1月 01, 2021
作者:
B
Bernard Xiong
提交者:
GitHub
1月 01, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4216 from mysterywolf/tio
重新整理了serial.c和pipe.c的格式
上级
cbe92500
e3fc77f2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
142 addition
and
138 deletion
+142
-138
components/drivers/serial/serial.c
components/drivers/serial/serial.c
+31
-26
components/drivers/src/pipe.c
components/drivers/src/pipe.c
+29
-29
include/libc/libc_ioctl.h
include/libc/libc_ioctl.h
+82
-83
未找到文件。
components/drivers/serial/serial.c
浏览文件 @
efc536af
...
...
@@ -71,21 +71,21 @@ static int serial_fops_open(struct dfs_fd *fd)
switch
(
fd
->
flags
&
O_ACCMODE
)
{
case
O_RDONLY
:
LOG_D
(
"fops open: O_RDONLY!"
);
flags
=
RT_DEVICE_FLAG_INT_RX
|
RT_DEVICE_FLAG_RDONLY
;
break
;
case
O_WRONLY
:
LOG_D
(
"fops open: O_WRONLY!"
);
flags
=
RT_DEVICE_FLAG_WRONLY
;
break
;
case
O_RDWR
:
LOG_D
(
"fops open: O_RDWR!"
);
flags
=
RT_DEVICE_FLAG_INT_RX
|
RT_DEVICE_FLAG_RDWR
;
break
;
default:
LOG_E
(
"fops open: unknown mode - %d!"
,
fd
->
flags
&
O_ACCMODE
);
break
;
case
O_RDONLY
:
LOG_D
(
"fops open: O_RDONLY!"
);
flags
=
RT_DEVICE_FLAG_INT_RX
|
RT_DEVICE_FLAG_RDONLY
;
break
;
case
O_WRONLY
:
LOG_D
(
"fops open: O_WRONLY!"
);
flags
=
RT_DEVICE_FLAG_WRONLY
;
break
;
case
O_RDWR
:
LOG_D
(
"fops open: O_RDWR!"
);
flags
=
RT_DEVICE_FLAG_INT_RX
|
RT_DEVICE_FLAG_RDWR
;
break
;
default:
LOG_E
(
"fops open: unknown mode - %d!"
,
fd
->
flags
&
O_ACCMODE
);
break
;
}
if
((
fd
->
flags
&
O_ACCMODE
)
!=
O_WRONLY
)
...
...
@@ -133,7 +133,7 @@ static int serial_fops_read(struct dfs_fd *fd, void *buf, size_t count)
do
{
size
=
rt_device_read
(
device
,
-
1
,
buf
,
count
);
size
=
rt_device_read
(
device
,
-
1
,
buf
,
count
);
if
(
size
<=
0
)
{
if
(
fd
->
flags
&
O_NONBLOCK
)
...
...
@@ -759,14 +759,17 @@ static rt_err_t rt_serial_close(struct rt_device *dev)
#ifdef RT_SERIAL_USING_DMA
else
if
(
dev
->
open_flag
&
RT_DEVICE_FLAG_DMA_RX
)
{
if
(
serial
->
config
.
bufsz
==
0
)
{
if
(
serial
->
config
.
bufsz
==
0
)
{
struct
rt_serial_rx_dma
*
rx_dma
;
rx_dma
=
(
struct
rt_serial_rx_dma
*
)
serial
->
serial_rx
;
RT_ASSERT
(
rx_dma
!=
RT_NULL
);
rt_free
(
rx_dma
);
}
else
{
}
else
{
struct
rt_serial_rx_fifo
*
rx_fifo
;
rx_fifo
=
(
struct
rt_serial_rx_fifo
*
)
serial
->
serial_rx
;
...
...
@@ -1105,6 +1108,16 @@ static rt_err_t rt_serial_control(struct rt_device *dev,
break
;
case
TCXONC
:
break
;
case
TIOCSWINSZ
:
{
struct
winsize
*
p_winsize
;
p_winsize
=
(
struct
winsize
*
)
args
;
rt_enter_critical
();
rt_kprintf
(
"
\x1b
[8;%d;%dt"
,
p_winsize
->
ws_col
,
p_winsize
->
ws_row
);
rt_exit_critical
();
}
break
;
#endif
/*RT_USING_POSIX_TERMIOS*/
case
FIONREAD
:
{
...
...
@@ -1118,14 +1131,6 @@ static rt_err_t rt_serial_control(struct rt_device *dev,
*
(
rt_size_t
*
)
args
=
recved
;
}
break
;
case
TIOCSWINSZ
:
{
struct
winsize
*
p_winsize
;
p_winsize
=
(
struct
winsize
*
)
args
;
rt_kprintf
(
"
\x1b
[8;%d;%dt"
,
p_winsize
->
ws_col
,
p_winsize
->
ws_row
);
}
break
;
#endif
/*RT_USING_POSIX*/
default
:
/* control device */
...
...
components/drivers/src/pipe.c
浏览文件 @
efc536af
...
...
@@ -41,16 +41,16 @@ static int pipe_fops_open(struct dfs_fd *fd)
switch
(
fd
->
flags
&
O_ACCMODE
)
{
case
O_RDONLY
:
pipe
->
readers
++
;
break
;
case
O_WRONLY
:
pipe
->
writers
++
;
break
;
case
O_RDWR
:
pipe
->
readers
++
;
pipe
->
writers
++
;
break
;
case
O_RDONLY
:
pipe
->
readers
++
;
break
;
case
O_WRONLY
:
pipe
->
writers
++
;
break
;
case
O_RDWR
:
pipe
->
readers
++
;
pipe
->
writers
++
;
break
;
}
device
->
ref_count
++
;
...
...
@@ -73,16 +73,16 @@ static int pipe_fops_close(struct dfs_fd *fd)
switch
(
fd
->
flags
&
O_ACCMODE
)
{
case
O_RDONLY
:
pipe
->
readers
--
;
break
;
case
O_WRONLY
:
pipe
->
writers
--
;
break
;
case
O_RDWR
:
pipe
->
readers
--
;
pipe
->
writers
--
;
break
;
case
O_RDONLY
:
pipe
->
readers
--
;
break
;
case
O_WRONLY
:
pipe
->
writers
--
;
break
;
case
O_RDWR
:
pipe
->
readers
--
;
pipe
->
writers
--
;
break
;
}
if
(
pipe
->
writers
==
0
)
...
...
@@ -123,15 +123,15 @@ static int pipe_fops_ioctl(struct dfs_fd *fd, int cmd, void *args)
switch
(
cmd
)
{
case
FIONREAD
:
*
((
int
*
)
args
)
=
rt_ringbuffer_data_len
(
pipe
->
fifo
);
break
;
case
FIONWRITE
:
*
((
int
*
)
args
)
=
rt_ringbuffer_space_len
(
pipe
->
fifo
);
break
;
default:
ret
=
-
EINVAL
;
break
;
case
FIONREAD
:
*
((
int
*
)
args
)
=
rt_ringbuffer_data_len
(
pipe
->
fifo
);
break
;
case
FIONWRITE
:
*
((
int
*
)
args
)
=
rt_ringbuffer_space_len
(
pipe
->
fifo
);
break
;
default:
ret
=
-
EINVAL
;
break
;
}
return
ret
;
...
...
include/libc/libc_ioctl.h
浏览文件 @
efc536af
...
...
@@ -28,99 +28,99 @@
* in send queue. */
#endif
#define TCGETS
0x5401
#define TCSETS
0x5402
#define TCSETSW
0x5403
#define TCSETSF
0x5404
#define TCGETA
0x5405
#define TCSETA
0x5406
#define TCSETAW
0x5407
#define TCSETAF
0x5408
#define TCSBRK
0x5409
#define TCXONC
0x540A
#define TCFLSH
0x540B
#define TIOCEXCL
0x540C
#define TIOCNXCL
0x540D
#define TIOCSCTTY
0x540E
#define TIOCGPGRP
0x540F
#define TIOCSPGRP
0x5410
#define TIOCOUTQ
0x5411
#define TIOCSTI
0x5412
#define TIOCGWINSZ
0x5413
#define TIOCSWINSZ
0x5414
#define TIOCMGET
0x5415
#define TIOCMBIS
0x5416
#define TIOCMBIC
0x5417
#define TIOCMSET
0x5418
#define TIOCGSOFTCAR
0x5419
#define TIOCSSOFTCAR
0x541A
// #define FIONREAD
0x541B
#define TIOCINQ
FIONREAD
#define TIOCLINUX
0x541C
#define TIOCCONS
0x541D
#define TIOCGSERIAL
0x541E
#define TIOCSSERIAL
0x541F
#define TIOCPKT
0x5420
// #define FIONBIO
0x5421
#define TIOCNOTTY
0x5422
#define TIOCSETD
0x5423
#define TIOCGETD
0x5424
#define TCSBRKP
0x5425
#define TIOCSBRK
0x5427
#define TIOCCBRK
0x5428
#define TIOCGSID
0x5429
#define TIOCGRS485
0x542E
#define TIOCSRS485
0x542F
#define TIOCGPTN
0x80045430
#define TIOCSPTLCK
0x40045431
#define TIOCGDEV
0x80045432
#define TCGETX
0x5432
#define TCSETX
0x5433
#define TCSETXF
0x5434
#define TCSETXW
0x5435
#define TIOCSIG
0x40045436
#define TIOCVHANGUP
0x5437
#define TIOCGPKT
0x80045438
#define TIOCGPTLCK
0x80045439
#define TIOCGEXCL
0x80045440
#define FIONCLEX
0x5450
#define FIOCLEX
0x5451
#define TCGETS
0x5401
#define TCSETS
0x5402
#define TCSETSW
0x5403
#define TCSETSF
0x5404
#define TCGETA
0x5405
#define TCSETA
0x5406
#define TCSETAW
0x5407
#define TCSETAF
0x5408
#define TCSBRK
0x5409
#define TCXONC
0x540A
#define TCFLSH
0x540B
#define TIOCEXCL
0x540C
#define TIOCNXCL
0x540D
#define TIOCSCTTY
0x540E
#define TIOCGPGRP
0x540F
#define TIOCSPGRP
0x5410
#define TIOCOUTQ
0x5411
#define TIOCSTI
0x5412
#define TIOCGWINSZ
0x5413
#define TIOCSWINSZ
0x5414
#define TIOCMGET
0x5415
#define TIOCMBIS
0x5416
#define TIOCMBIC
0x5417
#define TIOCMSET
0x5418
#define TIOCGSOFTCAR
0x5419
#define TIOCSSOFTCAR
0x541A
// #define FIONREAD
0x541B
#define TIOCINQ
FIONREAD
#define TIOCLINUX
0x541C
#define TIOCCONS
0x541D
#define TIOCGSERIAL
0x541E
#define TIOCSSERIAL
0x541F
#define TIOCPKT
0x5420
// #define FIONBIO
0x5421
#define TIOCNOTTY
0x5422
#define TIOCSETD
0x5423
#define TIOCGETD
0x5424
#define TCSBRKP
0x5425
#define TIOCSBRK
0x5427
#define TIOCCBRK
0x5428
#define TIOCGSID
0x5429
#define TIOCGRS485
0x542E
#define TIOCSRS485
0x542F
#define TIOCGPTN
0x80045430
#define TIOCSPTLCK
0x40045431
#define TIOCGDEV
0x80045432
#define TCGETX
0x5432
#define TCSETX
0x5433
#define TCSETXF
0x5434
#define TCSETXW
0x5435
#define TIOCSIG
0x40045436
#define TIOCVHANGUP
0x5437
#define TIOCGPKT
0x80045438
#define TIOCGPTLCK
0x80045439
#define TIOCGEXCL
0x80045440
#define FIONCLEX
0x5450
#define FIOCLEX
0x5451
#ifndef _WIN32
#define FIOASYNC
0x5452
#define FIOASYNC
0x5452
#endif
#define TIOCSERCONFIG
0x5453
#define TIOCSERGWILD
0x5454
#define TIOCSERSWILD
0x5455
#define TIOCGLCKTRMIOS
0x5456
#define TIOCSLCKTRMIOS
0x5457
#define TIOCSERGSTRUCT
0x5458
#define TIOCSERCONFIG
0x5453
#define TIOCSERGWILD
0x5454
#define TIOCSERSWILD
0x5455
#define TIOCGLCKTRMIOS
0x5456
#define TIOCSLCKTRMIOS
0x5457
#define TIOCSERGSTRUCT
0x5458
#define TIOCSERGETLSR 0x5459
#define TIOCSERGETMULTI 0x545A
#define TIOCSERSETMULTI 0x545B
#define TIOCMIWAIT
0x545C
#define TIOCGICOUNT
0x545D
#define FIOQSIZE
0x5460
#define TIOCMIWAIT
0x545C
#define TIOCGICOUNT
0x545D
#define FIOQSIZE
0x5460
#define TIOCPKT_DATA
0
#define TIOCPKT_FLUSHREAD
1
#define TIOCPKT_FLUSHWRITE
2
#define TIOCPKT_STOP
4
#define TIOCPKT_START
8
#define TIOCPKT_NOSTOP
16
#define TIOCPKT_DOSTOP
32
#define TIOCPKT_IOCTL
64
#define TIOCPKT_DATA
0
#define TIOCPKT_FLUSHREAD
1
#define TIOCPKT_FLUSHWRITE
2
#define TIOCPKT_STOP
4
#define TIOCPKT_START
8
#define TIOCPKT_NOSTOP
16
#define TIOCPKT_DOSTOP
32
#define TIOCPKT_IOCTL
64
#define TIOCSER_TEMT 0x01
struct
winsize
{
unsigned
short
ws_row
;
unsigned
short
ws_col
;
unsigned
short
ws_xpixel
;
unsigned
short
ws_ypixel
;
unsigned
short
ws_row
;
unsigned
short
ws_col
;
unsigned
short
ws_xpixel
;
unsigned
short
ws_ypixel
;
};
#define TIOCM_LE 0x001
...
...
@@ -223,8 +223,7 @@ struct winsize {
#define SIOCADDDLCI 0x8980
#define SIOCDELDLCI 0x8981
#define SIOCDEVPRIVATE
0x89F0
#define SIOCPROTOPRIVATE
0x89E0
#define SIOCDEVPRIVATE
0x89F0
#define SIOCPROTOPRIVATE
0x89E0
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录