Remove the extra check of the termios structure.

The extra memcmp check after the tcsetattr call is intended to verify
whether all the changes to the termios structure have been applied
correctly.

But for pty's, some of the termios settings make no sense at all, and
therefore the Linux kernel always does:

    tty->termios.c_cflag &= ~(CSIZE | PARENB);
    tty->termios.c_cflag |= (CS8 | CREAD);

Thus, instead of ignoring such nonsense termios settings, the kernel
changes the termios structure to reflect what pty's actually do. The
consequence is that these settings will not stick, and cause the memcmp
check to fail.

An example where this affects libdivecomputer, are the two backends that
require odd or even parity (e.g. vyper and iconhd). Here, the kernel
will clear the PARENB flag, and thus cause the memcmp check to fail.

Since this check appears to causes more trouble than it solves, let's
just remove it completely!
This commit is contained in:
Jef Driesen 2014-05-28 06:29:34 +02:00
parent 5f1a18653d
commit 197b9f0942

View File

@ -417,22 +417,6 @@ serial_configure (serial_t *device, int baudrate, int databits, int parity, int
return -1;
}
// tcsetattr() returns success if any of the requested changes could be
// successfully carried out. Therefore, when making multiple changes
// it may be necessary to follow this call with a further call to
// tcgetattr() to check that all changes have been performed successfully.
struct termios active;
memset (&active, 0, sizeof (active));
if (tcgetattr (device->fd, &active) != 0) {
SYSERROR (device->context, errno);
return -1;
}
if (memcmp (&tty, &active, sizeof (struct termios)) != 0) {
ERROR (device->context, "Failed to set the terminal attributes.");
return -1;
}
// Configure a custom baudrate if necessary.
if (custom) {
#if defined(TIOCGSERIAL) && defined(TIOCSSERIAL) && !defined(__ANDROID__)