Port Scanner
controller.infrastructure.communication.port_scanner
串口扫描器 - Infrastructure层 负责扫描可用的串口端口
PortScanner
串口端口扫描器。
负责扫描可用的串口端口,包含真实串口和虚拟串口。
scan_ports
staticmethod
scan_ports() -> List[str]
扫描可用的串口端口(包含真实串口和虚拟串口)。
返回:
| 类型 | 描述 |
|---|---|
List[str]
|
List[str]: 可用端口名称列表。 |
源代码位于: src/controller/controller/infrastructure/communication/port_scanner.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
get_port_info
staticmethod
get_port_info(port_name: str) -> Optional[Dict[str, str]]
获取指定端口的详细信息(支持真实串口和虚拟串口)。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
port_name
|
str
|
端口名称。 |
必需 |
返回:
| 类型 | 描述 |
|---|---|
Optional[Dict[str, str]]
|
Optional[Dict[str, str]]: 端口信息字典,包含 description 和 hwid。如果端口不可用则返回 None。 |
源代码位于: src/controller/controller/infrastructure/communication/port_scanner.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
get_all_port_info
staticmethod
get_all_port_info() -> List[Dict[str, str]]
获取所有可用端口的详细信息(包含真实串口和虚拟串口)。
返回:
| 类型 | 描述 |
|---|---|
List[Dict[str, str]]
|
List[Dict[str, str]]: 所有端口信息列表。 |
源代码位于: src/controller/controller/infrastructure/communication/port_scanner.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |