大家给我看看我的代码有没有错误,如果有请指出,没有看看可以有什么方法可以解决,下面是源码
C/C++ code:
/************************************
version:0.1
date :12/01/2010
author :yangchar
************************************/
#include /* Standard input/output definitions */
#include /* Standard lib */
#include /* String function definitions */
#include /* UNIX standard function definitions */
#include /* File control definitions */
#include /* Error number definitions */
#include /* POSIX terminal control definitions */
#define DEBUG 1
int open_port(const char *dev_name)
{
int fd; /* File descriptor for the port */
fd = open(dev_name, O_RDWR | O_NOCTTY | O_NDELAY);
if (-1 == fd)
{
perror("open_port: Unable to open tty " );
}
else
{
if(DEBUG)
printf("The %s is opened \n",dev_name);
}
if( fcntl(fd, F_SETFL, 0)< 0)
perror("fcntl failed");
else
{
if(DEBUG)
printf("The fcntl is %d \n",fcntl(fd, F_SETFL, 0));
}
if ( isatty(fd) == 0 )
perror("This is not a