当前位置:网站首页>QT -- 通讯协议
QT -- 通讯协议
2022-06-28 07:00:00 【wishfly】
1.封装下串口类QSerialPort的线程操作
(Qt)封装下串口类QSerialPort的线程操作_苏州-青蛙-CSDN博客_qserialport线程
2. QT 串口QSerialPort + 解决接收数据不完整问题
QT 串口QSerialPort + 解决接收数据不完整问题_Kelvin_Yan的专栏-CSDN博客_qt串口接收数据不完整
3. Calling QSerialPort methods from two different threads
class SerialThread : public QThread
{
Q_OBJECT
public:
QMutex quit;
SerialThread()
{
}
~SerialThread()
{
quit.lock();
wait();
}
void asyncWrite(QByteArray data)
{
QMutexLocker locker(&mutex);
buffer = data;
}
bool syncWrite(QByteArray &data)
{
QMutexLocker locker(&mutex);
serial->write(data);
if(serial->waitForReadyRead(1000))
{
data = serial->readAll();
return true;
}
return false;
}
private:
QMutex mutex;
QSerialPort * serial;
QByteArray buffer;
virtual void run()
{
mutex.lock();
QSerialPort port;
serial = &port;
port.setPortName("COM10");
port.open(QSerialPort::ReadWrite);
while (quit.tryLock()) {
quit.unlock();
if(!buffer.isEmpty())
{
serial->write(buffer);
buffer.clear();
if(serial->waitForReadyRead(1000))
{
emit onRead(serial->readAll());
}
else
emit onError();
}
mutex.unlock();
msleep(10);
mutex.lock();
}
}
signals:
void onRead(QByteArray data);
void onError();
};
5 串口 -- github - 实例
Search · QSerialPort Threading · GitHub
6 qtcreator未响应
删除~\AppData\Roaming\QtProject文件夹,
边栏推荐
- [digital statistics DP] counting problem
- Huawei cloud computing physical node cna installation tutorial
- 代码没写错,渲染页面不显示原因
- FPM tool installation
- 助力涨点 | YOLOv5结合Alpha-IoU
- Some habits of it veterans in the workplace
- 【C语言】详解 C 语言获取数组长度
- Pytorch RNN learning notes
- KMP string
- Introduction to Qualcomm platform WiFi -- Wi Fi display software
猜你喜欢

Techo Day 腾讯技术开放日,6月28日线上等你!

Freeswitch使用originate转dialplan

Introduction to browser tools: think sky browser, team work browser
![[online tutorial] official iptables tutorial -- learning notes 1](/img/b9/8f94caa46eb46dab581c713494f36d.png)
[online tutorial] official iptables tutorial -- learning notes 1

Eyebeam advanced settings

Batch import of pictures into WPS table by date

《微信小程序-基础篇》带你了解小程序中的生命周期(一)

全方位透析真实企业软件测试流程

选拔赛题目代码

Last 29 days
随机推荐
[online tutorial] official iptables tutorial -- learning notes 1
C language tutorial
Wechat applet paging function, pull-down refresh function, direct dry goods
Using interceptor and cache to complete interface anti brushing operation
Wechat applets - basics takes you to understand the life cycle of applets (I)
Interpretation of Blog
全方位透析真实企业软件测试流程
freeswitch设置最大呼叫时长
FPGA - 7 Series FPGA selectio -07- iserdese2 of advanced logic resources
小程序页面设置100%高度还是留白怎么办?
Servlet value passing JSP
CMAKE小知识
An important term in MySQL -- CRUD
JS of learning notes -- split(), replace(), join()
搭建你jmeter+jenkins+ant
Yesterday, I went to a large factory for an interview and asked me to do four arithmetic operations. Fortunately, I am smart enough
Singleton singleton mode
fpm工具安装
声网 VQA:将实时互动中未知的视频画质用户主观体验变可知
Trie string statistics