Q: write() with ttyS is non block My question is this - how can you make a call write() in uCLinux 2.6.21 synchronous, ie that the call is not completed before the end of the send?
Now I have the following code:
//...
fd = open (PORT, O_RDWR | O_SYNC)
//...

FIO3CLR |= 0x30000000; // RTS = 0 (enable transfer)
write (fd, "A", 1) // pass
FIO3SET |= 0x30000000; // RTS = 1 (disable transfer)

command FIO3SET |= 0x30000000; starts executed almost immediately after calling the write(), for the task it is undesirable.
Thanks.

A: My guess is that you should be setting TTY attributes and that Linux kernel will do the RTS/CTS handling for if you set the attributes. For complete example see http://www.tldp.org/HOWTO/Serial-Programming-HOWTO/x115.html. I would guess that the part that answers your question is this:
newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD; // CRTSCTS is set here
//...
tcsetattr(fd,TCSANOW,&newtio);


A: tcdrain() waits until all output written to the object referred to by fd has been transmitted.
it solved my problem
C read call blocking on serial port operation
