public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Paul Komkoff <i@stingr.net>
To: git-commits@fedoraproject.org
Subject: [rpms/pyserial] rawhide: Fix mips and pps operation (cherry-picked from upstream)
Date: Thu, 25 Jun 2026 18:09:15 GMT [thread overview]
Message-ID: <178241095545.1.11057271524711964968.rpms-pyserial-1f12fd893284@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/pyserial
Branch : rawhide
Commit : 1f12fd89328412a99f082ac10487c9ba936d977c
Author : Paul Komkoff <i@stingr.net>
Date : 2026-06-25T19:06:19+01:00
Stats : +140/-1 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/pyserial/c/1f12fd89328412a99f082ac10487c9ba936d977c?branch=rawhide
Log:
Fix mips and pps operation (cherry-picked from upstream)
This includes:
- Add support for setting a custom baudrate on the MIPS platform
- Adjust architectures detection for compatibility with MIPS/MIPS64
- Fix setting custom baudrates on linux/ppc{64,64le} machines
- serial_posix: Fix custom baud rates for glibc >=2.42; solves #805
Thanks to Dan Horák <dan@danny.cz> for cherry-picking the important bits.
---
diff --git a/0001-cherry-picked-fixes-from-upstream.patch b/0001-cherry-picked-fixes-from-upstream.patch
new file mode 100644
index 0000000..8889de4
--- /dev/null
+++ b/0001-cherry-picked-fixes-from-upstream.patch
@@ -0,0 +1,138 @@
+commit 5ce1773fdce16a0b184363695a7d7d9483c4da0c
+Author: ckielstra <c.kielstra@ultimaker.com>
+Date: Mon Apr 13 21:29:02 2020 +0200
+
+ Add support for setting a custom baudrate on the MIPS platform
+
+ Fixed the issue where a custom baudrate could not be set for the MIPS platform.
+ The hard coded values in the IOCTL call do differ in MIPS when compared to most other platforms.
+
+diff --git a/serial/serialposix.py b/serial/serialposix.py
+index 7aceb76..0464075 100644
+--- a/serial/serialposix.py
++++ b/serial/serialposix.py
+@@ -32,6 +32,7 @@ from __future__ import absolute_import
+ import errno
+ import fcntl
+ import os
++import platform
+ import select
+ import struct
+ import sys
+@@ -80,8 +81,14 @@ if plat[:5] == 'linux': # Linux (confirmed) # noqa
+ CMSPAR = 0o10000000000 # Use "stick" (mark/space) parity
+
+ # baudrate ioctls
+- TCGETS2 = 0x802C542A
+- TCSETS2 = 0x402C542B
++ if platform.machine().lower() == "mips":
++ TCGETS2 = 0x4030542A
++ TCSETS2 = 0x8030542B
++ BAUDRATE_OFFSET = 10
++ else:
++ TCGETS2 = 0x802C542A
++ TCSETS2 = 0x402C542B
++ BAUDRATE_OFFSET = 9
+ BOTHER = 0o010000
+
+ # RS485 ioctls
+@@ -154,7 +161,7 @@ if plat[:5] == 'linux': # Linux (confirmed) # noqa
+ # set custom speed
+ buf[2] &= ~termios.CBAUD
+ buf[2] |= BOTHER
+- buf[9] = buf[10] = baudrate
++ buf[BAUDRATE_OFFSET] = buf[BAUDRATE_OFFSET + 1] = baudrate
+
+ # set serial_struct
+ fcntl.ioctl(self.fd, TCSETS2, buf)
+commit 2aea0ba436d7a6af2f9f81b0daf245946b76dfe3
+Author: HinataKato <57648531+HinataKato@users.noreply.github.com>
+Date: Sun Nov 19 00:36:32 2023 +0800
+
+ Adjust architectures detection for compatibility with MIPS/MIPS64
+
+ This change ensures that the code handles both "mips" and "mips64" architectures correctly.
+
+diff --git a/serial/serialposix.py b/serial/serialposix.py
+index 8700af6..4233fa5 100644
+--- a/serial/serialposix.py
++++ b/serial/serialposix.py
+@@ -81,7 +81,7 @@ if plat[:5] == 'linux': # Linux (confirmed) # noqa
+ CMSPAR = 0o10000000000 # Use "stick" (mark/space) parity
+
+ # baudrate ioctls
+- if platform.machine().lower() == "mips":
++ if "mips" in platform.machine().lower():
+ TCGETS2 = 0x4030542A
+ TCSETS2 = 0x8030542B
+ BAUDRATE_OFFSET = 10
+commit 5eb1eafe1091d38c5478c16ecbb04e6c82d7eb47
+Author: Shawn Anastasio <shawn@anastas.io>
+Date: Mon Apr 21 19:02:53 2025 -0500
+
+ Fix setting custom baudrates on linux/ppc{64,64le} machines
+
+ serialposix.py's PlatformSpecific._set_special_baudrate uses the
+ TCGETS2/TCSETS2 ioctls on linux to set custom baud rates, but the
+ correct ioctl number and constants are not present for ppc.
+
+ Fix this by defining the required constants when running on a ppc
+ machine, as is already done for mips.
+
+ Signed-off-by: Shawn Anastasio <shawn@anastas.io>
+
+diff --git a/serial/serialposix.py b/serial/serialposix.py
+index e2980a7..46cd059 100644
+--- a/serial/serialposix.py
++++ b/serial/serialposix.py
+@@ -85,11 +85,17 @@ if plat[:5] == 'linux': # Linux (confirmed) # noqa
+ TCGETS2 = 0x4030542A
+ TCSETS2 = 0x8030542B
+ BAUDRATE_OFFSET = 10
++ BOTHER = 0o010000
++ elif platform.machine().lower().startswith("ppc"):
++ TCGETS2 = 0x403c7413
++ TCSETS2 = 0x803c7414
++ BAUDRATE_OFFSET = 13
++ BOTHER = 0x0000001f
+ else:
+ TCGETS2 = 0x802C542A
+ TCSETS2 = 0x402C542B
+ BAUDRATE_OFFSET = 9
+- BOTHER = 0o010000
++ BOTHER = 0o010000
+
+ # RS485 ioctls
+ TIOCGRS485 = 0x542E
+commit 70d188643b031d10d2a2b9ea880bd56789fdb1f6
+Author: Alexander von Gluck IV <alex@terarocket.io>
+Date: Sun Aug 24 20:17:51 2025 -0500
+
+ serial_posix: Fix custom baud rates for glibc >=2.42; solves #805
+
+ * https://sourceware.org/pipermail/libc-alpha/2025-July/168553.html
+ * Based on changes recommended by JoaoBarioni in #805
+ * Reverts 0085e1e1d (#519)
+
+diff --git a/serial/serialposix.py b/serial/serialposix.py
+index af6ac9d..9cbb05f 100644
+--- a/serial/serialposix.py
++++ b/serial/serialposix.py
+@@ -434,15 +434,8 @@ class Serial(SerialBase, PlatformSpecific):
+ ispeed = ospeed = self.BAUDRATE_CONSTANTS[self._baudrate]
+ except KeyError:
+ #~ raise ValueError('Invalid baud rate: %r' % self._baudrate)
+-
+- # See if BOTHER is defined for this platform; if it is, use
+- # this for a speed not defined in the baudrate constants list.
+- try:
+- ispeed = ospeed = BOTHER
+- except NameError:
+- # may need custom baud rate, it isn't in our list.
+- ispeed = ospeed = getattr(termios, 'B38400')
+-
++ # Use safe placeholder for tcsetattr(), try to set special baudrate later
++ ispeed = ospeed = termios.B38400
+ try:
+ custom_baud = int(self._baudrate) # store for later
+ except ValueError:
diff --git a/pyserial.spec b/pyserial.spec
index 5e6ae5b..35ab8d5 100644
--- a/pyserial.spec
+++ b/pyserial.spec
@@ -3,6 +3,7 @@ Name: pyserial
Version: 3.5
Release: %autorelease
Source0: %pypi_source
+Patch0: 0001-cherry-picked-fixes-from-upstream.patch
License: BSD-3-Clause
URL: https://pypi.org/project/pyserial/
BuildRequires: python3-devel
@@ -26,7 +27,7 @@ Conflicts: python2-pyserial < 3.4-6
%prep
export UNZIP="-aa"
-%autosetup
+%autosetup -p1
# Python 3.13+ has removed unittest.findTestCases()
# Reported upstream: https://github.com/pyserial/pyserial/issues/754
reply other threads:[~2026-06-25 18:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=178241095545.1.11057271524711964968.rpms-pyserial-1f12fd893284@fedoraproject.org \
--to=i@stingr.net \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox