Skip to contentSkip to conversation

serial device and fsync

DISCUSSION Ramagudi Naziir 2 participants 3 messages May 25, 2009

lore
Share & tools
lore
#0 lore raw

Hi all,

I need to write(2) a certain character to a serial device (using the standard /dev/ttySx), and make sure it was transferred to the device before I continue. I tried fsync(2), but that failed (does fsync even apply to character devices or only block devices ?).

Any idea ?

Is it even possible or should I just usleep(500ms) after write(2) ? (I know, it's ugly..).

Thanks in advance,
Naziir.

#1 lore raw
Quoted 6 lines · On Mon, 25 May 2009 12:50:22 +0300 Ramagudi Naziir <[email protected]> wrote:

Hi all,

I need to write(2) a certain character to a serial device (using the standard /dev/ttySx), and make sure it was transferred to the device before I continue. I tried fsync(2), but that failed (does fsync even apply to character devices or only block devices ?).

Block devices

Quoted 2 lines

Any idea ?

Most hardware UARTs actually can't do this but the kernel will do its best. The POSIX interface you want is tcdrain(fd). Quite why POSIX didn't use fsync is a very good question.

#2 lore raw
Quoted 3 lines · Alan Cox

Most hardware UARTs actually can't do this but the kernel will do its best. The POSIX interface you want is tcdrain(fd). Quite why POSIX didn't use fsync is a very good question.

Thank you so much !

Quoted 1 line