Hai all I have successfully communicated serial ports by running receive and transmitting programs in different terminals.Now i need to read and write data on same port.Here i am unable to do this.I am giving my code.If it has any bugs,help me out. waiting for your responses guys.. /*program:*/
#include /* Standard input/output definitions */ #include /* String function definitions */ #include /* UNIX standard function definitions */ #include /* File control definitions */ #include /* Error number definitions */ #include /* POSIX terminal control definitions */
int main() { int fd,i=0; char c,buff[100]; struct termios options; fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY ); if (fd == -1) perror("Unable to open /dev/ttyS1\n"); else { fcntl(fd, F_SETFL, 0); tcgetattr(fd, &options); cfsetispeed(&options,B9600); cfsetospeed(&options,B9600); options.c_cflag |= (CLOCAL | CREAD); options.c_cflag &= ~PARENB; options.c_cflag &= ~CSTOPB; options.c_cflag &= ~CSIZE; options.c_cflag |= CS8; options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); options.c_oflag &= ~OPOST; options.c_cc[VMIN]=1; tcsetattr(fd,TCSANOW, &options); fprintf(stdout,"In server\n"); while(1) { i=write(fd,"haranath",8); if(i