From 172f34f872e3d5e621172050b431c05fe0014121 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Wed, 9 Dec 2015 22:45:57 +0000 Subject: [PATCH] bug #46610: Floating point exception (core dumped) arch linux rpi2 bug #46483: version 6.2. ser_open(): can't set attributes for device * ser_posix.c: Back out change from patch #8380 git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1365 81a1dc3b-b13d-400b-aceb-764788c761c2 --- ChangeLog | 6 ++++ NEWS | 1 - ser_posix.c | 88 ++++------------------------------------------------- 3 files changed, 12 insertions(+), 83 deletions(-) diff --git a/ChangeLog b/ChangeLog index a6a2340f..50131804 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2015-12-09 Joerg Wunsch + + bug #46610: Floating point exception (core dumped) arch linux rpi2 + bug #46483: version 6.2. ser_open(): can't set attributes for device + * ser_posix.c: Back out change from patch #8380 + 2015-11-16 Joerg Wunsch * configure.ac: Bump for post-release 6.2. diff --git a/NEWS b/NEWS index 423ffa5b..9af35ca9 100644 --- a/NEWS +++ b/NEWS @@ -76,7 +76,6 @@ Version 6.2: - bug #40870: config nitpick: ATtiny25/45/85 have 1 calibration byte not 2 - bug #42908: no external reset at JTAGICE3 - patch #8437: [PATCH] Serial-over-ethernet for Win32 - - patch #8380: adds 500k 1M 2M baud to ser_posix.c - bug #44717: avrdude creates empty flash dump * Internals: diff --git a/ser_posix.c b/ser_posix.c index 20230f9b..beeb9bdc 100644 --- a/ser_posix.c +++ b/ser_posix.c @@ -37,9 +37,6 @@ #include #include #include -#ifdef __linux__ -#include -#endif #include #include @@ -55,13 +52,8 @@ struct baud_mapping { speed_t speed; }; -static struct termios original_termios; -static int saved_original_termios; +/* There are a lot more baud rates we could handle, but what's the point? */ -#if !defined __linux__ -/* For linux this mapping is no longer needed. - * (OSX and *BSD do not need this mapping either because for them, - * Bxxx is the same as xxx.) */ static struct baud_mapping baud_lookup_table [] = { { 1200, B1200 }, { 2400, B2400 }, @@ -81,6 +73,8 @@ static struct baud_mapping baud_lookup_table [] = { { 0, 0 } /* Terminator. */ }; +static struct termios original_termios; +static int saved_original_termios; static speed_t serial_baud_lookup(long baud) { @@ -101,19 +95,12 @@ static speed_t serial_baud_lookup(long baud) return baud; } -#endif static int ser_setspeed(union filedescriptor *fd, long baud) { int rc; struct termios termios; -#if defined __linux__ - /* for linux no conversion is needed*/ - speed_t speed = baud; -#else - /* converting the baud rate to the bit set needed by posix way*/ speed_t speed = serial_baud_lookup (baud); -#endif if (!isatty(fd->ifd)) return -ENOTTY; @@ -141,79 +128,16 @@ static int ser_setspeed(union filedescriptor *fd, long baud) termios.c_cflag = (CS8 | CREAD | CLOCAL); termios.c_cc[VMIN] = 1; termios.c_cc[VTIME] = 0; -#ifdef __linux__ - /* Support for custom baud rate for linux is implemented by setting - * a dummy baud rate of 38400 and manupulating the custom divider of - * the serial interface*/ - struct serial_struct ss; - int ioret = ioctl(fd->ifd, TIOCGSERIAL, &ss); - if (ioret < 0){ - avrdude_message(MSG_INFO, - "%s: Cannot get serial port settings. ioctl returned %d\n", - progname, ioret); - return -errno; - } - ss.flags = (ss.flags & ~ASYNC_SPD_MASK) | ASYNC_SPD_CUST; - ss.custom_divisor = (ss.baud_base + (speed / 2)) / speed; - unsigned int closestSpeed = ss.baud_base / ss.custom_divisor; - if (closestSpeed < speed * 98 / 100 || closestSpeed > speed * 102 / 100) { - avrdude_message(MSG_INFO, - "%s: Cannot set serial port speed to %d. Closest possible is %d\n", - progname, speed, closestSpeed); - return -errno; - } - ioret= ioctl(fd->ifd, TIOCSSERIAL, &ss); - if (ioret < 0){ - avrdude_message(MSG_INFO, - "%s: Cannot set serial port speed to %d. ioctl returned %d\n", - progname, speed, ioret); - return -errno; - } - if (cfsetispeed(&termios, B38400) < 0){ - avrdude_message(MSG_INFO, - "%s: cfsetispeed: failed to set dummy baud\n", - progname); - return -errno; - } - if (cfsetospeed(&termios, B38400) < 0){ - avrdude_message(MSG_INFO, - "%s: cfsetospeed: failed to set dummy baud\n", - progname); - return -errno; - } -#else /* !linux */ - if (cfsetospeed(&termios, speed) < 0){ - avrdude_message(MSG_INFO, - "%s: cfsetospeed: failed to set speed: %d\n", - progname, speed); - return -errno; - } - if (cfsetispeed(&termios, speed) < 0){ - avrdude_message(MSG_INFO, - "%s: cfsetispeed: failed to set speed: %d\n", - progname, speed); - return -errno; - } -#endif /* linux */ + cfsetospeed(&termios, speed); + cfsetispeed(&termios, speed); + rc = tcsetattr(fd->ifd, TCSANOW, &termios); if (rc < 0) { avrdude_message(MSG_INFO, "%s: ser_setspeed(): tcsetattr() failed\n", progname); return -errno; } -#ifdef __linux__ - /* a bit more linux specific stuff to set custom baud rates*/ - if (ioctl(fd->ifd, TIOCGSERIAL, &ss) < 0){ - avrdude_message(MSG_INFO, "%s: ioctl: failed to get port settins\n", progname); - return -errno; - } - ss.flags &= ~ASYNC_SPD_MASK; - if (ioctl(fd->ifd, TIOCSSERIAL, &ss) < 0){ - avrdude_message(MSG_INFO, "%s: ioctl: failed to set port settins\n", progname); - return -errno; - } -#endif /* * Everything is now set up for a local line without modem control