Skip to content

Instantly share code, notes, and snippets.

@vegertar
Created February 26, 2023 06:12
Show Gist options
  • Save vegertar/f89a212870d64bc154def57b7f2550dc to your computer and use it in GitHub Desktop.
Save vegertar/f89a212870d64bc154def57b7f2550dc to your computer and use it in GitHub Desktop.
Make pyserial work in DragonflyBSD properly
From 87e58dcc9e372de8399676d9151b634f69ad821d Mon Sep 17 00:00:00 2001
From: Joe Hu <vegertar@gmail.com>
Date: Sat, 25 Feb 2023 08:47:44 +0800
Subject: [PATCH] add DragonFlyBSD
---
serial/serialposix.py | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/serial/serialposix.py b/serial/serialposix.py
index 0464075..6ec4334 100644
--- a/serial/serialposix.py
+++ b/serial/serialposix.py
@@ -243,7 +243,8 @@ elif plat[:6] == 'darwin': # OS X
elif plat[:3] == 'bsd' or \
plat[:7] == 'freebsd' or \
plat[:6] == 'netbsd' or \
- plat[:7] == 'openbsd':
+ plat[:7] == 'openbsd' or \
+ plat[:9] == 'dragonfly':
class ReturnBaudrate(object):
def __getitem__(self, key):
@@ -270,7 +271,7 @@ elif plat[:3] == 'bsd' or \
else:
class PlatformSpecific(PlatformSpecificBase):
- pass
+ raise NotImplementedError(plat)
# load some constants for later use.
@@ -677,7 +678,11 @@ class Serial(SerialBase, PlatformSpecific):
"""
if not self.is_open:
raise PortNotOpenError()
- termios.tcdrain(self.fd)
+ # termios.tcdrain(self.fd)
+ # poll to prevent from hanging forever
+ while self.out_waiting:
+ import time
+ time.sleep(0.05)
def _reset_input_buffer(self):
"""Clear input buffer, discarding all that is in the buffer."""
--
2.38.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment