SerialLink::SerialLink(QString portname, int baudRate, bool hardwareFlowControl, bool parity, int dataBits, int stopBits) : port(0), portSettings(PortSettings()), portOpenMode(QIODevice::ReadWrite), portVendorId(0), portProductId(0), bitsSentTotal(0), bitsSentShortTerm(0), bitsSentCurrent(0), bitsSentMax(0), bitsReceivedTotal(0), bitsReceivedShortTerm(0), bitsReceivedCurrent(0), bitsReceivedMax(0), connectionStartTime(0), ports(new QVector<QString>()), waitingToReconnect(0), m_reconnectDelayMs(0), m_linkLossExpected(false), m_stopp(false), mode_port(false), countRetry(0), maxLength(0), rows(0), cols(0), firstRead(0) { portEnumerator = new QextSerialEnumerator(); portEnumerator->setUpNotifications(); QObject::connect(portEnumerator, SIGNAL(deviceDiscovered(const QextPortInfo &)), this, SLOT(deviceDiscovered(const QextPortInfo &))); QObject::connect(portEnumerator, SIGNAL(deviceRemoved(const QextPortInfo &)), this, SLOT(deviceRemoved(const QextPortInfo &))); getCurrentPorts(); // Setup settings this->porthandle = portname.trimmed(); if (!ports->contains(porthandle)) porthandle = ""; // Set unique ID and add link to the list of links this->id = getNextLinkId(); int par = parity ? (int)PAR_EVEN : (int)PAR_NONE; int fc = hardwareFlowControl ? (int)FLOW_HARDWARE : (int)FLOW_OFF; setBaudRate(baudRate); setFlowType(fc); setParityType(par); setDataBitsType(dataBits); setStopBitsType(stopBits); setTimeoutMillis(-1); // -1 means do not block on serial read/write. Do not use zero. setReconnectDelayMs(10); // default 10ms before reconnecting to M4, after detecting that COM port is back // Set the port name name = this->porthandle.length() ? this->porthandle : tr("Serial Link ") + QString::number(getId()); QObject::connect(this, SIGNAL(portError()), this, SLOT(disconnect())); }
XbeeLink::XbeeLink(QString portName, int baudRate) : m_xbeeCon(NULL), m_portName(NULL), m_portNameLength(0), m_baudRate(baudRate), m_connected(false), m_id(-1), m_addrHigh(0), m_addrLow(0) { /* setup the xbee */ this->setPortName(portName); //this->connect(); // Set unique ID and add link to the list of links this->m_id = getNextLinkId(); // set the Name this->m_name = tr("xbee link") + QString::number(this->m_id); emit nameChanged(this->m_name); }