commit
efc536afec
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 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 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
|
||||
|
||||
|
|
Loading…
Reference in New Issue