/************ set baud ********************/
void set_speed(int fd, int speed)
{
int status;
struct termios Opt;
tcgetattr(fd, &Opt); // get attribute of serial port
tcflush(fd, TCIOFLUSH);
cfsetispeed(&Opt, speed);
cfsetospeed(&Opt, speed);
status = tcsetattr(fd, TCSANOW, &Opt); // set attribute
if (status != 0)
{
perror("tcsetattr fd1");
return;
}
tcflush(fd,TCIOFLUSH);
}
/*********** set data format: databits,stopbits and parity **********/
int set_data_format(int fd,int databits,int stopbits,int parity)
{
struct termios opt;