i am using in Qt Creator 3.5.1 (opensource) Based on Qt 5.5.1 (GCC 4.9.1 20140922 (Red Hat 4.9.1-10), 32 bit). the problem is while build the project controller pc the error occurred "is not a member of 'QSerialPort' connect(serial, &QSerialPort::errorOccurred, this . ^In Serialconnector.cpp .
kindly resolve it .
*Serialconnector.cpp . * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain this list of conditions * and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE SOFTWARE PROVIDER OR DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */#include "serialconnector.h"#include "sdn-serial-send.h"#include "sdn-reliability.h"#include <QTcpSocket>#include <QSerialPort>#include <iostream>SerialConnector::SerialConnector(QObject *parent) : QObject(parent) { connect(&serializer, &Serializer::new_packet_available, [this](QByteArray packet){ if(packet.size() == sizeof(sdn_serial_packet_t)) { decodeSerialPacket(SerialConnector::castToPacketType(packet)); } });}SerialConnector::SerialConnector(const QString& serial_port, QObject *parent) : SerialConnector(parent) { initConnection(serial_port);}SerialConnector::SerialConnector(const QString &ip, quint16 port, QObject *parent) : SerialConnector(parent) { initConnection(ip, port);}SerialConnector::~SerialConnector() { if(device) { delete device; }}bool SerialConnector::ready() { return isReady;}void SerialConnector::requestNodeId() { if(ready()) { sdn_serial_packet_t packet; memset(&packet, 0, sizeof(sdn_serial_packet_t)); packet.header.msg_type = SDN_SERIAL_MSG_TYPE_ID_REQUEST; packet.header.payload_len = 0; QByteArray rawBytes = serializer.packetizer(&packet); device->write(rawBytes); }}void SerialConnector::sendGenericPacket(sdn_serial_packet_t *packet) { if(ready()) { QByteArray rawBytes = serializer.packetizer(packet); // unsigned int i; // for (i=0; i < rawBytes.length(); i++) { // printf("%02X ",((unsigned char*)rawBytes.constData())[i]); // } // printf("\n"); qint64 ret = device->write(rawBytes); if (ret == -1) { std::cout << "ERROR on device->write"<< std::endl; //} else { // std::cout << "device->write "<< ret << " bytes"<< std::endl; } }}void SerialConnector::initConnection(const QString& serial_port) { if(device) { device->close(); delete device; } QSerialPort *serial = new QSerialPort(serial_port); serial->setBaudRate(QSerialPort::Baud115200); serial->setDataBits(QSerialPort::Data8); serial->setParity(QSerialPort::NoParity); serial->setStopBits(QSerialPort::OneStop); connect(serial, &QSerialPort::errorOccurred, [this]() { isReady = false; emit state_changed_stringfy("Serial error ocurred."); }); isReady = serial->open(QIODevice::ReadWrite); device = serial; if (isReady) { emit state_changed_stringfy("Serial connected"); } connect(device, &QIODevice::readyRead, this, [this]() { data_received(); });}void SerialConnector::initConnection(const QString &ip, quint16 port) { if(device) { delete device; } QTcpSocket *socket = new QTcpSocket(); connect(socket, &QTcpSocket::stateChanged, [this](QAbstractSocket::SocketState state) { QString stateString = QString(state == QAbstractSocket::UnconnectedState ? "UnconnectedState" : state == QAbstractSocket::HostLookupState ? "HostLookupState" : state == QAbstractSocket::ConnectingState ? "ConnectingState" : state == QAbstractSocket::ConnectedState ? "ConnectedState" : state == QAbstractSocket::BoundState ? "BoundState" : state == QAbstractSocket::ListeningState ? "ListeningState" : state == QAbstractSocket::ClosingState ? "ClosingState" : ""); if(state == QAbstractSocket::ConnectedState) { isReady = true; } else { isReady = false; } emit state_changed_stringfy(stateString); }); socket->connectToHost(ip, port); device = socket; connect(device, &QIODevice::readyRead, this, [this]() { data_received(); });}void SerialConnector::data_received() { if(device) { while(device->bytesAvailable() > 0) { char max_data[512]; int len = device->read(max_data, 512); serializer.processBytes(max_data, len); } }}void SerialConnector::decodeSerialPacket(sdn_serial_packet_t *packet) { //qDebug() << "[MainWindow::decodePacket] New Packet"; if(packet->header.msg_type == SDN_SERIAL_MSG_TYPE_PRINT) { QByteArray string((char*)packet->payload, packet->header.payload_len);// QString text = QString("ID %1: %2").arg((int)packet->header.node_addr.u8[1]).arg(QString(string).remove("\n")); QString text = QString("%1").arg(QString(string)); emit printfString(text); } else if(packet->header.msg_type == SDN_SERIAL_MSG_TYPE_ID_REQUEST){ emit nodeIdReceived((sdnaddr_t *)packet->header.node_addr.u8); } else if(packet->header.msg_type == SDN_SERIAL_MSG_TYPE_RADIO){ emit defaultPacket(QByteArray((char*)packet, sizeof(sdn_serial_packet_t))); } else if(packet->header.msg_type == SDN_SERIAL_MSG_TYPE_RADIO_ACK){ emit ackReceived(SERIAL_TX_ACK); } else if(packet->header.msg_type == SDN_SERIAL_MSG_TYPE_RADIO_NACK){ emit nackReceived(SERIAL_TX_NACK); } else if(packet->header.msg_type == SDN_SERIAL_MSG_TYPE_TIMER){ sdn_reliability_timer_event(); } else if(packet->header.msg_type != SDN_SERIAL_MSG_TYPE_EMPTY){ emit customPacket(QByteArray((char*)packet, sizeof(sdn_serial_packet_t))); }}void SerialConnector::close() { device->close();}
* serialconnector.h/* * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain this list of conditions * and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE SOFTWARE PROVIDER OR DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */#ifndef SERIALCONNECTOR_H#define SERIALCONNECTOR_H#include <QObject>#include <QIODevice>#include "serializer.h"class SerialConnector : public QObject{ Q_OBJECTpublic: explicit SerialConnector(QObject *parent = 0); SerialConnector(const QString& serial_port, QObject *parent = 0); SerialConnector(const QString& ip, quint16 port, QObject* parent = 0); ~SerialConnector(); void initConnection(const QString &ip, quint16 port); void initConnection(const QString& serial_port); void close(); bool ready(); void requestNodeId(); static sdn_serial_packet_t* castToPacketType(QByteArray &packet) { return (sdn_serial_packet_t*)packet.data(); } void sendGenericPacket(sdn_serial_packet_t *packet);signals: void state_changed_stringfy(QString state); void nodeIdReceived(sdnaddr_t *nodeId); void printfString(QString string); void defaultPacket(QByteArray packet); void customPacket(QByteArray packet); void ackReceived(int status); void nackReceived(int status);protected: void decodeSerialPacket(sdn_serial_packet_t *packet); void data_received(); void decodePacket(sdn_serial_packet_t *packet);private: Serializer serializer; QIODevice *device = nullptr; bool isReady = false;};#endif // SERIALCONNECTOR_H
* controller-pc.proQT += core gui network serialportgreaterThan(QT_MAJOR_VERSION, 4): QT += widgetsTARGET = "controller-pc"TEMPLATE = app# The following define makes your compiler emit warnings if you use# any feature of Qt which as been marked as deprecated (the exact warnings# depend on your compiler). Please consult the documentation of the# deprecated API in order to know how to port your code away from it.DEFINES += QT_DEPRECATED_WARNINGSDEFINES += SDN_CONTROLLER_PCDEFINES += DEBUG_SDNDEFINES += SDNADDR_SIZE=2DEFINES += DIGRAPH_VERTICE_ID_SIZE=SDNADDR_SIZEDEFINES += SDN_MAX_PACKET_SIZE=115DEFINES += SDN_SEND_QUEUE_SIZE=100DEFINES += SDN_RECV_QUEUE_SIZE=100DEFINES += SDN_CONF_METRIC=dummy_metric#dummy_metric | mamdani_fuzzy_model_metric# Defines when changes from route weight can be used in flow setup.DEFINES += SDN_ROUTE_SENSIBILITY=0.5DEFINES += SDN_CONF_TX_RELIABILITY=1DEFINES += SDN_NEIGHBORINFO_NEIGHBORS_TO_SRCDEFINES += SDN_NEIGHBORINFO_SRC_TO_NEIGHBORSDEFINES += SDN_SOURCE_ROUTED#DEFINES += SDN_INFORM_NEW_EDGE_SERIAL# routes sensibility related setingsDEFINES += WEIGHT_ETX=1.0DEFINES += WEIGHT_ENERGY=0.0#Management flag#DEFINES += MANAGEMENT# You can also make your code fail to compile if you use deprecated APIs.# In order to do so, uncomment the following line.# You can also select to disable deprecated APIs only up to a certain version of Qt.#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0#INCLUDEPATH+=../../include(controller-pc.pro.contiki)INCLUDEPATH+=$$CONTIKI/core/INCLUDEPATH+=../../sdn-common/INCLUDEPATH+=../INCLUDEPATH+=../digraph/SOURCES += main.cpp\ mainwindow.cpp \ serializer.cpp \ serialconnector.cpp \ ../../sdn-common/control-flow-table.c \ ../../sdn-common/data-flow-table.c \ ../../sdn-common/sdn-addr.c \ ../../sdn-common/sdn-debug.c \ ../../sdn-common/sdn-packetbuf.c \ ../../sdn-common/sdn-queue.c \ ../../sdn-common/sdn-send-packet.c \ ../../sdn-common/sdn-process-packets.c \ ../../sdn-common/sdn-unknown-route.c \ $$CONTIKI/core/lib/list.c \ ../digraph/digraph.c \ ../digraph/dummy-metric.c \ ../digraph/mamdani-fuzzy-model-metric.c \ ../digraph/dijkstra.c \ ../controller-core.c \ ../sdn-flow-table-cache.c \ ../sdn-serial-send.c \ ../sdn-process-packets-controller.c \ ../sdn-reliability.c \ mainwindow_wrapper.cppHEADERS += mainwindow.h \ serializer.h \ serialconnector.h \ ../../sdn-common/control-flow-table.h \ ../../sdn-common/data-flow-table.h \ ../../sdn-common/sdn-addr.h \ ../../sdn-common/sdn-constants.h \ ../../sdn-common/sdn-debug.h \ ../../sdn-common/sdn-packetbuf.h \ ../../sdn-common/sdn-protocol.h \ ../../sdn-common/sdn-queue.h \ ../../sdn-common/sdn-send-packet.h \ ../../sdn-common/sdn-process-packets.h \ ../../sdn-common/sdn-unknown-route.h \ ../../sdn-common/sdn-serial-packet.h \ $$CONTIKI/core/lib/list.h \ ../digraph/digraph.h \ ../digraph/dummy-metric.h \ ../digraph/mamdani-fuzzy-model-metric.h \ ../digraph/dijkstra.h \ ../digraph/sdn-metric.h \ ../controller-core.h \ ../sdn-flow-table-cache.h \ ../sdn-serial-send.h \ ../sdn-process-packets-controller.h \ ../sdn-reliability.h \ mainwindow_wrapper.hQMAKE_CXXFLAGS += -std=c++0xFORMS += mainwindow.uiDISTFILES += \ controller-pc.pro.contiki
general message:Could not find qmake configuration file default.Error while parsing file /home/user/contiki/it-sdn/controller-server/controller-pc/controller-pc.pro. Giving up.Warnings while parsing QML type information of /home/user/Qt/5.5/gcc/qml:<dump of /home/user/Qt/5.5/gcc/qml>:1:24: Reading only version 1.1 parts.<dump of /home/user/Qt/5.5/gcc/qml>:10:5: Expected only Component and ModuleApi object definitions.**Error** error: 'errorOccurred' is not a member of 'QSerialPort'connect(serial, &QSerialPort::errorOccurred, [this]() { ^home/user/contiki/it-sdn/controller-server/controller-pc/