pytest-embedded-serial 2.1.2__tar.gz → 2.2.1__tar.gz
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.
- {pytest_embedded_serial-2.1.2 → pytest_embedded_serial-2.2.1}/PKG-INFO +2 -2
- {pytest_embedded_serial-2.1.2 → pytest_embedded_serial-2.2.1}/pyproject.toml +1 -1
- {pytest_embedded_serial-2.1.2 → pytest_embedded_serial-2.2.1}/pytest_embedded_serial/__init__.py +1 -1
- {pytest_embedded_serial-2.1.2 → pytest_embedded_serial-2.2.1}/pytest_embedded_serial/serial.py +46 -1
- {pytest_embedded_serial-2.1.2 → pytest_embedded_serial-2.2.1}/LICENSE +0 -0
- {pytest_embedded_serial-2.1.2 → pytest_embedded_serial-2.2.1}/README.md +0 -0
- {pytest_embedded_serial-2.1.2 → pytest_embedded_serial-2.2.1}/pytest_embedded_serial/dut.py +0 -0
- {pytest_embedded_serial-2.1.2 → pytest_embedded_serial-2.2.1}/tests/test_serial.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytest-embedded-serial
|
|
3
|
-
Version: 2.1
|
|
3
|
+
Version: 2.2.1
|
|
4
4
|
Summary: Make pytest-embedded plugin work with Serial.
|
|
5
5
|
Author-email: Fu Hanxi <fuhanxi@espressif.com>
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -19,7 +19,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
19
19
|
Classifier: Programming Language :: Python
|
|
20
20
|
Classifier: Topic :: Software Development :: Testing
|
|
21
21
|
License-File: LICENSE
|
|
22
|
-
Requires-Dist: pytest-embedded~=2.1
|
|
22
|
+
Requires-Dist: pytest-embedded~=2.2.1
|
|
23
23
|
Requires-Dist: pyserial~=3.0
|
|
24
24
|
Project-URL: changelog, https://github.com/espressif/pytest-embedded/blob/main/CHANGELOG.md
|
|
25
25
|
Project-URL: documentation, https://docs.espressif.com/projects/pytest-embedded/en/latest/
|
{pytest_embedded_serial-2.1.2 → pytest_embedded_serial-2.2.1}/pytest_embedded_serial/serial.py
RENAMED
|
@@ -193,8 +193,53 @@ class _SerialRedirectThread(threading.Thread):
|
|
|
193
193
|
|
|
194
194
|
try:
|
|
195
195
|
s = self._s.read_all()
|
|
196
|
+
except OSError as e:
|
|
197
|
+
logging.error(f'OSError detected: {e}. Serial connection may be lost.')
|
|
198
|
+
if self._s.closed:
|
|
199
|
+
logging.error('Serial port is already closed. Exiting event loop.')
|
|
200
|
+
return
|
|
201
|
+
|
|
202
|
+
port = self._s.port
|
|
203
|
+
port_config = {
|
|
204
|
+
'baudrate': self._s.baudrate,
|
|
205
|
+
'bytesize': self._s.bytesize,
|
|
206
|
+
'parity': self._s.parity,
|
|
207
|
+
'stopbits': self._s.stopbits,
|
|
208
|
+
'timeout': self._s.timeout,
|
|
209
|
+
'xonxoff': self._s.xonxoff,
|
|
210
|
+
'rtscts': self._s.rtscts,
|
|
211
|
+
}
|
|
212
|
+
for attempt in range(1, 4):
|
|
213
|
+
delay = attempt * 1.5
|
|
214
|
+
logging.warning(
|
|
215
|
+
f'Attempting to reconnect to serial port {port} (try {attempt}/3) after {delay}s...'
|
|
216
|
+
)
|
|
217
|
+
time.sleep(delay)
|
|
218
|
+
try:
|
|
219
|
+
self._s.close()
|
|
220
|
+
self._s = pyserial.serial_for_url(port, **port_config)
|
|
221
|
+
logging.info(f'Successfully reconnected to serial port {port}.')
|
|
222
|
+
break
|
|
223
|
+
except Exception as e:
|
|
224
|
+
logging.warning(f'Reconnection attempt {attempt} failed: {e}')
|
|
225
|
+
else:
|
|
226
|
+
logging.error(
|
|
227
|
+
f'Failed to reconnect to serial port {port} after 3 attempts. Exiting event loop.'
|
|
228
|
+
)
|
|
229
|
+
return
|
|
230
|
+
|
|
231
|
+
continue
|
|
232
|
+
|
|
233
|
+
except Exception as e:
|
|
234
|
+
logging.warning(
|
|
235
|
+
'unknown error: %s.\nRecommend to close the serial process by `dut.serial.close()`', str(e)
|
|
236
|
+
)
|
|
237
|
+
return
|
|
238
|
+
|
|
239
|
+
try:
|
|
196
240
|
self._q.put(s)
|
|
197
|
-
except OSError:
|
|
241
|
+
except OSError as e:
|
|
242
|
+
logging.warning(f'OSError. Error msg: {e}')
|
|
198
243
|
return
|
|
199
244
|
except Exception as e:
|
|
200
245
|
logging.warning(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|