syndesi 0.2.1__py3-none-any.whl → 0.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- syndesi/adapters/serialport.py +10 -29
- {syndesi-0.2.1.dist-info → syndesi-0.2.2.dist-info}/METADATA +1 -1
- {syndesi-0.2.1.dist-info → syndesi-0.2.2.dist-info}/RECORD +7 -7
- {syndesi-0.2.1.dist-info → syndesi-0.2.2.dist-info}/LICENSE +0 -0
- {syndesi-0.2.1.dist-info → syndesi-0.2.2.dist-info}/WHEEL +0 -0
- {syndesi-0.2.1.dist-info → syndesi-0.2.2.dist-info}/entry_points.txt +0 -0
- {syndesi-0.2.1.dist-info → syndesi-0.2.2.dist-info}/top_level.txt +0 -0
syndesi/adapters/serialport.py
CHANGED
|
@@ -14,16 +14,6 @@ from .timed_queue import TimedQueue
|
|
|
14
14
|
from ..tools import shell
|
|
15
15
|
from ..tools.others import DEFAULT
|
|
16
16
|
|
|
17
|
-
# From pyserial - serialposix.py
|
|
18
|
-
import fcntl
|
|
19
|
-
import termios
|
|
20
|
-
import struct
|
|
21
|
-
if hasattr(termios, 'TIOCINQ'):
|
|
22
|
-
TIOCINQ = termios.TIOCINQ
|
|
23
|
-
else:
|
|
24
|
-
TIOCINQ = getattr(termios, 'FIONREAD', 0x541B)
|
|
25
|
-
TIOCM_zero_str = struct.pack('I', 0)
|
|
26
|
-
|
|
27
17
|
DEFAULT_TIMEOUT = Timeout(response=1, continuation=200e-3, total=None)
|
|
28
18
|
|
|
29
19
|
class SerialPort(Adapter):
|
|
@@ -53,8 +43,6 @@ class SerialPort(Adapter):
|
|
|
53
43
|
self._status = self.Status.DISCONNECTED
|
|
54
44
|
|
|
55
45
|
self._rts_cts = rts_cts
|
|
56
|
-
|
|
57
|
-
self._stop_event_pipe, self._stop_event_pipe_write = os.pipe()
|
|
58
46
|
|
|
59
47
|
def flushRead(self):
|
|
60
48
|
self._port.flush()
|
|
@@ -68,10 +56,8 @@ class SerialPort(Adapter):
|
|
|
68
56
|
self._logger.info("Adapter opened !")
|
|
69
57
|
|
|
70
58
|
def close(self):
|
|
71
|
-
if self._thread is not None and self._thread.is_alive():
|
|
72
|
-
os.write(self._stop_event_pipe_write, b'1')
|
|
73
|
-
self._thread.join()
|
|
74
59
|
if hasattr(self, '_port'):
|
|
60
|
+
# Close and the read thread will die by itself
|
|
75
61
|
self._port.close()
|
|
76
62
|
self._logger.info("Adapter closed !")
|
|
77
63
|
|
|
@@ -92,24 +78,19 @@ class SerialPort(Adapter):
|
|
|
92
78
|
"""
|
|
93
79
|
self._logger.debug("Starting read thread...")
|
|
94
80
|
if self._thread is None or not self._thread.is_alive():
|
|
95
|
-
self._thread = Thread(target=self._read_thread, daemon=True, args=(self._port, self._read_queue
|
|
81
|
+
self._thread = Thread(target=self._read_thread, daemon=True, args=(self._port, self._read_queue))
|
|
96
82
|
self._thread.start()
|
|
97
83
|
|
|
98
|
-
def _read_thread(self, port : serial.Serial , read_queue : TimedQueue
|
|
84
|
+
def _read_thread(self, port : serial.Serial , read_queue : TimedQueue):
|
|
85
|
+
# NOTE : There should be some way to kill the thread, maybe check for an error on in_waiting but couldn't find it so far
|
|
99
86
|
while True:
|
|
100
|
-
#
|
|
101
|
-
# Equivalent of port.in_waiting :
|
|
102
|
-
#in_waiting = struct.unpack('I', fcntl.ioctl(port.fd, TIOCINQ, TIOCM_zero_str))[0]
|
|
87
|
+
# Check how many bytes are available
|
|
103
88
|
in_waiting = self._port.in_waiting # This is a temporary fix to get windows compatiblity back, an error might pop up
|
|
104
|
-
if in_waiting
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
# Else, read as many bytes as possible
|
|
110
|
-
fragment = os.read(port.fd, 1000) # simplified version of port.read()
|
|
111
|
-
if fragment:
|
|
112
|
-
read_queue.put(fragment)
|
|
89
|
+
if in_waiting > 0:
|
|
90
|
+
# Read those bytes
|
|
91
|
+
fragment = port.read(in_waiting)
|
|
92
|
+
if fragment:
|
|
93
|
+
read_queue.put(fragment)
|
|
113
94
|
|
|
114
95
|
def read(self, timeout=None, stop_condition=None, return_metrics: bool = False) -> bytes:
|
|
115
96
|
"""
|
|
@@ -11,7 +11,7 @@ syndesi/adapters/ip_server.py,sha256=wFMF_uPvVnYHPqAkAOvIvRTrMh_WMtK53hUorzD9L5s
|
|
|
11
11
|
syndesi/adapters/proxy.py,sha256=Vdfh7UZLf3tJ68MItVkQijOnOT5iQaqDbvmKH9P7nhU,3011
|
|
12
12
|
syndesi/adapters/remote.py,sha256=XaaMGVSq7ygEijbETlsy-2cHSmMhZmmjA6UCm7hBTmE,552
|
|
13
13
|
syndesi/adapters/serial.py,sha256=cDp4lFt1f6Z6pRTWRXn0mjT_p0mZgAxqiJgtoXnEHDk,877
|
|
14
|
-
syndesi/adapters/serialport.py,sha256=
|
|
14
|
+
syndesi/adapters/serialport.py,sha256=66T8aG7s_PbZ3IcBEBSZOlQRV29hOc4zBb4K9q8Ham0,5264
|
|
15
15
|
syndesi/adapters/stop_conditions.py,sha256=-dWUpgXbFEtONBnvk04gjFUhcprf_KJb28aFMgsps4A,5599
|
|
16
16
|
syndesi/adapters/timed_queue.py,sha256=F-Bwj91cR_iLN2TdCkFL4WfvlJXovhyRF7K3dm30g50,912
|
|
17
17
|
syndesi/adapters/timeout.py,sha256=fH5MIJIUEqgDXtF9EgxZgjgAQ0mdeoybcmFznutXINo,11656
|
|
@@ -55,9 +55,9 @@ syndesi/tools/shell.py,sha256=A13htgZ0FsFfe8GMlv-4P_w0pv44ca5r4yshz990uqs,3556
|
|
|
55
55
|
syndesi/tools/stop_conditions.py,sha256=_H-GPczrLTbPRHYpoPIItOqmPnemwn34QbKFn5GD6Uc,4824
|
|
56
56
|
syndesi/tools/types.py,sha256=rEpz5wEYGcJgYkRffRP9sYAhKv8X6DNCXIeI8Zcsvfc,1630
|
|
57
57
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
58
|
-
syndesi-0.2.
|
|
59
|
-
syndesi-0.2.
|
|
60
|
-
syndesi-0.2.
|
|
61
|
-
syndesi-0.2.
|
|
62
|
-
syndesi-0.2.
|
|
63
|
-
syndesi-0.2.
|
|
58
|
+
syndesi-0.2.2.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
59
|
+
syndesi-0.2.2.dist-info/METADATA,sha256=Ec2HsAR9U7kAYIEYe6EZGRfx3yHwAgQFOnlZKW8oPHA,3468
|
|
60
|
+
syndesi-0.2.2.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
|
61
|
+
syndesi-0.2.2.dist-info/entry_points.txt,sha256=Q_38BGDXKEFxNPSXtkT8brn6f8lmOrkdkEv0IOV-YOM,96
|
|
62
|
+
syndesi-0.2.2.dist-info/top_level.txt,sha256=HrY36JU6hFYp_6qv-GuVBBtHYYemn8qhCrqpvXBd1Lg,8
|
|
63
|
+
syndesi-0.2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|