diff --git a/testcases/rs485pingpong/rs485pingpong.c b/testcases/rs485pingpong/rs485pingpong.c index ba7ff55e0fe24fbaafb855f3f5e3ce164f582cf6..120ea9e6279d95ded75e0b900e0b550047492336 100644 --- a/testcases/rs485pingpong/rs485pingpong.c +++ b/testcases/rs485pingpong/rs485pingpong.c @@ -34,15 +34,19 @@ /******************************************************************************/ /* Standard Include Files */ -#include <stdio.h> -#include <stdlib.h> #include <errno.h> #include <fcntl.h> -#include <termios.h> -#include <time.h> -#include <linux/serial.h> +#include <unistd.h> +#include <stdio.h> +#include <stdlib.h> #include <sys/ioctl.h> +#include <sys/param.h> +#include <time.h> +#define TTYDEFCHARS +#include <termios.h> +#undef TTYDEFCHARS #include <asm/ioctls.h> +#include <linux/serial.h> /* Harness Specific Include Files. */ #include "old/test.h" @@ -226,15 +230,21 @@ setup() } // Get old attribute - if (tcgetattr (fd, &termios)) { + if (tcgetattr(fd, &termios)) { // This is not a serial device tst_brkm(TBROK, cleanup, "Can't read device configuration. Is this a serial device? \ Error:%d, %s\n", errno, strerror(errno)); } + termios.c_cflag = TTYDEF_CFLAG; + termios.c_iflag = TTYDEF_IFLAG; + termios.c_oflag = TTYDEF_OFLAG; + termios.c_lflag = TTYDEF_LFLAG; + memcpy(termios.c_cc, ttydefchars, MIN(sizeof(termios.c_cc), sizeof(ttydefchars))); // not 100% sure if this is sound and safe + // Set Speed into termios structure - if (cfsetospeed (&termios, baud)) { + if (cfsetspeed (&termios, baud)) { tst_brkm(TBROK, cleanup, "Can't set baud rate. Error:%d, %s\n", errno, strerror(errno));