1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00
LibQQt/examples/qqtclientexample/qqtuserprotocol3.cpp
tianduanrui 444a97e6c9 move example to QQtExample.pro
QQtExample工程依赖于QQt工程
2018-04-23 18:29:20 +08:00

34 lines
1017 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}