I got problem with programming COM port with POSIX. I have one device which communicate with PC through COM port (9600, space parity, 1 stop bit, no flow control). I have already write program which communicate with device under Win32 and under Linux using low level interface. Low level interface work normal with kernel version 2.4, but work with some errors under kernel 2.6. I try to turn off serial driver, but this don’t help.
But anyway the best solution will be interface which use POSIX, because in this case there are no need to unload serial driver, reconfigure kernel, …
I write this code:

#include <stdio.h> /* Standard input/output definitions */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
#include <iostream>

using namespace std;
int main(void)
int n;
int fd; /* File descriptor for the port */
char buf[200];
struct termios options;

fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NONBLOCK);
if (fd == -1) perror("open_port: Unable to open /dev/ttyS0 - ");
fcntl(fd, F_SETFL, 0);
tcgetattr(fd, &options);

// c_cflag
options.c_cflag |= CS8;
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag |= CREAD; // Enable Receiver
options.c_cflag |= CLOCAL; // Ignore modem control lines.

cfsetispeed(&options, B9600);
cfsetospeed(&options, B9600);

tcsetattr(fd, TCSAFLUSH, &options);
tcflush(fd, TCIOFLUSH); /**/

// Main code
n = write(fd, buf, 1);
cout << "Written:" << n << '\n';
usleep (150000);
cout << "Readen:" << int(buf[0]) << '\n';

After compiling (with -O) program write one bite to device, but don’t read any byte…
I had already check it many times, read lots of documentation, forums, but can’t find an error or solution to this problem…