[Simulator] Fix intermittent crc errors with telemetry simulator.
This commit is contained in:
@@ -141,7 +141,7 @@ class SimulatorInterface : public QObject
|
||||
virtual void setInputValue(int type, uint8_t index, int16_t value) = 0;
|
||||
virtual void rotaryEncoderEvent(int steps) = 0;
|
||||
virtual void setTrainerTimeout(uint16_t ms) = 0;
|
||||
virtual void sendTelemetry(uint8_t * data, unsigned int len) = 0;
|
||||
virtual void sendTelemetry(const QByteArray data) = 0;
|
||||
virtual void setLuaStateReloadPermanentScripts() = 0;
|
||||
virtual void addTracebackDevice(QIODevice * device) = 0;
|
||||
virtual void removeTracebackDevice(QIODevice * device) = 0;
|
||||
|
||||
@@ -227,7 +227,6 @@ void setSportPacketCrc(uint8_t * packet)
|
||||
crc &= 0x00ff;
|
||||
}
|
||||
packet[FRSKY_SPORT_PACKET_SIZE-1] = 0xFF - (crc & 0x00ff);
|
||||
//TRACE("crc set: %x", packet[FRSKY_SPORT_PACKET_SIZE-1]);
|
||||
}
|
||||
|
||||
uint8_t getBit(uint8_t position, uint8_t value)
|
||||
@@ -257,15 +256,13 @@ void TelemetrySimulator::generateTelemetryFrame()
|
||||
{
|
||||
static int item = 0;
|
||||
bool ok = true;
|
||||
uint8_t buffer[FRSKY_SPORT_PACKET_SIZE];
|
||||
uint8_t buffer[FRSKY_SPORT_PACKET_SIZE] = {0};
|
||||
static FlvssEmulator *flvss = new FlvssEmulator();
|
||||
static GPSEmulator *gps = new GPSEmulator();
|
||||
|
||||
if (!m_simuStarted)
|
||||
return;
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
|
||||
switch (item++) {
|
||||
case 0:
|
||||
#if defined(XJT_VERSION_ID)
|
||||
@@ -431,10 +428,14 @@ void TelemetrySimulator::generateTelemetryFrame()
|
||||
return;
|
||||
}
|
||||
|
||||
if (ok && (buffer[2] || buffer[3]))
|
||||
emit telemetryDataChanged(buffer, FRSKY_SPORT_PACKET_SIZE);
|
||||
else
|
||||
if (ok && (buffer[2] || buffer[3])) {
|
||||
QByteArray ba((char *)buffer, FRSKY_SPORT_PACKET_SIZE);
|
||||
emit telemetryDataChanged(ba);
|
||||
//qDebug("%02X %02X %02X %02X %02X %02X %02X %02X %02X", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], buffer[8]);
|
||||
}
|
||||
else {
|
||||
generateTelemetryFrame();
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t TelemetrySimulator::FlvssEmulator::encodeCellPair(uint8_t cellNum, uint8_t firstCellNo, double cell1, double cell2)
|
||||
|
||||
@@ -48,7 +48,7 @@ class TelemetrySimulator : public QWidget
|
||||
|
||||
signals:
|
||||
|
||||
void telemetryDataChanged(uint8_t * data, unsigned int len);
|
||||
void telemetryDataChanged(const QByteArray data);
|
||||
|
||||
protected slots:
|
||||
|
||||
|
||||
@@ -305,11 +305,11 @@ void OpenTxSimulator::setTrainerTimeout(uint16_t ms)
|
||||
ppmInputValidityTimer = ms;
|
||||
}
|
||||
|
||||
void OpenTxSimulator::sendTelemetry(uint8_t * data, unsigned int len)
|
||||
void OpenTxSimulator::sendTelemetry(const QByteArray data)
|
||||
{
|
||||
Q_UNUSED(len)
|
||||
#if defined(TELEMETRY_FRSKY_SPORT)
|
||||
sportProcessTelemetryPacket(data);
|
||||
//OTXS_DBG << data;
|
||||
sportProcessTelemetryPacket((uint8_t *)data.constData());
|
||||
#else
|
||||
Q_UNUSED(data)
|
||||
#endif
|
||||
|
||||
@@ -65,7 +65,7 @@ class DLLEXPORT OpenTxSimulator : public SimulatorInterface
|
||||
virtual void setInputValue(int type, uint8_t index, int16_t value);
|
||||
virtual void rotaryEncoderEvent(int steps);
|
||||
virtual void setTrainerTimeout(uint16_t ms);
|
||||
virtual void sendTelemetry(uint8_t * data, unsigned int len);
|
||||
virtual void sendTelemetry(const QByteArray data);
|
||||
virtual void setLuaStateReloadPermanentScripts();
|
||||
virtual void addTracebackDevice(QIODevice * device);
|
||||
virtual void removeTracebackDevice(QIODevice * device);
|
||||
|
||||
Reference in New Issue
Block a user