0
votes

I am using C language and Linux as my programming platform. And I have problems in setting up the serial port(/dev/ttyS0). In my small program, I set my serial port using tcgetattr and tcsetattr

options.c_cflag |= B115200;
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag &= ~CRTSCTS;
options.c_cflag |= CS8;
options.c_cflag |= (CLOCAL | CREAD);
options.c_iflag &= ~(IXON | IXOFF | IXANY);

My problem is, my app doesn't get the first data that I sent. Did I missed some value?

Thanks.

1
Can you come with a minimal sample that reproduces this behavior? I personally don't know if this can be solved otherwise.INS

1 Answers

0
votes

Is it possible your app IS getting the first thing you send it, but it has junk at the beginning from connection/setup and is not being parsed properly?

You could try flushing the serial out just after init or sending CR/LF just after init to see if that clears things out before you send to your app.