This is what my function looks like to open the serial port (using Ubuntu 12.04):
int open_port(void) { int fd; /* File descriptor for the port */ fd =
I think I figured it out. For some reason, I need to add a delay before flushing. These two lines added before returning fd seem to have done the trick:
fd
sleep(2); //required to make flush work, for some reason tcflush(fd,TCIOFLUSH);