linux基礎復習(7)串口應用開發(fā)
printf(fcntl=%dn,fcntl(fd, F_SETFL,0));
if(isatty(STDIN_FILENO)==0)
printf(standard input is not a terminal devicen);
else
printf(isatty success!n);
printf(fd-open=%dn,fd);
return fd;
}
int main(void)
{
int fd;
int nread,i;
char buff[]=Hellon;
if((fd=open_port(fd,1))0){
perror(open_port error);
return;
}
if((i=set_opt(fd,115200,8,'N',1))0){
perror(set_opt error);
return;
}
printf(fd=%dn,fd);
// fd=3;
nread=read(fd,buff,8);
printf(nread=%d,%sn,nread,buff);
close(fd);
return;
}
評論