I have a serial device on /dev/ttyAMA0. I have program written in C that communicates with this device. But apart from the C program I sometimes need to input some configuration data from terminal, for example: echo xxx >> /dev/ttyAMA0. Problem is that the device replies to this configuration input (something like parameter xxx set) but I do not read (because I don't need to) this reply so it buffers in the serial port's buffer. This causes problems in the C program because I need to read data from it but there is already this reply buffered that I do not care about.
So my question. How do I flush device's buffer from terminal? I know I can use tcflush(sfd, TCIOFLUSH); in C but I need to do it from terminal.
echoclearly only does half the job.