1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-21 11:54:15 +01:00

OP-4 GCS/Telemetry More bug fixes after telemetry testing (basic functionality now working)

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@507 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
vassilis 2010-04-16 01:56:56 +00:00 committed by vassilis
parent bc472102b4
commit c107ab34d4
7 changed files with 22 additions and 21 deletions

View File

@ -240,6 +240,7 @@ qint32 UAVObject::unpack(const quint8* dataIn)
} }
emit objectUnpacked(this); // trigger object updated event emit objectUnpacked(this); // trigger object updated event
emit objectUpdated(this); emit objectUpdated(this);
return numBytes; return numBytes;
} }
@ -285,7 +286,7 @@ bool UAVObject::save(QFile& file)
quint8 tmpId[4]; quint8 tmpId[4];
// Write the object ID // Write the object ID
qToBigEndian<quint32>(objID, tmpId); qToLittleEndian<quint32>(objID, tmpId);
if ( file.write((const char*)tmpId, 4) == -1 ) if ( file.write((const char*)tmpId, 4) == -1 )
{ {
return false; return false;
@ -294,7 +295,7 @@ bool UAVObject::save(QFile& file)
// Write the instance ID // Write the instance ID
if (!isSingleInst) if (!isSingleInst)
{ {
qToBigEndian<quint16>(instID, tmpId); qToLittleEndian<quint16>(instID, tmpId);
if ( file.write((const char*)tmpId, 2) == -1 ) if ( file.write((const char*)tmpId, 2) == -1 )
{ {
return false; return false;
@ -360,7 +361,7 @@ bool UAVObject::load(QFile& file)
} }
// Check that the IDs match // Check that the IDs match
if (qFromBigEndian<quint32>(tmpId) != objID) if (qFromLittleEndian<quint32>(tmpId) != objID)
{ {
return false; return false;
} }
@ -372,7 +373,7 @@ bool UAVObject::load(QFile& file)
} }
// Check that the IDs match // Check that the IDs match
if (qFromBigEndian<quint16>(tmpId) != instID) if (qFromLittleEndian<quint16>(tmpId) != instID)
{ {
return false; return false;
} }

View File

@ -58,7 +58,7 @@ qint32 UAVObjectFieldFloat::pack(quint8* dataOut)
{ {
quint32 value; quint32 value;
memcpy(&value, &data[offset + numBytesPerElement*index], numBytesPerElement); memcpy(&value, &data[offset + numBytesPerElement*index], numBytesPerElement);
qToBigEndian<quint32>(value, &dataOut[numBytesPerElement*index]); qToLittleEndian<quint32>(value, &dataOut[numBytesPerElement*index]);
} }
// Done // Done
return getNumBytes(); return getNumBytes();
@ -74,7 +74,7 @@ qint32 UAVObjectFieldFloat::unpack(const quint8* dataIn)
for (quint32 index = 0; index < numElements; ++index) for (quint32 index = 0; index < numElements; ++index)
{ {
quint32 value; quint32 value;
value = qFromBigEndian<quint32>(&dataIn[numBytesPerElement*index]); value = qFromLittleEndian<quint32>(&dataIn[numBytesPerElement*index]);
memcpy(&data[offset + numBytesPerElement*index], &value, numBytesPerElement); memcpy(&data[offset + numBytesPerElement*index], &value, numBytesPerElement);
} }
// Done // Done

View File

@ -58,7 +58,7 @@ qint32 UAVObjectFieldInt16::pack(quint8* dataOut)
{ {
qint16 value; qint16 value;
memcpy(&value, &data[offset + numBytesPerElement*index], numBytesPerElement); memcpy(&value, &data[offset + numBytesPerElement*index], numBytesPerElement);
qToBigEndian<qint16>(value, &dataOut[numBytesPerElement*index]); qToLittleEndian<qint16>(value, &dataOut[numBytesPerElement*index]);
} }
// Done // Done
return getNumBytes(); return getNumBytes();
@ -74,7 +74,7 @@ qint32 UAVObjectFieldInt16::unpack(const quint8* dataIn)
for (quint32 index = 0; index < numElements; ++index) for (quint32 index = 0; index < numElements; ++index)
{ {
qint16 value; qint16 value;
value = qFromBigEndian<qint16>(&dataIn[numBytesPerElement*index]); value = qFromLittleEndian<qint16>(&dataIn[numBytesPerElement*index]);
memcpy(&data[offset + numBytesPerElement*index], &value, numBytesPerElement); memcpy(&data[offset + numBytesPerElement*index], &value, numBytesPerElement);
} }
// Done // Done

View File

@ -58,7 +58,7 @@ qint32 UAVObjectFieldInt32::pack(quint8* dataOut)
{ {
qint32 value; qint32 value;
memcpy(&value, &data[offset + numBytesPerElement*index], numBytesPerElement); memcpy(&value, &data[offset + numBytesPerElement*index], numBytesPerElement);
qToBigEndian<qint32>(value, &dataOut[numBytesPerElement*index]); qToLittleEndian<qint32>(value, &dataOut[numBytesPerElement*index]);
} }
// Done // Done
return getNumBytes(); return getNumBytes();
@ -74,7 +74,7 @@ qint32 UAVObjectFieldInt32::unpack(const quint8* dataIn)
for (quint32 index = 0; index < numElements; ++index) for (quint32 index = 0; index < numElements; ++index)
{ {
qint32 value; qint32 value;
value = qFromBigEndian<qint32>(&dataIn[numBytesPerElement*index]); value = qFromLittleEndian<qint32>(&dataIn[numBytesPerElement*index]);
memcpy(&data[offset + numBytesPerElement*index], &value, numBytesPerElement); memcpy(&data[offset + numBytesPerElement*index], &value, numBytesPerElement);
} }
// Done // Done

View File

@ -58,7 +58,7 @@ qint32 UAVObjectFieldUInt16::pack(quint8* dataOut)
{ {
quint16 value; quint16 value;
memcpy(&value, &data[offset + numBytesPerElement*index], numBytesPerElement); memcpy(&value, &data[offset + numBytesPerElement*index], numBytesPerElement);
qToBigEndian<quint16>(value, &dataOut[numBytesPerElement*index]); qToLittleEndian<quint16>(value, &dataOut[numBytesPerElement*index]);
} }
// Done // Done
return getNumBytes(); return getNumBytes();
@ -74,7 +74,7 @@ qint32 UAVObjectFieldUInt16::unpack(const quint8* dataIn)
for (quint32 index = 0; index < numElements; ++index) for (quint32 index = 0; index < numElements; ++index)
{ {
quint16 value; quint16 value;
value = qFromBigEndian<quint16>(&dataIn[numBytesPerElement*index]); value = qFromLittleEndian<quint16>(&dataIn[numBytesPerElement*index]);
memcpy(&data[offset + numBytesPerElement*index], &value, numBytesPerElement); memcpy(&data[offset + numBytesPerElement*index], &value, numBytesPerElement);
} }
// Done // Done

View File

@ -58,7 +58,7 @@ qint32 UAVObjectFieldUInt32::pack(quint8* dataOut)
{ {
quint32 value; quint32 value;
memcpy(&value, &data[offset + numBytesPerElement*index], numBytesPerElement); memcpy(&value, &data[offset + numBytesPerElement*index], numBytesPerElement);
qToBigEndian<quint32>(value, &dataOut[numBytesPerElement*index]); qToLittleEndian<quint32>(value, &dataOut[numBytesPerElement*index]);
} }
// Done // Done
return getNumBytes(); return getNumBytes();
@ -74,7 +74,7 @@ qint32 UAVObjectFieldUInt32::unpack(const quint8* dataIn)
for (quint32 index = 0; index < numElements; ++index) for (quint32 index = 0; index < numElements; ++index)
{ {
quint32 value; quint32 value;
value = qFromBigEndian<quint32>(&dataIn[numBytesPerElement*index]); value = qFromLittleEndian<quint32>(&dataIn[numBytesPerElement*index]);
memcpy(&data[offset + numBytesPerElement*index], &value, numBytesPerElement); memcpy(&data[offset + numBytesPerElement*index], &value, numBytesPerElement);
} }
// Done // Done

View File

@ -156,7 +156,7 @@ bool UAVTalk::processInputByte(quint8 rxbyte)
if (rxCount == 4) if (rxCount == 4)
{ {
// Search for object, if not found reset state machine // Search for object, if not found reset state machine
rxObjId = (qint32)qFromBigEndian<quint32>(rxTmpBuffer); rxObjId = (qint32)qFromLittleEndian<quint32>(rxTmpBuffer);
UAVObject* rxObj = objMngr->getObject(rxObjId); UAVObject* rxObj = objMngr->getObject(rxObjId);
if (rxObj == NULL) if (rxObj == NULL)
{ {
@ -210,7 +210,7 @@ bool UAVTalk::processInputByte(quint8 rxbyte)
rxTmpBuffer[rxCount++] = rxbyte; rxTmpBuffer[rxCount++] = rxbyte;
if (rxCount == 2) if (rxCount == 2)
{ {
rxInstId = (qint16)qFromBigEndian<quint16>(rxTmpBuffer); rxInstId = (qint16)qFromLittleEndian<quint16>(rxTmpBuffer);
rxCS = updateChecksum(rxCS, rxTmpBuffer, 2); rxCS = updateChecksum(rxCS, rxTmpBuffer, 2);
rxCount = 0; rxCount = 0;
// If there is a payload get it, otherwise receive checksum // If there is a payload get it, otherwise receive checksum
@ -237,7 +237,7 @@ bool UAVTalk::processInputByte(quint8 rxbyte)
rxTmpBuffer[rxCount++] = rxbyte; rxTmpBuffer[rxCount++] = rxbyte;
if (rxCount == 2) if (rxCount == 2)
{ {
rxCSPacket = (qint16)qFromBigEndian<quint16>(rxTmpBuffer); rxCSPacket = (qint16)qFromLittleEndian<quint16>(rxTmpBuffer);
if (rxCS == rxCSPacket) if (rxCS == rxCSPacket)
{ {
mutex->lock(); mutex->lock();
@ -486,7 +486,7 @@ bool UAVTalk::transmitSingleObject(UAVObject* obj, quint8 type, bool allInstance
// Setup type and object id fields // Setup type and object id fields
objId = obj->getObjID(); objId = obj->getObjID();
txBuffer[0] = type; txBuffer[0] = type;
qToBigEndian<quint32>(objId, &txBuffer[1]); qToLittleEndian<quint32>(objId, &txBuffer[1]);
// Setup instance ID if one is required // Setup instance ID if one is required
if ( obj->isSingleInstance() ) if ( obj->isSingleInstance() )
@ -498,12 +498,12 @@ bool UAVTalk::transmitSingleObject(UAVObject* obj, quint8 type, bool allInstance
// Check if all instances are requested // Check if all instances are requested
if (allInstances) if (allInstances)
{ {
qToBigEndian<quint16>(allInstId, &txBuffer[5]); qToLittleEndian<quint16>(allInstId, &txBuffer[5]);
} }
else else
{ {
instId = obj->getInstID(); instId = obj->getInstID();
qToBigEndian<quint16>(instId, &txBuffer[5]); qToLittleEndian<quint16>(instId, &txBuffer[5]);
} }
dataOffset = 7; dataOffset = 7;
} }
@ -536,7 +536,7 @@ bool UAVTalk::transmitSingleObject(UAVObject* obj, quint8 type, bool allInstance
// Calculate checksum // Calculate checksum
cs = 0; cs = 0;
cs = updateChecksum(cs, txBuffer, dataOffset+length); cs = updateChecksum(cs, txBuffer, dataOffset+length);
qToBigEndian<quint16>(cs, &txBuffer[dataOffset+length]); qToLittleEndian<quint16>(cs, &txBuffer[dataOffset+length]);
// Send buffer // Send buffer
io->write((const char*)txBuffer, dataOffset+length+CHECKSUM_LENGTH); io->write((const char*)txBuffer, dataOffset+length+CHECKSUM_LENGTH);