Esempio n. 1
0
void DisplayClient::appClientReceiveMulticast(int servicePort, SYNTRO_EHEAD *multiCast, int len)
{
	// make sure this is for us
	if (servicePort != m_receivePort) {
		logWarn(QString("Multicast received to invalid port %1").arg(servicePort));
		free(multiCast);
		return;
	}

	// and the size we expect
	if (len != (sizeof(SYNTRO_RECORD_HEADER) + sizeof(quint32))) {
		logWarn(QString("Multicast length is unexpected : %1").arg(len - sizeof(SYNTRO_RECORD_HEADER)));
		free(multiCast);
		return;
	}

	// unpack the record, first get a pointer to the SYNTRO_RECORD_HEADER
	SYNTRO_RECORD_HEADER *head = (SYNTRO_RECORD_HEADER *)(multiCast + 1);

	// the led data is immediately after the SYNTRO_RECORD_HEADER in a single quint32
	quint32 *values = (quint32 *)(head + 1);

	// the BoneLedDisplay class catches this signal
	emit newData(*values);

	// ack the data
	clientSendMulticastAck(servicePort);

	// always free the record you are given
	free(multiCast);
}
void SyntroPythonClient::appClientReceiveMulticast(int servicePort, SYNTRO_EHEAD *message, int length)
{
    QMutexLocker lock(&m_lock);

    while (servicePort >= m_receivedData.count())
        m_receivedData.append(QQueue<QByteArray>());

    m_receivedData[servicePort].append(QByteArray((const char *)(message + 1), length));
    if (m_receivedData[servicePort].count() > 5)            // stop queue getting too long
        m_receivedData[servicePort].dequeue();
    clientSendMulticastAck(servicePort);
    free(message);
}
Esempio n. 3
0
void StoreClient::appClientReceiveMulticast(int servicePort, SYNTRO_EHEAD *message, int len)
{
	int sourceIndex;

	sourceIndex = clientGetServiceData(servicePort);

	if ((sourceIndex >= SYNTROSTORE_MAX_STREAMS) || (sourceIndex < 0)) {
		logWarn(QString("Multicast received to out of range port %1").arg(servicePort));
		free(message);
		return;
	}
	if (m_sources[sourceIndex] != NULL) {					// still active
		m_sources[sourceIndex]->queueBlock(QByteArray(reinterpret_cast<char *>(message + 1), len));
		clientSendMulticastAck(servicePort);
	}
	free(message);
}
Esempio n. 4
0
void ViewClient::appClientReceiveMulticast(int servicePort, SYNTRO_EHEAD *multiCast, int totalLength)
{
    SYNTRO_GLOVEDATA *data;
    RTQuaternion palmQuat;
    RTQuaternion thumbQuat;
    RTQuaternion fingerQuat;

    SYNTRO_RECORD_HEADER *head = (SYNTRO_RECORD_HEADER *)(multiCast + 1);
    int recordType = SyntroUtils::convertUC2ToUInt(head->type);

    if (recordType != SYNTRO_RECORD_TYPE_GLOVE) {
        qDebug() << "Expecting nav record, received record type" << recordType;
    } else {
        data = (SYNTRO_GLOVEDATA *)(head + 1);

        while (totalLength > (int)sizeof(SYNTRO_GLOVEDATA)) {
            palmQuat.setScalar(data->fusionQPosePalm[0]);
            palmQuat.setX(data->fusionQPosePalm[1]);
            palmQuat.setY(data->fusionQPosePalm[2]);
            palmQuat.setZ(data->fusionQPosePalm[3]);

            thumbQuat.setScalar(data->fusionQPoseThumb[0]);
            thumbQuat.setX(data->fusionQPoseThumb[1]);
            thumbQuat.setY(data->fusionQPoseThumb[2]);
            thumbQuat.setZ(data->fusionQPoseThumb[3]);

            fingerQuat.setScalar(data->fusionQPoseFinger[0]);
            fingerQuat.setX(data->fusionQPoseFinger[1]);
            fingerQuat.setY(data->fusionQPoseFinger[2]);
            fingerQuat.setZ(data->fusionQPoseFinger[3]);

            emit newIMUData(palmQuat, thumbQuat, fingerQuat);
            totalLength -= sizeof(SYNTRO_GLOVEDATA);
            data++;
        }
    }
    clientSendMulticastAck(servicePort);
    free(multiCast);
}