I need to save the terminal attributes (tcgetattr), set them to something that will block terminal echoing etc. (calling tcsetattr), and then later, after doing things with the framebuffer device /dev/fb0, restore the original attributes (calling tcsetattr).
I'm finding that the second call to tcsetattr always fails with an I/O error i.e. errno == EIO.
Is there a special trick to doing this?
struct termios originaltermios;
struct termios newtermios;
tcgetattr(console_fd, &originaltermios);
//
newtermios = originaltermios;
tcsdrain(console_fd);
// (change newtermios here)
tcsetattr(console_fd, TCSANOW, &newtermios);
// ... do some stuff for 10-20 seconds with /dev/fd0
if (tcsetattr(console_fd, TCSANOW, &originaltermios)) {
perror("tcsetattr"); // EIO
}
new_termios.c_lflag &= ~ECHO;
new_termios.c_lflag &= ~ISIG;
new_termios.c_lflag &= ~ICANON;
new_termios.c_lflag &= ~IEXTEN;
new_termios.c_iflag &= ~ISTRIP;
new_termios.c_iflag &= ~ICRNL;
new_termios.c_iflag &= ~INLCR;
new_termios.c_iflag &= ~IGNCR;
new_termios.c_iflag &= ~BRKINT;
new_termios.c_iflag &= ~(IXON|IXOFF);
new_termios.c_cc[VMIN] = 0;
new_termios.c_cc[VTIME] = 0;