fix warnings (#1282)

* warnings

* don't need to template those
This commit is contained in:
Matthew Kennedy 2020-04-12 06:39:14 -07:00 committed by GitHub
parent 6481b9df0a
commit ff867b9301
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 49 additions and 116 deletions

View File

@ -181,7 +181,9 @@ static void handleGetDataRequest(const CANRxFrame& rx) {
static void handleDtcRequest(int numCodes, int *dtcCode) {
// TODO: this appears to be unfinished?
UNUSED(numCodes);
UNUSED(dtcCode);
// int numBytes = numCodes * 2;
// // write CAN-TP Single Frame header?
// txmsg.data8[0] = (uint8_t)((0 << 4) | numBytes);

View File

@ -230,8 +230,8 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
prevOutputName = outputName;
}
#if EFI_UNIT_TEST || EFI_SIMULATOR || EFI_PRINTF_FUEL_DETAILS
InjectorOutputPin *output = event->outputs[0];
#if EFI_PRINTF_FUEL_DETAILS
printf("fuelout %s duration %d total=%d\t\n", output->name, (int)durationUs,
(int)MS2US(getCrankshaftRevolutionTimeMs(GET_RPM_VALUE)));
#endif /*EFI_PRINTF_FUEL_DETAILS */

View File

@ -25,5 +25,5 @@ SensorResult LinearFunc::convert(float inputValue) const {
void LinearFunc::showInfo(Logging* logger, float testRawValue) const {
scheduleMsg(logger, " Linear function slope: %.2f offset: %.2f min: %.1f max: %.1f", m_a, m_b, m_minOutput, m_maxOutput);
const auto [valid, value] = convert(testRawValue);
scheduleMsg(logger, " raw value %.2f converts to %.2f", testRawValue, value);
scheduleMsg(logger, " raw value %.2f converts to %.2f valid: %d", testRawValue, value, valid);
}

View File

@ -28,6 +28,6 @@ SensorResult ResistanceFunc::convert(float raw) const {
}
void ResistanceFunc::showInfo(Logging* logger, float testInputValue) const {
const auto [valid, value] = convert(testInputValue);
scheduleMsg(logger, " %.2f volts -> %.1f ohms with supply voltage %.2f and pullup %.1f.", testInputValue, value, m_supplyVoltage, m_pullupResistor);
const auto result = convert(testInputValue);
scheduleMsg(logger, " %.2f volts -> %.1f ohms with supply voltage %.2f and pullup %.1f.", testInputValue, result.Value, m_supplyVoltage, m_pullupResistor);
}

View File

@ -11,5 +11,9 @@ struct SensorConverter {
SensorConverter() = default;
virtual SensorResult convert(float raw) const = 0;
virtual void showInfo(Logging* logger, float testRawValue) const {}
virtual void showInfo(Logging* logger, float testRawValue) const {
// Unused base - nothing to print
(void)logger;
(void)testRawValue;
}
};

View File

@ -299,11 +299,6 @@ void IgnitionOutputPin::reset() {
OutputPin::OutputPin() {
modePtr = &DEFAULT_OUTPUT;
#if EFI_GPIO_HARDWARE
port = NULL;
pin = 0;
#endif /* EFI_GPIO_HARDWARE */
currentLogicValue = INITIAL_PIN_STATE;
}
bool OutputPin::isInitialized() {

View File

@ -53,15 +53,15 @@ public:
#if EFI_GPIO_HARDWARE
ioportid_t port;
uint8_t pin;
ioportid_t port = 0;
uint8_t pin = 0;
#if (BOARD_EXT_GPIOCHIPS > 0)
/* used for external pins */
brain_pin_e brainPin;
bool ext;
#endif
#endif /* EFI_GPIO_HARDWARE */
int8_t currentLogicValue;
int8_t currentLogicValue = INITIAL_PIN_STATE;
/**
* we track current pin status so that we do not touch the actual hardware if we want to write new pin bit
* which is same as current pin value. This maybe helps in case of status leds, but maybe it's a total over-engineering

View File

@ -409,7 +409,7 @@ static void triggerShapeInfo(void) {
scheduleMsg(logger, "useRise=%s", boolToString(TRIGGER_WAVEFORM(useRiseEdge)));
scheduleMsg(logger, "gap from %.2f to %.2f", TRIGGER_WAVEFORM(syncronizationRatioFrom[0]), TRIGGER_WAVEFORM(syncronizationRatioTo[0]));
for (int i = 0; i < s->getSize(); i++) {
for (size_t i = 0; i < s->getSize(); i++) {
scheduleMsg(logger, "event %d %.2f", i, s->eventAngles[i]);
}
#endif

View File

@ -352,7 +352,7 @@ bool TriggerState::validateEventCounters(TriggerWaveform *triggerShape) const {
}
void TriggerState::onShaftSynchronization(const TriggerStateCallback triggerCycleCallback,
efitick_t nowNt, trigger_wheel_e triggerWheel, TriggerWaveform *triggerShape) {
efitick_t nowNt, TriggerWaveform *triggerShape) {
if (triggerCycleCallback) {
@ -627,7 +627,7 @@ void TriggerState::decodeTriggerEvent(TriggerWaveform *triggerShape, const Trigg
nextTriggerEvent()
;
onShaftSynchronization(triggerCycleCallback, nowNt, triggerWheel, triggerShape);
onShaftSynchronization(triggerCycleCallback, nowNt, triggerShape);
} else { /* if (!isSynchronizationPoint) */
nextTriggerEvent()

View File

@ -74,7 +74,7 @@ public:
bool validateEventCounters(TriggerWaveform *triggerShape) const;
void onShaftSynchronization(const TriggerStateCallback triggerCycleCallback,
efitick_t nowNt, trigger_wheel_e triggerWheel, TriggerWaveform *triggerShape);
efitick_t nowNt, TriggerWaveform *triggerShape);
bool isValidIndex(TriggerWaveform *triggerShape) const;

View File

@ -22,78 +22,8 @@
#include "poten.h"
#include "trigger_emulator.h"
static THD_WORKING_AREA(eeThreadStack, UTILITY_THREAD_STACK_SIZE);
#define DIAG_PIN GPIOD_0
void setDiag(int value) {
print("Setting diag: %d\r\n", value);
// todo: convert to new api palWritePad(DIAG_PORT, DIAG_PIN, value);
}
#define PERIOD 3000
EXTERN_ENGINE;
static void emulate(void) {
print("Emulating...\r\n");
setDiag(1);
chThdSleep(1);
for (int i = 400; i <= 1300; i++) {
if (i % 50 != 0)
continue;
setTriggerEmulatorRPM(i PASS_ENGINE_PARAMETER_SUFFIX);
chThdSleepMilliseconds(PERIOD);
}
setTriggerEmulatorRPM(0 PASS_ENGINE_PARAMETER_SUFFIX);
setDiag(0);
chThdSleep(1);
print("Emulation DONE!\r\n");
}
static int flag = FALSE;
static msg_t eeThread(void *arg) {
(void)arg;
chRegSetThreadName("Engine");
while (TRUE) {
while (!flag)
chThdSleepMilliseconds(200);
flag = FALSE;
emulate();
}
#if defined __GNUC__
return (msg_t)NULL;
#endif
}
void startEmulator(void) {
flag = TRUE;
}
//static void printAdvance(int rpm, int maf100) {
// float advance = getAdvance(rpm, maf100 / 100.0);
// print("advance for %d rpm %d maf100: %.2f\r\n", rpm, maf100, advance);
//}
#if defined(EFI_ENGINE_STIMULATOR)
static void initECUstimulator(Engine *engine) {
efiSetPadMode("TEN", DIAG_PIN, PAL_MODE_OUTPUT_PUSHPULL);
addConsoleActionI("diag", setDiag);
addConsoleAction("emu", startEmulator);
// addConsoleActionII("ad", printAdvance);
setDiag(1);
chThdCreateStatic(eeThreadStack, sizeof(eeThreadStack), NORMALPRIO, (tfunc_t)(void*) eeThread, engine);
}
#endif /* EFI_ENGINE_STIMULATOR */
void initEngineEmulator(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
if (hasFirmwareError())
return;
@ -102,6 +32,5 @@ void initEngineEmulator(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
initPotentiometers(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX);
#endif /* EFI_POTENTIOMETER && HAL_USE_SPI*/
//initECUstimulator();
initTriggerEmulator(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX);
}

View File

@ -274,7 +274,6 @@ static void listDirectory(const char *path) {
scheduleMsg(&logger, LS_RESPONSE);
int i = strlen(path);
for (int count = 0;count < FILE_LIST_MAX_COUNT;) {
FILINFO fno;

View File

@ -132,10 +132,10 @@ float interpolate3d(float x, const kType xBin[], int xBinSize, float y, const kT
#endif /* DEBUG_INTERPOLATION */
if (yIndex == yBinSize - 1)
return map[0][yIndex];
kType keyMin = yBin[yIndex];
kType keyMax = yBin[yIndex + 1];
vType rpmMinValue = map[0][yIndex];
vType rpmMaxValue = map[0][yIndex + 1];
float keyMin = yBin[yIndex];
float keyMax = yBin[yIndex + 1];
float rpmMinValue = map[0][yIndex];
float rpmMaxValue = map[0][yIndex + 1];
return interpolateMsg("3d", keyMin, rpmMinValue, keyMax, rpmMaxValue, y);
}
@ -147,10 +147,10 @@ float interpolate3d(float x, const kType xBin[], int xBinSize, float y, const kT
#endif /* DEBUG_INTERPOLATION */
if (xIndex == xBinSize - 1)
return map[xIndex][0];
kType key1 = xBin[xIndex];
kType key2 = xBin[xIndex + 1];
vType value1 = map[xIndex][0];
vType value2 = map[xIndex + 1][0];
float key1 = xBin[xIndex];
float key2 = xBin[xIndex + 1];
float value1 = map[xIndex][0];
float value2 = map[xIndex + 1][0];
return interpolateMsg("out3d", key1, value1, key2, value2, x);
}
@ -170,10 +170,10 @@ float interpolate3d(float x, const kType xBin[], int xBinSize, float y, const kT
#endif /* DEBUG_INTERPOLATION */
// here yIndex is less than yBinSize - 1, we've checked that condition already
kType key1 = yBin[yIndex];
kType key2 = yBin[yIndex + 1];
vType value1 = map[xIndex][yIndex];
vType value2 = map[xIndex][yIndex + 1];
float key1 = yBin[yIndex];
float key2 = yBin[yIndex + 1];
float value1 = map[xIndex][yIndex];
float value2 = map[xIndex][yIndex + 1];
return interpolateMsg("out3d", key1, value1, key2, value2, y);
}
@ -185,10 +185,10 @@ float interpolate3d(float x, const kType xBin[], int xBinSize, float y, const kT
#endif /* DEBUG_INTERPOLATION */
// here xIndex is less than xBinSize - 1, we've checked that condition already
kType key1 = xBin[xIndex];
kType key2 = xBin[xIndex + 1];
vType value1 = map[xIndex][yIndex];
vType value2 = map[xIndex + 1][yIndex];
float key1 = xBin[xIndex];
float key2 = xBin[xIndex + 1];
float value1 = map[xIndex][yIndex];
float value2 = map[xIndex + 1][yIndex];
return interpolateMsg("out3d", key1, value1, key2, value2, x);
}
@ -198,10 +198,10 @@ float interpolate3d(float x, const kType xBin[], int xBinSize, float y, const kT
*/
int rpmMaxIndex = xIndex + 1;
kType xMin = xBin[xIndex];
kType xMax = xBin[xIndex + 1];
vType rpmMinKeyMinValue = map[xIndex][yIndex];
vType rpmMaxKeyMinValue = map[xIndex + 1][yIndex];
float xMin = xBin[xIndex];
float xMax = xBin[xIndex + 1];
float rpmMinKeyMinValue = map[xIndex][yIndex];
float rpmMaxKeyMinValue = map[xIndex + 1][yIndex];
float keyMinValue = interpolateMsg("", xMin, rpmMinKeyMinValue, xMax, rpmMaxKeyMinValue, x);
@ -213,10 +213,10 @@ float interpolate3d(float x, const kType xBin[], int xBinSize, float y, const kT
#endif /* DEBUG_INTERPOLATION */
int keyMaxIndex = yIndex + 1;
kType keyMin = yBin[yIndex];
kType keyMax = yBin[keyMaxIndex];
vType rpmMinKeyMaxValue = map[xIndex][keyMaxIndex];
vType rpmMaxKeyMaxValue = map[rpmMaxIndex][keyMaxIndex];
float keyMin = yBin[yIndex];
float keyMax = yBin[keyMaxIndex];
float rpmMinKeyMaxValue = map[xIndex][keyMaxIndex];
float rpmMaxKeyMaxValue = map[rpmMaxIndex][keyMaxIndex];
float keyMaxValue = interpolateMsg("3d", xMin, rpmMinKeyMaxValue, xMax, rpmMaxKeyMaxValue, x);
@ -224,11 +224,14 @@ float interpolate3d(float x, const kType xBin[], int xBinSize, float y, const kT
if (needInterpolationLogging()) {
printf("key=%.2f:\r\nrange %.2f - %.2f\r\n", y, keyMin, keyMax);
printf("key interpolation range %.2f %.2f result %.2f\r\n", rpmMinKeyMaxValue, rpmMaxKeyMaxValue, keyMaxValue);
printf("%f", rpmMinKeyMaxValue);
printf("%f", rpmMaxKeyMaxValue);
printf("%f", keyMaxValue);
}
#endif /* DEBUG_INTERPOLATION */
float result = interpolateMsg("3d", keyMin, keyMinValue, keyMax, keyMaxValue, y);
return result;
return interpolateMsg("3d", keyMin, keyMinValue, keyMax, keyMaxValue, y);
}
void setCurveValue(float bins[], float values[], int size, float key, float value);
void initInterpolation(Logging *sharedLogger);

View File

@ -26,6 +26,7 @@ ifeq ($(USE_OPT),)
USE_OPT = -c -Wall -O0 -ggdb -g3
USE_OPT += -fprofile-arcs -ftest-coverage
USE_OPT += -Werror=missing-field-initializers
USE_OPT += -Wno-unused-parameter -Wno-unused-function
endif