views:

33

answers:

1

Hi,

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.

A: 

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.

Toddeman