sdev 0.7.11__tar.gz → 0.7.12__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.7.11/sdev.egg-info → sdev-0.7.12}/PKG-INFO +1 -1
- {sdev-0.7.11 → sdev-0.7.12}/pyproject.toml +1 -1
- {sdev-0.7.11 → sdev-0.7.12}/sdev/cli/__init__.py +87 -87
- {sdev-0.7.11 → sdev-0.7.12/sdev.egg-info}/PKG-INFO +1 -1
- {sdev-0.7.11 → sdev-0.7.12}/setup.py +1 -1
- {sdev-0.7.11 → sdev-0.7.12}/LICENSE +0 -0
- {sdev-0.7.11 → sdev-0.7.12}/MANIFEST.in +0 -0
- {sdev-0.7.11 → sdev-0.7.12}/README.md +0 -0
- {sdev-0.7.11 → sdev-0.7.12}/sdev/__init__.py +0 -0
- {sdev-0.7.11 → sdev-0.7.12}/sdev/cli/__main__.py +0 -0
- {sdev-0.7.11 → sdev-0.7.12}/sdev/deprecated/demoboard.py +0 -0
- {sdev-0.7.11 → sdev-0.7.12}/sdev/modules/__init__.py +0 -0
- {sdev-0.7.11 → sdev-0.7.12}/sdev/modules/mcp_server.py +0 -0
- {sdev-0.7.11 → sdev-0.7.12}/sdev/modules/serial_notebook.py +0 -0
- {sdev-0.7.11 → sdev-0.7.12}/sdev/modules/serial_rw.py +0 -0
- {sdev-0.7.11 → sdev-0.7.12}/sdev/modules/serial_rw_server.py +0 -0
- {sdev-0.7.11 → sdev-0.7.12}/sdev.egg-info/SOURCES.txt +0 -0
- {sdev-0.7.11 → sdev-0.7.12}/sdev.egg-info/dependency_links.txt +0 -0
- {sdev-0.7.11 → sdev-0.7.12}/sdev.egg-info/entry_points.txt +0 -0
- {sdev-0.7.11 → sdev-0.7.12}/sdev.egg-info/requires.txt +0 -0
- {sdev-0.7.11 → sdev-0.7.12}/sdev.egg-info/top_level.txt +0 -0
- {sdev-0.7.11 → sdev-0.7.12}/setup.cfg +0 -0
|
@@ -493,97 +493,97 @@ def _handle_list(args: argparse.Namespace) -> int:
|
|
|
493
493
|
scan_local = scope != "remote"
|
|
494
494
|
scan_remote = scope != "local"
|
|
495
495
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
try:
|
|
511
|
-
futs = {ex.submit(_check_one, p): p for p in ports}
|
|
512
|
-
if fast:
|
|
513
|
-
for fut in as_completed(futs):
|
|
514
|
-
port, r = fut.result()
|
|
515
|
-
results.append((port, r))
|
|
516
|
-
if r.get("available"):
|
|
517
|
-
fast_exit = True
|
|
518
|
-
alive_ports = [port]
|
|
519
|
-
break
|
|
520
|
-
else:
|
|
521
|
-
for fut in as_completed(futs):
|
|
522
|
-
results.append(fut.result())
|
|
523
|
-
results.sort(key=lambda x: x[0])
|
|
524
|
-
for port, r in results:
|
|
525
|
-
if r.get("available"):
|
|
526
|
-
alive_ports.append(port)
|
|
527
|
-
finally:
|
|
528
|
-
ex.shutdown(wait=not fast_exit)
|
|
529
|
-
|
|
530
|
-
def _model_one(port: str) -> Tuple[str, str]:
|
|
496
|
+
# 本地与远程扫描分别封装为任务,由 spinner 展示进度。
|
|
497
|
+
def _scan_local_task(ports: List[str]) -> List[Dict[str, Any]]:
|
|
498
|
+
entries: List[Dict[str, Any]] = []
|
|
499
|
+
if not ports:
|
|
500
|
+
return entries
|
|
501
|
+
|
|
502
|
+
def _check_one(port: str) -> Tuple[str, Dict[str, Any]]:
|
|
503
|
+
r = check_port_alive_nonblock(port, baudrate=115200, timeout=1.5)
|
|
504
|
+
return (port, r)
|
|
505
|
+
|
|
506
|
+
alive_ports: List[str] = []
|
|
507
|
+
results: List[Tuple[str, Dict[str, Any]]] = []
|
|
508
|
+
fast_exit = False
|
|
509
|
+
ex = ThreadPoolExecutor(max_workers=max(len(ports), 1))
|
|
531
510
|
try:
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
return entries
|
|
553
|
-
|
|
554
|
-
def _scan_remote_task() -> List[Dict[str, Any]]:
|
|
555
|
-
entries: List[Dict[str, Any]] = []
|
|
556
|
-
hosts = get_remote_hosts()
|
|
557
|
-
# print(f"[debug] remote hosts found by discovery: {hosts}")
|
|
558
|
-
if not hosts:
|
|
559
|
-
return entries
|
|
560
|
-
for host, service_port in hosts:
|
|
561
|
-
# print(f"[debug] fetching boards from {host}:{service_port}...")
|
|
562
|
-
boards = fetch_boards_from_host(host, service_port, timeout=10.0)
|
|
563
|
-
# print(f"[debug] host {host} returned {len(boards)} boards")
|
|
564
|
-
for b in boards:
|
|
565
|
-
if not b.get("available"):
|
|
566
|
-
continue
|
|
567
|
-
serial_dev = (b.get("device") or b.get("port") or "").strip()
|
|
568
|
-
if not serial_dev:
|
|
569
|
-
continue
|
|
570
|
-
baud = int(b.get("baudrate") or 115200)
|
|
571
|
-
device_type = "unknown"
|
|
511
|
+
futs = {ex.submit(_check_one, p): p for p in ports}
|
|
512
|
+
if fast:
|
|
513
|
+
for fut in as_completed(futs):
|
|
514
|
+
port, r = fut.result()
|
|
515
|
+
results.append((port, r))
|
|
516
|
+
if r.get("available"):
|
|
517
|
+
fast_exit = True
|
|
518
|
+
alive_ports = [port]
|
|
519
|
+
break
|
|
520
|
+
else:
|
|
521
|
+
for fut in as_completed(futs):
|
|
522
|
+
results.append(fut.result())
|
|
523
|
+
results.sort(key=lambda x: x[0])
|
|
524
|
+
for port, r in results:
|
|
525
|
+
if r.get("available"):
|
|
526
|
+
alive_ports.append(port)
|
|
527
|
+
finally:
|
|
528
|
+
ex.shutdown(wait=not fast_exit)
|
|
529
|
+
|
|
530
|
+
def _model_one(port: str) -> Tuple[str, str]:
|
|
572
531
|
try:
|
|
573
|
-
with SerialNotebook(device=
|
|
574
|
-
|
|
532
|
+
with SerialNotebook(device=port, baudrate=115200) as nb:
|
|
533
|
+
return (port, nb.get_model_type(timeout=2.0, verbose=False) or "unknown")
|
|
575
534
|
except Exception as e:
|
|
576
|
-
|
|
577
|
-
|
|
535
|
+
return (port, f"error: {e}")
|
|
536
|
+
|
|
537
|
+
if alive_ports:
|
|
538
|
+
model_results: List[Tuple[str, str]] = []
|
|
539
|
+
with ThreadPoolExecutor(max_workers=max(len(alive_ports), 1)) as ex2:
|
|
540
|
+
futs = {ex2.submit(_model_one, p): p for p in alive_ports}
|
|
541
|
+
for fut in as_completed(futs):
|
|
542
|
+
model_results.append(fut.result())
|
|
543
|
+
model_results.sort(key=lambda x: x[0])
|
|
544
|
+
for port, device_type in model_results:
|
|
545
|
+
entries.append({
|
|
546
|
+
"host": "localhost",
|
|
547
|
+
"device": port,
|
|
548
|
+
"device_id": _device_id("localhost", port),
|
|
549
|
+
"device_type": device_type if not device_type.startswith("error:") else "unknown",
|
|
550
|
+
"last_update": now,
|
|
551
|
+
})
|
|
552
|
+
return entries
|
|
553
|
+
|
|
554
|
+
def _scan_remote_task() -> List[Dict[str, Any]]:
|
|
555
|
+
entries: List[Dict[str, Any]] = []
|
|
556
|
+
hosts = get_remote_hosts()
|
|
557
|
+
# print(f"[debug] remote hosts found by discovery: {hosts}")
|
|
558
|
+
if not hosts:
|
|
559
|
+
return entries
|
|
560
|
+
for host, service_port in hosts:
|
|
561
|
+
# print(f"[debug] fetching boards from {host}:{service_port}...")
|
|
562
|
+
boards = fetch_boards_from_host(host, service_port, timeout=10.0)
|
|
563
|
+
# print(f"[debug] host {host} returned {len(boards)} boards")
|
|
564
|
+
for b in boards:
|
|
565
|
+
if not b.get("available"):
|
|
566
|
+
continue
|
|
567
|
+
serial_dev = (b.get("device") or b.get("port") or "").strip()
|
|
568
|
+
if not serial_dev:
|
|
569
|
+
continue
|
|
570
|
+
baud = int(b.get("baudrate") or 115200)
|
|
578
571
|
device_type = "unknown"
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
572
|
+
try:
|
|
573
|
+
with SerialNotebook(device=serial_dev, baudrate=baud, host=host, port=service_port) as nb:
|
|
574
|
+
device_type = nb.get_model_type(timeout=3.0, verbose=False) or "unknown"
|
|
575
|
+
except Exception as e:
|
|
576
|
+
# 如果报错,说明连接或者握手阶段就出问题了
|
|
577
|
+
# print(f"[debug] failed to get model type from {host}:{serial_dev}: {e}")
|
|
578
|
+
device_type = "unknown"
|
|
579
|
+
entries.append({
|
|
580
|
+
"host": host,
|
|
581
|
+
"device": serial_dev,
|
|
582
|
+
"device_id": _device_id(host, serial_dev),
|
|
583
|
+
"device_type": device_type if not device_type.startswith("error:") else "unknown",
|
|
584
|
+
"last_update": now,
|
|
585
|
+
})
|
|
586
|
+
return entries
|
|
587
587
|
|
|
588
588
|
specs: List[Tuple[str, Any]] = []
|
|
589
589
|
local_entries: List[Dict[str, Any]] = []
|
|
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
|