1 Star 0 Fork 1

robin6974/QSweepTerminal

forked from FiberCOMM/QSweepTerminal 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
serialrtx.py 1.52 KB
一键复制 编辑 原始数据 按行查看 历史
FiberCOMM 提交于 2020-01-29 21:18 . 1.初次提交
from PyQt5.QtSerialPort import QSerialPort
from PyQt5.QtCore import QIODevice
class SerialRtx(object):
def __init__(self, parent=None):
self._bOpened = False
self._serialPort = QSerialPort()
self._reseStatics()
def openPort(self, port, baud):
self._serialPort.setPortName(port)
self._bOpened = self._serialPort.open(QIODevice.ReadWrite)
if self._bOpened:
self._serialPort.setBaudRate(baud)
self._serialPort.setDataBits(QSerialPort.Data8)
self._serialPort.setParity(QSerialPort.NoParity)
self._serialPort.setStopBits(QSerialPort.OneStop)
self._serialPort.setReadBufferSize(4096)
return True
else:
return False
def closePort(self):
self._serialPort.close()
self._bOpened = False
self._reseStatics()
def send(self, data, len):
self._serialPort.writeData(data)
self._sendBytesNum += len
def bindRecvSignal(self, recvProcess):
self._serialPort.readyRead.connect(recvProcess)
def recv(self):
# len = self._serialPort.bytesAvailable()
data = self._serialPort.readAll()
data = bytes(data)
self._recvBytesNum += len(data)
return data
def isOpened(self):
return self._bOpened
def _reseStatics(self):
self._recvBytesNum = 0
self._sendBytesNum = 0
def recvBytesNum(self):
return self._recvBytesNum
def sendBytesNum(self):
return self._sendBytesNum
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/robin6974/QSweepTerminal.git
git@gitee.com:robin6974/QSweepTerminal.git
robin6974
QSweepTerminal
QSweepTerminal
master

搜索帮助