PySide6.QtSerialPort.QSerialPortInfo¶
- class QSerialPortInfo¶
提供有关现有串行端口的信息。更多…
概要¶
方法¶
def
__init__()def
description()def
isNull()def
manufacturer()def
portName()def
serialNumber()def
swap()def
systemLocation()
静态函数¶
def
availablePorts()
注意
本文档可能包含从C++自动翻译到Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译问题,您也可以通过在我们的https:/bugreports.qt.io/projects/PYSIDE上创建工单来告知我们。
详细描述¶
警告
本节包含从C++自动翻译到Python的代码片段,可能包含错误。
使用静态函数
availablePorts()生成一个QSerialPortInfo对象列表。列表中的每个QSerialPortInfo对象代表一个串行端口,并且可以查询port name、system location、description、manufacturer以及其他一些硬件参数。QSerialPortInfo类也可以作为QSerialPort类的setPort()方法的输入参数。示例用法¶
示例代码枚举所有可用的串行端口并将其参数打印到控制台:
serialPortInfos = QSerialPortInfo.availablePorts() for portInfo in serialPortInfos: print("\n") << "Port:" << portInfo.portName() << "\n" << "Location:" << portInfo.systemLocation() << "\n" << "Description:" << portInfo.description() << "\n" << "Manufacturer:" << portInfo.manufacturer() << "\n" << "Serial number:" << portInfo.serialNumber() << "\n" << "Vendor Identifier:" << (portInfo.hasVendorIdentifier() ? QByteArray.number(portInfo.vendorIdentifier(), 16) : QByteArray()) << "\n" << "Product Identifier:" << (portInfo.hasProductIdentifier() ? QByteArray.number(portInfo.productIdentifier(), 16) super().__init__())另请参阅
- __init__()¶
构造一个空的
QSerialPortInfo对象。另请参阅
- __init__(port)
- Parameters:
端口 –
QSerialPort
从串行
port构造一个QSerialPortInfo对象。- __init__(other)
- Parameters:
其他 –
QSerialPortInfo
构造
other的副本。- __init__(name)
- Parameters:
name – str
从串口
name构造一个QSerialPortInfo对象。此构造函数根据端口名称
name在可用的串行端口中找到相关的串行端口,并为该端口构建串行端口信息实例。- static availablePorts()¶
- Return type:
返回系统上可用的串行端口列表。
- description()¶
- Return type:
字符串
返回串口的描述字符串(如果可用);否则返回空字符串。
- hasProductIdentifier()¶
- Return type:
布尔
如果存在有效的
16-bit产品编号,则返回true;否则返回false。- hasVendorIdentifier()¶
- Return type:
布尔
如果存在有效的
16-bit供应商编号,则返回true;否则返回false。- isNull()¶
- Return type:
布尔
返回此
QSerialPortInfo对象是否包含串口定义。- manufacturer()¶
- Return type:
字符串
返回串行端口的制造商字符串(如果可用);否则返回空字符串。
- portName()¶
- Return type:
字符串
返回串口的名称。
另请参阅
- productIdentifier()¶
- Return type:
整数
返回串行端口的16位产品编号(如果可用);否则返回零。
- serialNumber()¶
- Return type:
字符串
返回串行端口的序列号字符串(如果可用);否则返回空字符串。
- static standardBaudRates()¶
- Return type:
.qint32的列表
返回目标平台支持的可用标准波特率列表。
- swap(other)¶
- Parameters:
其他 –
QSerialPortInfo
将
QSerialPortInfoother与此QSerialPortInfo交换。此操作非常快速且永远不会失败。- systemLocation()¶
- Return type:
字符串
返回串口的系统位置。
另请参阅
- vendorIdentifier()¶
- Return type:
整数
返回串行端口的16位供应商编号(如果可用);否则返回零。