خرید بک لینک

Vote count: 0

Can anyone tell me what are the flags need to be set to avoid the junk characters in the serial port.

I am using the ttyS1 termios with default setting. Speed = B230400,

code shown below

tty_fd = open(DEVICE, O_RDWR | O_NDELAY);
if(tty_fd < 0)
{
    perror(DEVICE);
    exit(-1);
}
printf("Init 1 complete.n");

tcflush(tty_fd, TCIOFLUSH);

struct termios newtio;
retval = tcgetattr(tty_fd, &newtio);
if(retval != 0)
{
    perror(DEVICE);
    exit(-1);
}
printf("get attributes.n");

cfsetospeed(&newtio, SPEED);
cfsetispeed(&newtio, SPEED);

newtio.c_cflag = (newtio.c_cflag & ~CSIZE) | CS8;
newtio.c_cflag |= CLOCAL | CREAD;
newtio.c_cflag &= ~(PARENB | PARODD);
newtio.c_cflag &= ~CRTSCTS;
newtio.c_cflag &= ~CSTOPB;

newtio.c_iflag = IGNBRK;
newtio.c_iflag &= ~(IXON | IXOFF | IXANY);

newtio.c_lflag = 0;

newtio.c_oflag = 0;

retval = tcsetattr(tty_fd, TCSANOW, &newtio);

if(retval != 0)
{
    perror(DEVICE);
    exit(-1);
}
printf("Set attributes n");

after this writing then reading the values form the serial port.

Write success but from the serial port out the values are adding up with extra junk. while reading also junk characters reading.

asked 59 secs ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 15 ارديبهشت 1395 ساعت: 13:30

صفحه بندی