Skip to content
Snippets Groups Projects
Commit 7df45e0b authored by Clemens Terasa's avatar Clemens Terasa
Browse files

rs485pingpong: Set default tty settings, refs #39874

The rs485pingpon test tool uses partly the tty settings that are setup
prior to execution.
This might lead to problems when the tty is misconfigured.

Use the default tty settings from glibc instead.
This was inspired by "stty sane"

Change-Id: Ie1a5d69edddb967e4dc284a450e3195e53d6af3c
parent 6629dc78
No related branches found
No related tags found
No related merge requests found
...@@ -34,15 +34,19 @@ ...@@ -34,15 +34,19 @@
/******************************************************************************/ /******************************************************************************/
/* Standard Include Files */ /* Standard Include Files */
#include <stdio.h>
#include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <termios.h> #include <unistd.h>
#include <time.h> #include <stdio.h>
#include <linux/serial.h> #include <stdlib.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/param.h>
#include <time.h>
#define TTYDEFCHARS
#include <termios.h>
#undef TTYDEFCHARS
#include <asm/ioctls.h> #include <asm/ioctls.h>
#include <linux/serial.h>
/* Harness Specific Include Files. */ /* Harness Specific Include Files. */
#include "old/test.h" #include "old/test.h"
...@@ -226,15 +230,21 @@ setup() ...@@ -226,15 +230,21 @@ setup()
} }
// Get old attribute // Get old attribute
if (tcgetattr (fd, &termios)) { if (tcgetattr(fd, &termios)) {
// This is not a serial device // This is not a serial device
tst_brkm(TBROK, cleanup, tst_brkm(TBROK, cleanup,
"Can't read device configuration. Is this a serial device? \ "Can't read device configuration. Is this a serial device? \
Error:%d, %s\n", errno, strerror(errno)); 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 // Set Speed into termios structure
if (cfsetospeed (&termios, baud)) { if (cfsetspeed (&termios, baud)) {
tst_brkm(TBROK, cleanup, tst_brkm(TBROK, cleanup,
"Can't set baud rate. Error:%d, %s\n", "Can't set baud rate. Error:%d, %s\n",
errno, strerror(errno)); errno, strerror(errno));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment