无论打开数据库还是串口,之前进行判断数据库或串口是否已经被打开了

int comm_fd = -1;

if(comm_fd !=-1)

{

    close (comm_fd);

    comm_fd = -1;

}

char path[20] ={0};

strcpy(path,"/dev/ser1");

comm_fd = open ( path, O_RDWR,S_IRUSR | S_IWUSR)

猜你喜欢

转载自blog.csdn.net/modi000/article/details/112555129