此帖出自嵌入式系统论坛
最新回复
if (!tty->icanon && (tty->read_cnt >= tty->minimum_to_wake)) {
kill_fasync(&tty->fasync, SIGIO, POLL_IN);
if (waitqueue_active(&tty->read_wait))
wake_up_interruptible(&tty->read_wait);
}
看看你的串口参数怎么设置的,有可能没有达到你设置接受到字节数目,所以没有唤醒你来接收
注意options.c_cc[VTIME] = 10;
options.c_cc[VMIN] = AcmGetPortRxBufferSize(DIAG_PORT) / 2;
这两个参数的设置。
static boolean AcmConfigPort(int fd, AcmPortType port)
{
struct termios options;
if ( tcgetattr( fd,&options) != 0)
{
perror("tcgetattr");
return FALSE;
}
/*使能接收,并设置本地状态*/
options.c_cflag |= (CLOCAL | CREAD);
/*波特率设置115200*/
cfsetispeed(&options, B115200);
cfsetospeed(&options, B115200);
/*无校验位(8N1)*/
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;
options.c_iflag &= ~INPCK;
/*原始输入*/
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
options.c_iflag &= ~( INLCR | IGNCR| ICRNL |IUCLC);
/*关闭流控*/
options.c_cflag &= ~CRTSCTS;
options.c_iflag &= ~(IXON | IXOFF | IXANY);
/*原始输出*/
options.c_oflag &= ~OPOST; /*Output*/
/*读超时值设定*/
switch (port)
{
case UI_PORT:
options.c_cc[VTIME] = 0;
options.c_cc[VMIN] = 0;
break;
case MODEM_PORT:
options.c_cc[VTIME] = 0;
options.c_cc[VMIN] = 0;
break;
case DIAG_PORT:
options.c_cc[VTIME] = 10;
options.c_cc[VMIN] = AcmGetPortRxBufferSize(DIAG_PORT) / 2;
break;
default:
assert(FALSE);
break;
}
/* Update the options and do it NOW */
tcflush(fd,TCIFLUSH);
if (tcsetattr(fd,TCSANOW,&options) != 0)
{
perror("tcsetattr");
return FALSE;
}
return TRUE;
}
详情
回复
发表于 2010-6-30 16:49
| ||
|
||
此帖出自嵌入式系统论坛
| ||
|
||
EEWorld Datasheet 技术支持