Regardless of opening the database or the serial port, before proceeding to judge whether the database or the serial port has been opened

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)

Guess you like

Origin blog.csdn.net/modi000/article/details/112555129