sdev 0.6.2__tar.gz → 0.6.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.6.2
3
+ Version: 0.6.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.6.2"
7
+ version = "0.6.3"
8
8
  description = "串口控制器工具包"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -10,7 +10,7 @@ from __future__ import annotations
10
10
  from .models import Demoboard
11
11
  from .remote import any_device
12
12
 
13
- __version__ = "0.6.2"
13
+ __version__ = "0.6.3"
14
14
  __author__ = "klrc"
15
15
  __email__ = "1440698245@qq.com"
16
16
 
@@ -382,6 +382,8 @@ def cmd_shell(args: argparse.Namespace) -> int:
382
382
 
383
383
  # 若未显式指定 --timeout,则默认等待 60 秒,避免长命令过早被认为超时。
384
384
  effective_timeout: Optional[float] = args.timeout if args.timeout is not None else 60.0
385
+ # Ctrl-C / 超时后的「收尾」等待不需要这么久,单独使用较短的间隔。
386
+ interrupt_timeout: Optional[float] = min(effective_timeout, 5.0) if effective_timeout is not None else 5.0
385
387
 
386
388
  with Demoboard(port, baudrate, host=host) as board:
387
389
  try:
@@ -392,13 +394,19 @@ def cmd_shell(args: argparse.Namespace) -> int:
392
394
  try:
393
395
  board.send_interrupt()
394
396
  # 不再发送新命令,仅等待当前提示符出现作为“收尾”信号。
395
- _ = board.execute_command(None, flag=args.flag, timeout=effective_timeout)
397
+ _ = board.execute_command(None, flag=args.flag, timeout=interrupt_timeout)
396
398
  except Exception:
397
399
  pass
398
400
  print() # 保证光标回到新行
399
401
  return 130 # 约定:被 Ctrl-C 中断
400
402
  except TimeoutError as e:
403
+ # 命令执行超时时,自动向板子发送一次 Ctrl-C,并尝试等提示符收尾。
401
404
  print(e, file=sys.stderr)
405
+ try:
406
+ board.send_interrupt()
407
+ _ = board.execute_command(None, flag=args.flag, timeout=interrupt_timeout)
408
+ except Exception:
409
+ pass
402
410
  return 1
403
411
  print()
404
412
  # sys.stdout.flush()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sdev
3
- Version: 0.6.2
3
+ Version: 0.6.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.6.2",
8
+ version="0.6.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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes