标签:
linux串口编程ioctlit |
分类: 编程技术 |
Getting the Number of Bytes
Available
The FIONREAD ioctl gets the number of bytes in the serial port
input buffer. As with TIOCMGET you pass in a pointer to an integer
to hold the number of bytes, as shown in Listing 7.
获得控制信号
TIOCMGET - ioctl
获得当前“MODEM”的状态位,其中包括了除 RXD 和 TXD 之外,所有的RS-232 信号线,见列表 11。
为了获得状态位,使用一个包含比特位的整数的指针来调用 ioctl,见清单5。
Listing 5 - Getting the
MODEM status bits.
清单 5 - 读取 DODEM 的状态位.
#include <unistd.h>
#include <termios.h>
int fd;
int status;
ioctl(fd, TIOCMGET, &status);
Table 11 - Control Signal Constants
表 11 - 控制信号常量