我的使用程序是这样的,在open部分出现问题

int open_port(char *com)

{

int fd;

//fd = open(com, O_RDWR|O_NOCTTY|O_NDELAY);

fd = open(com, O_RDWR|O_NOCTTY);

if (-1 == fd)

{

return(-1);

}


if(fcntl(fd, F_SETFL, FNDELAY)<0) /* 设置串口为非阻塞状态*/

{

printf("fcntl failed!\n");

return -1;

}


return fd;

}



int serial_init(int *fd,int *iuRet)

{

int i;

  fd[0] = open_port("/dev/ttyS1");

fd[1] = open_port("/dev/ttyS2");

fd[2] = open_port("/dev/ttyS3");

fd[3] = open_port("/dev/ttyS4");

fd[4] = open_port("/dev/ttyS5");

fd[5] = open_port("/dev/ttyS6");

fd[6] = open_port("/dev/ttyS7");

fd[7] = open_port("/dev/ttyS8");

fd[8] = open_port("/dev/ttyCH9344USB0");

fd[9] = open_port("/dev/ttyCH9344USB1");

fd[10] = open_port("/dev/ttyCH9344USB2");

fd[11] = open_port("/dev/ttyCH9344USB3");

fd[12] = open_port("/dev/ttyCH9344USB4");

fd[13] = open_port("/dev/ttyCH9344USB5");

fd[14] = open_port("/dev/ttyCH9344USB6");

fd[15] = open_port("/dev/ttyCH9344USB7");

for(i=0;i<16;i++)

{

iuRet[i] = set_opt(fd[i], 115200, 8, 'N', 1);

}


  return 0;

}

88ecf0e78d91047fa490322b36928ff.png