void QDmxE131Controler::readDatagram() { if(sender()) { QUdpSocket* socket = qobject_cast<QUdpSocket*>(sender()); if(socket) { while(socket->hasPendingDatagrams()) { QNetworkDatagram datagram = socket->receiveDatagram(); if(datagram.senderAddress().isInSubnet(_address, _entry.prefixLength())) { QByteArray rawData = datagram.data(); if(_packetizer->checkPacket(rawData)) { QByteArray dmx; quint32 u; _packetizer->fillDMXdata(rawData, dmx, u); u--; if(_listenedUniverse.contains(u)) emit hasDmx(u, dmx); } } } } } }
void RacomClient::onUdpSocketReadyRead() { if(status() != Status::Running) return; QUdpSocket *sock = udpSocket(); QNetworkDatagram dg = sock->receiveDatagram(); QByteArray data = dg.data(); qfInfo() << data.toHex(); // remove possible initial garbage int i = 0; for(i=0; i<data.size(); i++) if(data.at(i) == 0x02) break; data = data.mid(i); // remove possible multiple 0x02 for(i=1; i<data.size(); i++) if(data.at(i) != 0x02) break; data = data.mid(i-1); qfInfo() << "stripped data:" << data.toHex(); if(!m_siDriver) { m_siDriver = new siut::DeviceDriver(this); CardReader::CardReaderPlugin *plugin = cardReaderPlugin(); if(plugin) { connect(m_siDriver, &siut::DeviceDriver::messageReady, plugin, &CardReader::CardReaderPlugin::emitSiMessagereceived); } } m_siDriver->processSiPacket(data); }
void RacomClient::onRawSIDataUdpSocketReadyRead() { if(status() != Status::Running) return; #if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)) QUdpSocket *sock = rawDataUdpSocket(); QNetworkDatagram dg = sock->receiveDatagram(); QByteArray data = dg.data(); qfInfo() << data.toHex(); // remove possible initial garbage int i = 0; for(i=0; i<data.size(); i++) if(data.at(i) == 0x02) break; data = data.mid(i); // remove possible multiple 0x02 for(i=1; i<data.size(); i++) if(data.at(i) != 0x02) break; data = data.mid(i-1); qfInfo() << "stripped data:" << data.toHex(); CardReader::CardReaderPlugin *plugin = cardReaderPlugin(); if(plugin) { if(!m_siDriver) { m_siDriver = new siut::DeviceDriver(this); connect(m_siDriver, &siut::DeviceDriver::siTaskFinished, plugin, &CardReader::CardReaderPlugin::emitSiTaskFinished); } m_siDriver->processData(data); } #else qfWarning() << "Racom client is not supported with Qt < 5.8"; #endif }