Skip to content

Commit

Permalink
Fixed some bugs around custom configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
vedderb committed Mar 10, 2024
1 parent af09e28 commit d69db23
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
20 changes: 15 additions & 5 deletions commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ Commands::Commands(QObject *parent) : QObject(parent)
mTimeoutDecAdc = 0;
mTimeoutDecChuk = 0;
mTimeoutPingCan = 0;
mTimeoutCustomConf = 0;
mTimeoutBmsVal = 0;

mFilePercentage = 0.0;
Expand Down Expand Up @@ -742,8 +741,12 @@ void Commands::processPacket(QByteArray data)

case COMM_GET_CUSTOM_CONFIG:
case COMM_GET_CUSTOM_CONFIG_DEFAULT: {
mTimeoutCustomConf = 0;
int confInd = vb.vbPopFrontInt8();

if (mTimeoutCustomConf.size() > confInd) {
mTimeoutCustomConf[confInd] = 0;
}

emit customConfigRx(confInd, vb);
} break;

Expand Down Expand Up @@ -1994,11 +1997,15 @@ void Commands::customConfigGetChunk(int confInd, int len, int offset)

void Commands::customConfigGet(int confInd, bool isDefault)
{
if (mTimeoutCustomConf > 0) {
while (mTimeoutCustomConf.size() <= confInd) {
mTimeoutCustomConf.append(0);
}

if (mTimeoutCustomConf[confInd] > 0) {
return;
}

mTimeoutCustomConf = mTimeoutCount;
mTimeoutCustomConf[confInd] = mTimeoutCount;

VByteArray vb;
vb.vbAppendUint8(isDefault ? COMM_GET_CUSTOM_CONFIG_DEFAULT : COMM_GET_CUSTOM_CONFIG);
Expand Down Expand Up @@ -2272,7 +2279,10 @@ void Commands::timerSlot()
qWarning() << "CAN ping timed out";
}
}
if (mTimeoutCustomConf > 0) mTimeoutCustomConf--;
for (int i = 0;i < mTimeoutCustomConf.size();i++) {
if (mTimeoutCustomConf.at(i) > 0) mTimeoutCustomConf[i]--;
}

if (mTimeoutBmsVal > 0) mTimeoutBmsVal--;
if (mTimeoutStats > 0) mTimeoutStats--;
}
Expand Down
2 changes: 1 addition & 1 deletion commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ private slots:
int mTimeoutDecAdc;
int mTimeoutDecChuk;
int mTimeoutPingCan;
int mTimeoutCustomConf;
QVector<int> mTimeoutCustomConf;
int mTimeoutBmsVal;
int mTimeoutStats;

Expand Down
10 changes: 5 additions & 5 deletions vescinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3784,13 +3784,13 @@ void VescInterface::fwVersionReceived(FW_RX_PARAMS params)
QDir().mkpath(confCacheDir);
}

while (!mCustomConfigs.isEmpty()) {
mCustomConfigs.last()->deleteLater();
mCustomConfigs.removeLast();
}

// Read custom configs
if (!mIgnoreCustomConfigs && params.customConfigNum > 0) {
while (!mCustomConfigs.isEmpty()) {
mCustomConfigs.last()->deleteLater();
mCustomConfigs.removeLast();
}

bool readConfigsOk = true;
for (int i = 0;i < params.customConfigNum;i++) {
QString confCacheFile;
Expand Down

0 comments on commit d69db23

Please sign in to comment.