#include "serial.h"
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <termios.h>
#include <string.h>
int main (int argc, char* argv[])
{
int i, rv, len, pid;
char buffer[100], buffer2[10];
struct termios my_termios, new_termios;
char dev[20]="/dev/ttyS3";
int fd = open(dev, O_RDWR | O_NDELAY | O_NOCTTY);
tcgetattr(fd, &my_termios);
my_termios.c_iflag &= ~(IGNBRK | BRKINT | ICRNL | INLCR);
my_termios.c_iflag &= ~(PARMRK | INPCK | ISTRIP | IXON);
my_termios.c_oflag &= ~(OCRNL | ONLCR | ONLRET | ONOCR);
my_termios.c_oflag &= ~( OFILL | OLCUC | OPOST);
my_termios.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN);
my_termios.c_lflag &= ~(ISIG | ECHOK | ECHOCTL | ECHOPRT);
my_termios.c_cflag &= ~(CSIZE | PARENB);
my_termios.c_cflag &= ~CRTSCTS;
my_termios.c_cflag |= CS8 | CLOCAL;
my_termios.c_cflag &= ~CBAUD;
my_termios.c_cflag |= B115200; /* change your baudrate here */
my_termios.c_cc[VMIN] = 0;
my_termios.c_cc[VTIME] = 5;
rv = tcsetattr(fd, TCSANOW, &my_termios);
tcgetattr(fd, &new_termios);
while(1)
{
printf("enter the string to send \n");
scanf("%s",buffer);
len = strlen(buffer)+1;
write(fd, buffer, len);
if (read(fd, buffer2, 1) > 0)
for(i=0;i<len;i++){
printf("%c\n",buffer2[i]);}
}
close(fd);
}