Skip to content

Commit

Permalink
Merge branch 'vedderb:master' into ci
Browse files Browse the repository at this point in the history
  • Loading branch information
darwinbeing authored Jan 31, 2024
2 parents b1ac515 + a659ac0 commit ec4674f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 30 deletions.
2 changes: 2 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
23 changes: 1 addition & 22 deletions packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -131,8 +123,6 @@ void Packet::processData(QByteArray data)
QVector<QByteArray> decodedPackets;

for(unsigned char rx_data: data) {
mRxTimer = mByteTimeout;

unsigned int data_len = mRxWritePtr - mRxReadPtr;

// Out of space (should not happen)
Expand Down Expand Up @@ -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<QByteArray> &decodedPackets)
{
Expand Down
7 changes: 0 additions & 7 deletions packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#define PACKET_H

#include <QObject>
#include <QTimer>

class Packet : public QObject
{
Expand All @@ -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;
Expand Down
14 changes: 13 additions & 1 deletion vescinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;");
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions vescinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -459,6 +462,7 @@ private slots:
bool mAllowScreenRotation;
bool mSpeedGaugeUseNegativeValues;
bool mAskQmlLoad;
bool mIgnoreCustomConfigs;

void updateFwRx(bool fwRx);
void setLastConnectionType(conn_t type);
Expand Down

0 comments on commit ec4674f

Please sign in to comment.