- class QSerialPortInfo#
提供有关现有串行端口的详细信息。 更多…
简介#
方法#
def
__init__()def
description()def
isNull()def
manufacturer()def
portName()定义
swap()
静态函数#
注意
本文档可能包含自动从C++翻译到Python的代码片段。我们始终欢迎对片段翻译的贡献。如果您发现翻译存在问题,也可以通过在https:/bugreports.qt.io/projects/PYSIDE上创建工单的方式来告诉我们。
详细描述#
警告
本节包含自动从C++翻译到Python的代码片段,可能存在错误。
使用静态函数
availablePorts()生成一个包含QSerialPortInfo对象的列表。列表中的每个QSerialPortInfo对象代表一个串行端口,可以查询其端口名称、系统位置、描述、制造商和一些其他硬件参数。QSerialPortInfo类还可以用作setPort()方法中QSerialPort类的输入参数。示例用法#
示例代码将列举所有可用的串行端口,并将它们的参数打印到控制台。
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__(port)#
- 参数:
端口 –
QSerialPort
从串行
port构造一个QSerialPortInfo对象。- __init__(other)
- 参数:
other –
QSerialPortInfo
构造一个
other的副本。- __init__(name)
- 参数:
name – str
从串行端口
name构造一个QSerialPortInfo对象。此构造函数根据端口名称
name在可用端口中查找相关端口,并为此端口构造串行端口信息实例。- __init__()
构造一个空的
QSerialPortInfo对象。另请参阅
- static availablePorts()#
- 返回类型:
. QSerialPortInfo 列表
返回系统上可用的串行端口列表。
- description()#
- 返回类型:
str
如果可用,则返回串行端口的描述字符串;否则返回空字符串。
- hasProductIdentifier()#
- 返回类型:
bool
如果存在有效的
16-bit产品号码,则返回true;否则返回false。- hasVendorIdentifier()#
- 返回类型:
bool
如果存在有效的
16-bit生产商编号,则返回true;否则返回false。- isNull()#
- 返回类型:
bool
返回此
QSerialPortInfo对象是否包含串行端口定义。- manufacturer()#
- 返回类型:
str
如果存在,则返回串行端口的制造商字符串;否则返回空字符串。
- portName()#
- 返回类型:
str
返回串行端口的名称。
另请参阅
- productIdentifier()#
- 返回类型:
int
如果存在,则返回串行端口的 16-bit 产品编号;否则返回零。
- serialNumber()#
- 返回类型:
str
如果存在,则返回串行端口的序列号字符串;否则返回空字符串。
- static standardBaudRates()#
- 返回类型:
.qint32 列表
返回由目标平台支持的标准波特率列表。
- swap(other)#
- 参数:
other –
QSerialPortInfo
交换
QSerialPortInfo对象other与当前QSerialPortInfo对象。此操作速度非常快且永远不会失败。- systemLocation()#
- 返回类型:
str
返回串行端口的系统位置。
另请参阅
- vendorIdentifier()#
- 返回类型:
int
如果可用,返回串行端的16位供应商编号;否则返回零。