sdev 0.6.0__tar.gz → 0.6.2__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.
- {sdev-0.6.0/sdev.egg-info → sdev-0.6.2}/PKG-INFO +1 -1
- {sdev-0.6.0 → sdev-0.6.2}/pyproject.toml +1 -1
- {sdev-0.6.0 → sdev-0.6.2}/sdev/__init__.py +1 -1
- {sdev-0.6.0 → sdev-0.6.2}/sdev/base/serial_core.py +17 -0
- {sdev-0.6.0 → sdev-0.6.2}/sdev/cli/cli_wrapper.py +18 -4
- {sdev-0.6.0 → sdev-0.6.2}/sdev/models/demoboard.py +14 -1
- {sdev-0.6.0 → sdev-0.6.2}/sdev/remote/board_list.py +1 -3
- {sdev-0.6.0 → sdev-0.6.2}/sdev/remote/client.py +17 -0
- {sdev-0.6.0 → sdev-0.6.2/sdev.egg-info}/PKG-INFO +1 -1
- {sdev-0.6.0 → sdev-0.6.2}/setup.py +1 -1
- {sdev-0.6.0 → sdev-0.6.2}/LICENSE +0 -0
- {sdev-0.6.0 → sdev-0.6.2}/MANIFEST.in +0 -0
- {sdev-0.6.0 → sdev-0.6.2}/README.md +0 -0
- {sdev-0.6.0 → sdev-0.6.2}/sdev/base/__init__.py +0 -0
- {sdev-0.6.0 → sdev-0.6.2}/sdev/cli/__init__.py +0 -0
- {sdev-0.6.0 → sdev-0.6.2}/sdev/models/__init__.py +0 -0
- {sdev-0.6.0 → sdev-0.6.2}/sdev/remote/__init__.py +0 -0
- {sdev-0.6.0 → sdev-0.6.2}/sdev/remote/discovery.py +0 -0
- {sdev-0.6.0 → sdev-0.6.2}/sdev/remote/server.py +0 -0
- {sdev-0.6.0 → sdev-0.6.2}/sdev/util.py +0 -0
- {sdev-0.6.0 → sdev-0.6.2}/sdev.egg-info/SOURCES.txt +0 -0
- {sdev-0.6.0 → sdev-0.6.2}/sdev.egg-info/dependency_links.txt +0 -0
- {sdev-0.6.0 → sdev-0.6.2}/sdev.egg-info/entry_points.txt +0 -0
- {sdev-0.6.0 → sdev-0.6.2}/sdev.egg-info/requires.txt +0 -0
- {sdev-0.6.0 → sdev-0.6.2}/sdev.egg-info/top_level.txt +0 -0
- {sdev-0.6.0 → sdev-0.6.2}/setup.cfg +0 -0
|
@@ -187,6 +187,23 @@ class SerialCore:
|
|
|
187
187
|
self._max_lines_per_prompt = 4
|
|
188
188
|
# 仅串口与缓冲区逻辑,不包含任何日志/显示状态
|
|
189
189
|
|
|
190
|
+
# --- 轻量级日志接口:供上层 Demoboard.check_alive 使用,默认静默 ---
|
|
191
|
+
|
|
192
|
+
def _log(self, level: str, message: str) -> None:
|
|
193
|
+
"""
|
|
194
|
+
占位日志接口:目前串口核心层不做实际日志记录,仅为上层提供统一调用点。
|
|
195
|
+
"""
|
|
196
|
+
return
|
|
197
|
+
|
|
198
|
+
def error(self, message: str) -> None:
|
|
199
|
+
self._log("error", message)
|
|
200
|
+
|
|
201
|
+
def warning(self, message: str) -> None:
|
|
202
|
+
self._log("warning", message)
|
|
203
|
+
|
|
204
|
+
def success(self, message: str) -> None:
|
|
205
|
+
self._log("success", message)
|
|
206
|
+
|
|
190
207
|
# --- 连接与资源管理 ---
|
|
191
208
|
|
|
192
209
|
def _serial_reader(self) -> None:
|
|
@@ -280,7 +280,7 @@ def _get_combined_demoboard_list_silent(
|
|
|
280
280
|
remote_hosts_override: Optional[list] = None,
|
|
281
281
|
) -> list[dict[str, Any]]:
|
|
282
282
|
"""
|
|
283
|
-
静默获取「本地 + 远程」combined 列表并填充 device
|
|
283
|
+
静默获取「本地 + 远程」combined 列表并填充 device(保持原始大小写),不输出任何日志。
|
|
284
284
|
供 activate 按 device 模糊匹配时使用。实现复用 sdev.remote.board_list。
|
|
285
285
|
"""
|
|
286
286
|
from ..remote.board_list import get_combined_demoboard_list_silent as _get_combined
|
|
@@ -380,9 +380,23 @@ def cmd_shell(args: argparse.Namespace) -> int:
|
|
|
380
380
|
prefix = _format_shell_prefix(host, port, baudrate)
|
|
381
381
|
print(f"{_CYAN}{prefix}{_RESET}")
|
|
382
382
|
|
|
383
|
+
# 若未显式指定 --timeout,则默认等待 60 秒,避免长命令过早被认为超时。
|
|
384
|
+
effective_timeout: Optional[float] = args.timeout if args.timeout is not None else 60.0
|
|
385
|
+
|
|
383
386
|
with Demoboard(port, baudrate, host=host) as board:
|
|
384
387
|
try:
|
|
385
|
-
_ = board.execute_command(args.command, flag=args.flag, timeout=
|
|
388
|
+
_ = board.execute_command(args.command, flag=args.flag, timeout=effective_timeout)
|
|
389
|
+
except KeyboardInterrupt:
|
|
390
|
+
# 将本地 Ctrl-C 映射为对板子的真实 Ctrl-C 中断,
|
|
391
|
+
# 然后通过 execute_command(None, ...) 等待提示符,尽量让远端命令完整收尾。
|
|
392
|
+
try:
|
|
393
|
+
board.send_interrupt()
|
|
394
|
+
# 不再发送新命令,仅等待当前提示符出现作为“收尾”信号。
|
|
395
|
+
_ = board.execute_command(None, flag=args.flag, timeout=effective_timeout)
|
|
396
|
+
except Exception:
|
|
397
|
+
pass
|
|
398
|
+
print() # 保证光标回到新行
|
|
399
|
+
return 130 # 约定:被 Ctrl-C 中断
|
|
386
400
|
except TimeoutError as e:
|
|
387
401
|
print(e, file=sys.stderr)
|
|
388
402
|
return 1
|
|
@@ -616,7 +630,7 @@ def cmd_demoboard_list(args: argparse.Namespace) -> int:
|
|
|
616
630
|
print(f"{_YELLOW}[INFO]{_RESET} 未发现任何 demoboard。")
|
|
617
631
|
return 0
|
|
618
632
|
|
|
619
|
-
# 对可用板子逐个获取 device
|
|
633
|
+
# 对可用板子逐个获取 device(串行,避免持锁冲突),保留原始大小写
|
|
620
634
|
device_timeout = getattr(args, "timeout", 2.0)
|
|
621
635
|
for r in combined:
|
|
622
636
|
if not r.get("available"):
|
|
@@ -633,7 +647,7 @@ def cmd_demoboard_list(args: argparse.Namespace) -> int:
|
|
|
633
647
|
board = Demoboard(port_raw, baud)
|
|
634
648
|
board.connect()
|
|
635
649
|
try:
|
|
636
|
-
r["device"] =
|
|
650
|
+
r["device"] = board.check_model_type(timeout=device_timeout) or ""
|
|
637
651
|
finally:
|
|
638
652
|
board.disconnect()
|
|
639
653
|
except Exception:
|
|
@@ -107,9 +107,20 @@ class Demoboard:
|
|
|
107
107
|
|
|
108
108
|
# --- 对外 API ---
|
|
109
109
|
|
|
110
|
+
def send_interrupt(self) -> None:
|
|
111
|
+
"""
|
|
112
|
+
将一次「中断」请求转换为对板子的 Ctrl-C(^C)发送。
|
|
113
|
+
供 CLI 在捕获本地 KeyboardInterrupt 时调用,尽量让远端 shell 也一起中断当前前台命令。
|
|
114
|
+
"""
|
|
115
|
+
try:
|
|
116
|
+
self._core.send(CTRL_C)
|
|
117
|
+
except Exception:
|
|
118
|
+
# 中断本身是“尽力而为”,失败时不再向外抛异常,避免干扰宿主进程退出路径。
|
|
119
|
+
return
|
|
120
|
+
|
|
110
121
|
def execute_command(
|
|
111
122
|
self,
|
|
112
|
-
cmd: str,
|
|
123
|
+
cmd: Optional[str],
|
|
113
124
|
*,
|
|
114
125
|
flag: str = " #",
|
|
115
126
|
timeout: Optional[float] = None,
|
|
@@ -118,6 +129,8 @@ class Demoboard:
|
|
|
118
129
|
) -> Union[List[str], Generator[str, None, None]]:
|
|
119
130
|
"""
|
|
120
131
|
在板子上执行一条命令并等待提示符出现:
|
|
132
|
+
- cmd 为非 None 时:发送该命令并等待其回显 + 提示符;
|
|
133
|
+
- cmd 为 None 时:不发送新命令,仅等待当前提示符(适合 Ctrl-C 之后“收尾”等待)。
|
|
121
134
|
- 默认开启 display:边收数据边在宿主终端高亮回显(语义参考旧版 shell);
|
|
122
135
|
- stream=False:收集所有行并返回 list;
|
|
123
136
|
- stream=True:返回一个逐行生成原始输出的 generator。
|
|
@@ -174,9 +174,7 @@ def get_combined_demoboard_list_silent(
|
|
|
174
174
|
board = Demoboard(port_raw, baud)
|
|
175
175
|
board.connect()
|
|
176
176
|
try:
|
|
177
|
-
r["device"] = (
|
|
178
|
-
board.check_model_type(timeout=device_timeout) or ""
|
|
179
|
-
).lower()
|
|
177
|
+
r["device"] = board.check_model_type(timeout=device_timeout) or ""
|
|
180
178
|
finally:
|
|
181
179
|
board.disconnect()
|
|
182
180
|
except Exception:
|
|
@@ -45,6 +45,23 @@ class RemoteSerialCore:
|
|
|
45
45
|
self._scan_timeout = 0.1
|
|
46
46
|
self._max_lines_per_prompt = 4
|
|
47
47
|
|
|
48
|
+
# --- 轻量级日志接口:供上层 Demoboard.check_alive 使用,默认静默 ---
|
|
49
|
+
|
|
50
|
+
def _log(self, level: str, message: str) -> None:
|
|
51
|
+
"""
|
|
52
|
+
占位日志接口:目前远程串口核心层不做实际日志记录,仅为上层提供统一调用点。
|
|
53
|
+
"""
|
|
54
|
+
return
|
|
55
|
+
|
|
56
|
+
def error(self, message: str) -> None:
|
|
57
|
+
self._log("error", message)
|
|
58
|
+
|
|
59
|
+
def warning(self, message: str) -> None:
|
|
60
|
+
self._log("warning", message)
|
|
61
|
+
|
|
62
|
+
def success(self, message: str) -> None:
|
|
63
|
+
self._log("success", message)
|
|
64
|
+
|
|
48
65
|
# --- 底层 TCP 收发 ---
|
|
49
66
|
|
|
50
67
|
def _read_loop(self) -> None:
|
|
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
|