sdev 0.3.2__tar.gz → 0.3.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sdev
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: 串口控制器工具包
5
5
  Home-page: https://github.com/klrc/sdev
6
6
  Author: klrc
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "sdev"
7
- version = "0.3.2"
7
+ version = "0.3.3"
8
8
  description = "串口控制器工具包"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -6,7 +6,7 @@ Demoboard:串口连接、后台异步读、发送、按行/按 flag 读、回
6
6
 
7
7
  from .core import SerialDevice
8
8
 
9
- __version__ = "0.3.2"
9
+ __version__ = "0.3.3"
10
10
  __author__ = "klrc"
11
11
  __email__ = "1440698245@qq.com"
12
12
 
@@ -213,26 +213,27 @@ class SerialDevice:
213
213
  gen = self.scan_and_display(flag, "end_flag", timeout=timeout)
214
214
  _ = list(gen)
215
215
 
216
+ def is_breathing(self) -> bool:
217
+ """检查板子是否呼吸。"""
218
+ time.sleep(self._check_alive_timeout)
219
+ return self._has_output_in_buffer()
220
+
216
221
  def check_alive(self, stable_flag: str):
217
222
  """
218
223
  确认板子存活:有输出则 wait_for_flag(stable_flag) 后 return;否则 send_interrupt,成功则 return。
219
224
  若 send_interrupt 超时则打 warning 并轮询 _has_output_in_buffer(),有数据再 wait_for_flag 后 return;未接串口会一直循环。
220
225
  """
221
- time.sleep(self._check_alive_timeout)
222
- if self._has_output_in_buffer(): # 可能正在启动,等待稳定标志
223
- self.wait_for_flag(stable_flag, self._reboot_timeout)
224
- return
226
+ while self.is_breathing():
227
+ pass
225
228
 
226
- # 测试是否能够接收ctrlc信号,若无反应, wait for boot
229
+ # 测试是否能够接收ctrlc信号,若无反应,等待转生
227
230
  try:
228
231
  self.send_interrupt(self._check_alive_timeout, stable_flag)
229
232
  except TimeoutError:
230
233
  logger.warning(f"请接入串口")
231
- while True:
232
- time.sleep(self._check_alive_timeout)
233
- if self._has_output_in_buffer():
234
- self.wait_for_flag(stable_flag, self._reboot_timeout)
235
- return
234
+ while not self.is_breathing():
235
+ pass
236
+ self.check_alive(stable_flag)
236
237
 
237
238
  def __enter__(self):
238
239
  self.connect()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sdev
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: 串口控制器工具包
5
5
  Home-page: https://github.com/klrc/sdev
6
6
  Author: klrc
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="sdev",
8
- version="0.3.2",
8
+ version="0.3.3",
9
9
  author="klrc",
10
10
  author_email="144069824@qq.com",
11
11
  description="串口控制器工具包",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes