[Simulator] Fix trims issue with AVR simulators (build failure since 57dc015); Fix possible array bounds issue if data is corrupt.

This commit is contained in:
Max Paperno
2017-04-07 03:50:40 -04:00
parent 3a8f9adb4d
commit 629d82fe27
2 changed files with 6 additions and 2 deletions
+1 -1
View File
@@ -689,7 +689,7 @@ QString RawSwitch::toString(Board::Type board, const GeneralSettings * const gen
swName = QString(generalSettings->switchName[qr.quot]); swName = QString(generalSettings->switchName[qr.quot]);
if (swName.isEmpty()) if (swName.isEmpty())
swName = getSwitchInfo(board, qr.quot).name; swName = getSwitchInfo(board, qr.quot).name;
return swName + directionIndicators.at(qr.rem < directionIndicators.size() ? qr.rem : 1); return swName + directionIndicators.at(qr.rem > -1 && qr.rem < directionIndicators.size() ? qr.rem : 1);
} }
else { else {
return CHECK_IN_ARRAY(switches9X, index - 1); return CHECK_IN_ARRAY(switches9X, index - 1);
+5 -1
View File
@@ -211,6 +211,7 @@ void OpenTxSimulator::setTrim(unsigned int idx, int value)
i = modn12x3[4 * getStickMode() + idx]; i = modn12x3[4 * getStickMode() + idx];
uint8_t phase = getTrimFlightMode(getFlightMode(), i); uint8_t phase = getTrimFlightMode(getFlightMode(), i);
#ifdef CPUARM
if (!setTrimValue(phase, i, value)) { if (!setTrimValue(phase, i, value)) {
QTimer *timer = new QTimer(this); QTimer *timer = new QTimer(this);
timer->setSingleShot(true); timer->setSingleShot(true);
@@ -221,6 +222,9 @@ void OpenTxSimulator::setTrim(unsigned int idx, int value)
}); });
timer->start(350); timer->start(350);
} }
#else
setTrimValue(phase, i, value);
#endif
} }
void OpenTxSimulator::setTrainerInput(unsigned int inputNumber, int16_t value) void OpenTxSimulator::setTrainerInput(unsigned int inputNumber, int16_t value)
@@ -405,7 +409,7 @@ void OpenTxSimulator::removeTracebackDevice(QIODevice * device)
} }
/*** Protected classes ***/ /*** Protected functions ***/
void OpenTxSimulator::run() void OpenTxSimulator::run()
{ {