1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00
LibQQt/examples/qqtclientexample/qqtuserprotocol3.cpp

34 lines
1017 B
C++
Raw Normal View History

2018-04-19 23:03:39 +08:00
#include "qqtuserprotocol3.h"
QDebug& operator << ( QDebug& dbg, const QQtUserMessage3& msg )
{
//这里打印一下,报文里面到底有什么信息,
//一般到这里的都是被解析好的message。
dbg.nospace() << "{" << hex << msg.size() << "}";
return dbg.space();
}
QQtUserProtocol3* QQtUserConnectionInstance3 ( QObject* parent )
{
static QQtUserProtocol3* p0 = NULL;
static QQtSerialPort* s0 = NULL;
if ( !p0 && !s0 )
{
p0 = new QQtUserProtocol3 ( parent );
s0 = new QQtSerialPort ( parent );
s0->setPortName ( "/dev/ttyUSB0" );
s0->setBaudRate ( QQtSerialPort::Baud57600 );
s0->setDataBits ( QQtSerialPort::Data8 );
s0->setParity ( QQtSerialPort::NoParity );
s0->setStopBits ( QQtSerialPort::OneStop );
s0->setFlowControl ( QQtSerialPort::NoFlowControl );
s0->open ( QQtSerialPort::ReadWrite );
s0->installProtocol ( p0 );
}
return p0;
}