diff --git a/main.cpp b/main.cpp index 2dc9411f0..7adc91251 100755 --- a/main.cpp +++ b/main.cpp @@ -981,6 +981,8 @@ int main(int argc, char *argv[]) } app = new QCoreApplication(argc, argv); vesc = new VescInterface; + vesc->setIgnoreCustomConfigs(!isCustomConf); + vesc->fwConfig()->loadParamsXml("://res/config/fw.xml"); Utility::configLoadLatest(vesc); diff --git a/packet.cpp b/packet.cpp index a55564058..ce2d626f1 100644 --- a/packet.cpp +++ b/packet.cpp @@ -56,20 +56,12 @@ const unsigned short crc16_tab[] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, Packet::Packet(QObject *parent) : QObject(parent) { - mRxTimer = 0; - mByteTimeout = 50; mMaxPacketLen = 10000; mRxReadPtr = 0; mRxWritePtr = 0; mBytesLeft = 0; mBufferLen = mMaxPacketLen + 8; mRxBuffer = new unsigned char[mBufferLen]; - - mTimer = new QTimer(this); - mTimer->setInterval(10); - mTimer->start(); - - connect(mTimer, SIGNAL(timeout()), this, SLOT(timerSlot())); } Packet::~Packet() @@ -131,8 +123,6 @@ void Packet::processData(QByteArray data) QVector decodedPackets; for(unsigned char rx_data: data) { - mRxTimer = mByteTimeout; - unsigned int data_len = mRxWritePtr - mRxReadPtr; // Out of space (should not happen) @@ -188,22 +178,11 @@ void Packet::processData(QByteArray data) } } - for (QByteArray b: decodedPackets) { + foreach (QByteArray b, decodedPackets) { emit packetReceived(b); } } -void Packet::timerSlot() -{ - if (mRxTimer) { - mRxTimer--; - } else { - mRxReadPtr = 0; - mRxWritePtr = 0; - mBytesLeft = 0; - } -} - int Packet::try_decode_packet(unsigned char *buffer, unsigned int in_len, int *bytes_left, QVector &decodedPackets) { diff --git a/packet.h b/packet.h index 98acb78a4..9f4110cec 100644 --- a/packet.h +++ b/packet.h @@ -21,7 +21,6 @@ #define PACKET_H #include -#include class Packet : public QObject { @@ -40,13 +39,7 @@ class Packet : public QObject public slots: void processData(QByteArray data); -private slots: - void timerSlot(); - private: - QTimer *mTimer; - int mRxTimer; - int mByteTimeout; unsigned int mRxReadPtr; unsigned int mRxWritePtr; int mBytesLeft; diff --git a/vescinterface.cpp b/vescinterface.cpp index d7ca091b1..b73e5ecd5 100755 --- a/vescinterface.cpp +++ b/vescinterface.cpp @@ -105,6 +105,8 @@ VescInterface::VescInterface(QObject *parent) : QObject(parent) mCanTmpFwdSendCanLast = false; mCanTmpFwdIdLast = -1; + mIgnoreCustomConfigs = false; + #ifdef Q_OS_ANDROID QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod( "org/qtproject/qt5/android/QtNative", "activity", "()Landroid/app/Activity;"); @@ -3765,7 +3767,7 @@ void VescInterface::fwVersionReceived(FW_RX_PARAMS params) } // Read custom configs - if (params.customConfigNum > 0) { + if (!mIgnoreCustomConfigs && params.customConfigNum > 0) { while (!mCustomConfigs.isEmpty()) { mCustomConfigs.last()->deleteLater(); mCustomConfigs.removeLast(); @@ -3995,6 +3997,16 @@ void VescInterface::customConfigRx(int confId, QByteArray data) } } +bool VescInterface::ignoreCustomConfigs() const +{ + return mIgnoreCustomConfigs; +} + +void VescInterface::setIgnoreCustomConfigs(bool newIgnoreCustomConfigs) +{ + mIgnoreCustomConfigs = newIgnoreCustomConfigs; +} + int VescInterface::getLastTcpHubPort() const { return mLastTcpHubPort; diff --git a/vescinterface.h b/vescinterface.h index c0cc0ee04..d5703c6c7 100755 --- a/vescinterface.h +++ b/vescinterface.h @@ -262,6 +262,9 @@ class VescInterface : public QObject Q_INVOKABLE bool downloadFwArchive(); + bool ignoreCustomConfigs() const; + void setIgnoreCustomConfigs(bool newIgnoreCustomConfigs); + signals: void statusMessage(const QString &msg, bool isGood); void messageDialog(const QString &title, const QString &msg, bool isGood, bool richText); @@ -459,6 +462,7 @@ private slots: bool mAllowScreenRotation; bool mSpeedGaugeUseNegativeValues; bool mAskQmlLoad; + bool mIgnoreCustomConfigs; void updateFwRx(bool fwRx); void setLastConnectionType(conn_t type);