manual sync

This commit is contained in:
Andrey B 2014-04-30 11:05:25 -05:00
parent 785ffea80f
commit 3fcd366ef8
19 changed files with 31 additions and 792 deletions

View File

@ -71,7 +71,7 @@
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="controllers_trigger/trigger_central.c|controllers_trigger/rpm_calculator.c|controllers_trigger/main_trigger_callback.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry excluding="controllers_trigger/trigger_central.cpp|controllers_trigger/rpm_calculator.cpp|controllers_trigger/trigger_central.c|controllers_trigger/rpm_calculator.c|controllers_trigger/main_trigger_callback.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
@ -119,7 +119,7 @@
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="controllers_trigger/trigger_central.c|controllers_trigger/rpm_calculator.c|controllers_trigger/main_trigger_callback.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry excluding="controllers_trigger/trigger_central.cpp|controllers_trigger/rpm_calculator.cpp|controllers_trigger/trigger_central.c|controllers_trigger/rpm_calculator.c|controllers_trigger/main_trigger_callback.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>

View File

@ -86,19 +86,20 @@ CSRC = $(UTILSRC) \
$(CONTROLLERS_MATH_SRC) \
$(CONTROLLERS_SENSORS_SRC) \
$(ENGINES_SRC) \
$(PROJECT_DIR)/controllers/trigger/trigger_mazda.c \
$(PROJECT_DIR)/controllers/trigger/trigger_structure.c \
$(TEST_SRC_C)
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CPPSRC = $(UTILSRC_CPP) \
$(CONTROLLERS_ALGO_SRC_CPP) \
$(PROJECT_DIR)/controllers/trigger/trigger_mazda.cpp \
$(PROJECT_DIR)/controllers/trigger/trigger_chrysler.cpp \
$(PROJECT_DIR)/controllers/trigger/trigger_gm.cpp \
$(PROJECT_DIR)/controllers/trigger/trigger_decoder.cpp \
$(PROJECT_DIR)/controllers/trigger/trigger_structure.cpp \
$(ENGINES_SRC_CPP) \
$(CONTROLLERS_MATH_SRC_CPP) \
$(CONTROLLERS_SENSORS_SRC_CPP) \
$(TEST_SRC_CPP) \
main.cpp

View File

@ -16,5 +16,7 @@
#define EFI_SUPPORT_FORD_FIESTA TRUE
#define EFI_SUPPORT_NISSAN_PRIMERA TRUE
#define EFI_SIGNAL_EXECUTOR_ONE_TIMER TRUE
#endif /* EFIFEATURES_H_ */

View File

@ -14,6 +14,8 @@
#include "main.h"
#include "error_handling.h"
#include "ec2.h"
extern "C"
{
@ -23,7 +25,6 @@ extern "C"
#include "test_interpolation_3d.h"
#include "test_find_index.h"
#include "test_fuel_map.h"
#include "test_engine_math.h"
#include "test_event_registry.h"
#include "test_sensors.h"
#include "test_signal_executor.h"
@ -32,6 +33,7 @@ extern "C"
#include "engine_math.h"
}
#include "test_engine_math.h"
#include "test_trigger_decoder.h"
static engine_configuration_s ec;
@ -45,7 +47,7 @@ uint64_t getTimeNowUs(void) {
return 0;
}
void assertEqualsM(char *msg, float expected, float actual) {
void assertEqualsM(const char *msg, float expected, float actual) {
if (cisnan(actual) && !cisnan(expected)) {
printf("Unexpected: %s %.4f while expected %.4f\r\n", msg, actual, expected);
exit(-1);
@ -64,7 +66,7 @@ void assertEquals(float expected, float actual) {
assertEqualsM("", expected, actual);
}
void assertTrueM(char *msg, float actual) {
void assertTrueM(const char *msg, float actual) {
assertEqualsM(msg, TRUE, actual);
}
@ -72,7 +74,7 @@ void assertTrue(float actual) {
assertTrueM("", actual);
}
void assertFalseM(char *msg, float actual) {
void assertFalseM(const char *msg, float actual) {
assertEqualsM(msg, FALSE, actual);
}
@ -117,7 +119,7 @@ int main(void) {
testPinHelper();
testSetTableValue();
printf("Success 20130422\r\n");
printf("Success 20130429\r\n");
// resizeMap();

View File

@ -40,12 +40,12 @@ void print(const char *fmt, ...);
#define chDbgCheck(x, y) chDbgAssert(x, y, NULL)
void assertEqualsM(char *msg, float expected, float actual);
void assertEqualsM(const char *msg, float expected, float actual);
void assertEquals(float expected, float actual);
void assertTrue(float actual);
void assertTrueM(char *msg, float actual);
void assertTrueM(const char *msg, float actual);
void assertFalse(float actual);
void assertFalseM(char *msg, float actual);
void assertFalseM(const char *msg, float actual);
float getIntakeAirTemperature(void);
float getCoolantTemperature(void);

View File

@ -1,5 +1,4 @@
TEST_SRC_C = boards.c \
test_data_structures/test_engine_math.c \
test_basic_math/test_find_index.c \
test_basic_math/test_interpolation_3d.c \
test_idle_controller.c \
@ -7,6 +6,7 @@ TEST_SRC_C = boards.c \
TEST_SRC_CPP = test_util.cpp \
test_data_structures/test_event_registry.cpp \
test_data_structures/test_engine_math.cpp \
test_trigger_decoder.cpp \
test_fuel_map.cpp \
test_signal_executor.cpp

View File

@ -1,56 +0,0 @@
/*
* test_event_registry.c
*
* Created on: Nov 27, 2013
* Author: Andrey Belomutskiy, (c) 2012-2013
*/
#include "event_registry.h"
#include "test_event_registry.h"
#include "main.h"
static ActuatorEventList eventList;
static ActuatorEventList result;
int pinDefaultState[IO_PIN_COUNT];
void initOutputSignal(OutputSignal *signal, io_pin_e ioPin) {
signal->io_pin = ioPin;
}
extern int outputSignalCount;
void testEventRegistry(void) {
printf("*************************************** testEventRegistry\r\n");
printf("resetting\r\n");
resetEventList(&eventList);
resetOutputSignals();
printf("registering 0\r\n");
registerActuatorEvent(&eventList, 0, addOutputSignal(10), 0);
registerActuatorEvent(&eventList, 0, addOutputSignal(20), 10);
assertEquals(2, eventList.size);
printf("registering 1\r\n");
registerActuatorEvent(&eventList, 1, addOutputSignal(30), 0);
registerActuatorEvent(&eventList, 1, addOutputSignal(40), 10);
assertEquals(4, eventList.size);
printf("Looking for 0\r\n");
findEvents(0, &eventList, &result);
assertEquals(2, result.size);
assertEquals(4, eventList.size);
printf("Validating pins\r\n");
assertEquals(10, result.events[0].actuator->io_pin);
assertEquals(20, result.events[1].actuator->io_pin);
printf("Looking for 1\r\n");
findEvents(1, &eventList, &result);
assertEquals(2, result.size);
assertEquals(4, eventList.size);
assertEquals(30, result.events[0].actuator->io_pin);
assertEquals(40, result.events[1].actuator->io_pin);
}

View File

@ -1,27 +0,0 @@
/*
* @file test_engine_math.c
*
* Created on: Nov 14, 2013
* Author: Andrey Belomutskiy, (c) 2012-2013
*/
#include "test_engine_math.h"
#include "main.h"
#include "engine_math.h"
#include "engine_configuration.h"
extern engine_configuration_s *engineConfiguration;
extern engine_configuration2_s *engineConfiguration2;
void testEngineMath(void) {
printf("*************************************************** testEngineMath\r\n");
engineConfiguration->rpmMultiplier = 0.5;
assertEqualsM("600 RPM", 5000, getOneDegreeTime(600) * 180);
assertEqualsM("6000 RPM", 500, getOneDegreeTime(6000) * 180);
}
float getMap(void) {
return 0;
}

View File

@ -1,150 +0,0 @@
/**
* @file test_fuel_map.c
*
* Created on: Nov 6, 2013
* Author: Andrey Belomutskiy, (c) 2012-2013
*/
#include "main.h"
#include "engine_configuration.h"
#include "fuel_math.h"
#include "trigger_structure.h"
#include "allsensors.h"
#include "engine_math.h"
extern engine_configuration_s *engineConfiguration;
extern engine_configuration2_s *engineConfiguration2;
void testFuelMap(void) {
chDbgCheck(engineConfiguration!=NULL, "engineConfiguration");
printf("*************************************************** testFuelMap\r\n");
for (int k = 0; k < FUEL_LOAD_COUNT; k++) {
for (int r = 0; r < FUEL_RPM_COUNT; r++) {
engineConfiguration->fuelTable[k][r] = k * 200 + r;
}
}
printf("*************************************************** initThermistors\r\n");
initThermistors();
printf("*** getInjectorLag\r\n");
assertEquals(0, getInjectorLag(12));
for (int i = 0; i < FUEL_LOAD_COUNT; i++)
engineConfiguration->fuelLoadBins[i] = i;
for (int i = 0; i < FUEL_RPM_COUNT; i++)
engineConfiguration->fuelRpmBins[i] = i;
printf("*************************************************** prepareFuelMap\r\n");
prepareFuelMap();
assertEquals(1005, getBaseFuel(5, 5));
engineConfiguration->injectorLag = 0.5;
for (int i = 0; i < VBAT_INJECTOR_CURVE_SIZE; i++) {
engineConfiguration->battInjectorLagCorrBins[i] = i;
engineConfiguration->battInjectorLagCorr[i] = 2 * i;
}
// because all the correction tables are zero
printf("*************************************************** getRunningFuel\r\n");
assertEquals(1005.5, getRunningFuel(5, 5));
printf("*************************************************** setting IAT table\r\n");
for (int i = 0; i < IAT_CURVE_SIZE; i++) {
engineConfiguration->iatFuelCorrBins[i] = i;
engineConfiguration->iatFuelCorr[i] = 2 * i;
}
engineConfiguration->iatFuelCorr[0] = 2;
printf("*************************************************** setting CLT table\r\n");
for (int i = 0; i < CLT_CURVE_SIZE; i++) {
engineConfiguration->cltFuelCorrBins[i] = i;
engineConfiguration->cltFuelCorr[i] = 1;
}
engineConfiguration->injectorLag = 0;
assertEquals(NAN, getIntakeAirTemperature());
float iatCorrection = getIatCorrection(-KELV);
assertEqualsM("IAT", 2, iatCorrection);
float cltCorrection = getCltCorrection(getCoolantTemperature());
assertEqualsM("CLT", 1, cltCorrection);
float injectorLag = getInjectorLag(getVBatt());
assertEquals(0, injectorLag);
// 1005 * 2 for IAT correction
printf("*************************************************** getRunningFuel\r\n");
assertEquals(1005, getRunningFuel(5, 5));
engineConfiguration->crankingSettings.coolantTempMaxC = 65; // 8ms at 65C
engineConfiguration->crankingSettings.fuelAtMaxTempMs = 8;
engineConfiguration->crankingSettings.coolantTempMinC = 0; // 20ms at 0C
engineConfiguration->crankingSettings.fuelAtMinTempMs = 20;
printf("*************************************************** getStartingFuel\r\n");
// NAN in case we have issues with the CLT sensor
// assertEquals(16, getStartingFuel(NAN));
assertEquals(20, getStartingFuel(0));
assertEquals(18.5231, getStartingFuel(8));
assertEquals(8, getStartingFuel(70));
}
static void confgiureFordAspireTriggerShape(trigger_shape_s * s) {
triggerShapeInit(s);
triggerAddEvent(s, 53.747, T_SECONDARY, 1);
triggerAddEvent(s, 121.90, T_SECONDARY, 0);
triggerAddEvent(s, 232.76, T_SECONDARY, 1);
triggerAddEvent(s, 300.54, T_SECONDARY, 0);
triggerAddEvent(s, 360, T_PRIMARY, 1);
triggerAddEvent(s, 409.8412, T_SECONDARY, 1);
triggerAddEvent(s, 478.6505, T_SECONDARY, 0);
triggerAddEvent(s, 588.045, T_SECONDARY, 1);
triggerAddEvent(s, 657.03, T_SECONDARY, 0);
triggerAddEvent(s, 720, T_PRIMARY, 0);
}
static ActuatorEventList ae;
extern int outputSignalCount;
void testAngleResolver(void) {
printf("*************************************************** testAngleResolver\r\n");
engineConfiguration->globalTriggerAngleOffset = 175;
trigger_shape_s * ts = &engineConfiguration2->triggerShape;
confgiureFordAspireTriggerShape(ts);
assertEqualsM("shape size", 10, ts->size);
resetOutputSignals();
resetEventList(&ae);
printf("*************************************************** testAngleResolver 0\r\n");
registerActuatorEventExt(engineConfiguration, &engineConfiguration2->triggerShape, &ae, addOutputSignal(INJECTOR_1_OUTPUT), 53 - 175);
assertEquals(1, ae.size);
assertEquals(1, outputSignalCount);
assertEquals(0, ae.events[0].eventIndex);
assertEquals(53, ae.events[0].angleOffset);
printf("*************************************************** testAngleResolver 2\r\n");
resetEventList(&ae);
registerActuatorEventExt(engineConfiguration, &engineConfiguration2->triggerShape, &ae, addOutputSignal(INJECTOR_1_OUTPUT), 51 + 180 - 175);
assertEquals(2, ae.events[0].eventIndex);
assertEquals(51.9870, ae.events[0].angleOffset);
}
void testPinHelper(void) {
printf("*************************************************** testPinHelper\r\n");
assertEquals(0, getElectricalValue(0, OM_DEFAULT));
assertEquals(1, getElectricalValue(1, OM_DEFAULT));
assertEquals(0, getElectricalValue(1, OM_INVERTED));
assertEquals(1, getElectricalValue(0, OM_INVERTED));
}

View File

@ -1,69 +0,0 @@
/**
* @file test_signal_executor.c
*
* @date Nov 28, 2013
* @author Andrey Belomutskiy, (c) 2012-2013
*/
#include <time.h>
#include "main.h"
#include "signal_executor.h"
#include "signal_executor_single_timer_algo.h"
#include "test_signal_executor.h"
#include "io_pins.h"
#include "utlist.h"
extern OutputSignal *st_output_list;
static io_pin_e testLastToggledPin;
static int testToggleCounter;
void setOutputPinValue(io_pin_e pin, int value) {
// this is a test implementation of the method - we use it to see what's going on
testLastToggledPin = pin;
testToggleCounter++;
}
void scheduleTask(scheduling_s *scheduling, int delay, schfunc_t callback, void *param) {
}
void testSignalExecutor() {
print("*************************************** testSignalExecutor\r\n");
// OutputSignal s1;
// OutputSignal s2;
//
// registerSignal(&s1);
// registerSignal(&s2);
//
// OutputSignal *out;
// int count;
// LL_COUNT(st_output_list, out, count);
// assertEquals(2, count);
//
// s1.io_pin = 0;
// initOutputSignalBase(&s1);
// assertEqualsM("status", IDLE, s1.status);
// scheduleOutputBase(&s1, 10, 100);
//
// long now = 1;
// print("now = 1\r\n");
// testToggleCounter = 0;
// assertEqualsM("duration", 10, GET_DURATION(&s1));
// assertEquals(9, toggleSignalIfNeeded(&s1, now));
// assertEquals(0, testToggleCounter);
//
// now = 100;
// print("now = 100\r\n");
// testToggleCounter = 0;
// assertEquals(100, toggleSignalIfNeeded(&s1, now));
// assertEquals(1, testToggleCounter);
//
// print("now = 300\r\n");
// now = 300; // let's see what happens if the handler is late
// testToggleCounter = 0;
// assertEquals(10, toggleSignalIfNeeded(&s1, now));
// assertEquals(1, testToggleCounter);
}

View File

@ -1,245 +0,0 @@
/**
* @file test_trigger_decoder.c
*
* @date Dec 24, 2013
* @author Andrey Belomutskiy, (c) 2012-2013
*/
#include "main.h"
#include "test_trigger_decoder.h"
#include "trigger_decoder.h"
#include "engine_math.h"
#include "ford_aspire.h"
#include "dodge_neon.h"
#include "ford_1995_inline_6.h"
#include "mazda_323.h"
void sendOutConfirmation(char *value, int i) {
// test implementation
}
static void testDodgeNeonDecoder(void) {
printf("*************************************************** testDodgeNeonDecoder\r\n");
initTriggerDecoder();
engine_configuration_s ec;
engine_configuration2_s ec2;
resetConfigurationExt(DODGE_NEON_1995, &ec, &ec2);
trigger_shape_s * shape = &ec2.triggerShape;
trigger_state_s state;
clearTriggerState(&state);
assertFalseM("1 shaft_is_synchronized", state.shaft_is_synchronized);
int r = 0;
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, r + 60);
assertFalseM("2 shaft_is_synchronized", state.shaft_is_synchronized); // still no synchronization
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, r + 210);
assertFalseM("3 shaft_is_synchronized", state.shaft_is_synchronized); // still no synchronization
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, r + 420);
assertFalseM("4 shaft_is_synchronized", state.shaft_is_synchronized); // still no synchronization
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, r + 630);
assertFalse(state.shaft_is_synchronized); // still no synchronization
printf("2nd camshaft revolution\r\n");
r = 720;
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, r + 60);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, r + 210);
assertTrue(state.shaft_is_synchronized);
assertEquals(0, state.current_index);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, r + 420);
assertEquals(1, state.current_index);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, r + 630);
assertEquals(2, state.current_index);
printf("3rd camshaft revolution\r\n");
r = 2 * 720;
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, r + 60);
assertEqualsM("current index", 3, state.current_index);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, r + 210);
assertTrue(state.shaft_is_synchronized);
assertEqualsM("current index", 0, state.current_index);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, r + 420);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, r + 630);
}
static void test1995FordInline6TriggerDecoder(void) {
printf("*************************************************** test1995FordInline6TriggerDecoder\r\n");
initTriggerDecoder();
resetOutputSignals();
engine_configuration_s ec;
engine_configuration2_s ec2;
resetConfigurationExt(FORD_INLINE_6_1995, &ec, &ec2);
ActuatorEventList *ecl = &ec2.engineEventConfiguration.ignitionEvents;
assertEqualsM("ignition events size", 6, ecl->size);
assertEqualsM("event index", 0, ecl->events[0].eventIndex);
assertEquals(13, ecl->events[0].angleOffset);
assertEqualsM("event index", 10, ecl->events[5].eventIndex);
assertEquals(13, ecl->events[5].angleOffset);
trigger_state_s state;
clearTriggerState(&state);
trigger_shape_s * shape = &ec2.triggerShape;
assertFalseM("shaft_is_synchronized", state.shaft_is_synchronized);
int r = 0;
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, r + 10);
assertFalseM("shaft_is_synchronized", state.shaft_is_synchronized); // still no synchronization
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, r + 11);
assertTrue(state.shaft_is_synchronized); // first signal rise synchronize
assertEquals(0, state.current_index);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, r++);
assertEquals(1, state.current_index);
for (int i = 2; i < 10;) {
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, r++);
assertEqualsM("even", i++, state.current_index);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, r++);
assertEqualsM("odd", i++, state.current_index);
}
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, r++);
assertEquals(10, state.current_index);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, r++);
assertEquals(11, state.current_index);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, r++);
assertEquals(0, state.current_index); // new revolution
assertEqualsM("running dwell", 0.5, getSparkDwellMsT(&ec, 2000));
}
void testFordAspire(void) {
printf("*************************************************** testTriggerDecoder\r\n");
engine_configuration_s ec;
engine_configuration2_s ec2;
resetConfigurationExt(FORD_ASPIRE_1996, &ec, &ec2);
assertEqualsM("cranking dwell", 54.166670, getSparkDwellMsT(&ec, 200));
assertEqualsM("running dwell", 4, getSparkDwellMsT(&ec, 2000));
assertEqualsM("higher rpm dwell", 3.25, getSparkDwellMsT(&ec, 6000));
}
void testMazda323(void) {
printf("*************************************************** testMazda323\r\n");
engine_configuration_s ec;
engine_configuration2_s ec2;
resetConfigurationExt(MAZDA_323, &ec, &ec2);
}
void testMazdaMianaNbDecoder(void) {
printf("*************************************************** testMazdaMianaNbDecoder\r\n");
engine_configuration_s ec;
engine_configuration2_s ec2;
resetConfigurationExt(MAZDA_MIATA_NB, &ec, &ec2);
trigger_state_s state;
clearTriggerState(&state);
trigger_shape_s * shape = &ec2.triggerShape;
int a = 0;
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, a + 20);
assertFalseM("0a shaft_is_synchronized", state.shaft_is_synchronized);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, a + 340);
assertFalseM("0b shaft_is_synchronized", state.shaft_is_synchronized);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, a + 360);
assertFalseM("0c shaft_is_synchronized", state.shaft_is_synchronized);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, a + 380);
assertFalseM("0d shaft_is_synchronized", state.shaft_is_synchronized);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, a + 400);
assertTrueM("0e shaft_is_synchronized", state.shaft_is_synchronized);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, a + 720);
assertTrueM("0f shaft_is_synchronized", state.shaft_is_synchronized);
a = 720;
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, a + 20);
assertTrueM("1a shaft_is_synchronized", state.shaft_is_synchronized);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, a + 340);
assertTrueM("1b shaft_is_synchronized", state.shaft_is_synchronized);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, a + 360);
assertTrueM("1c shaft_is_synchronized", state.shaft_is_synchronized);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, a + 380);
assertTrueM("1d shaft_is_synchronized", state.shaft_is_synchronized);
assertEquals(5, state.current_index);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, a + 400);
assertTrueM("1e shaft_is_synchronized", state.shaft_is_synchronized);
assertEquals(0, state.current_index);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, a + 720);
assertTrueM("1f shaft_is_synchronized", state.shaft_is_synchronized);
}
void testGY6_139QMB(void) {
printf("*************************************************** testGY6_139QMB\r\n");
engine_configuration_s ec;
engine_configuration2_s ec2;
resetConfigurationExt(GY6_139QMB, &ec, &ec2);
trigger_state_s state;
clearTriggerState(&state);
assertFalseM("shaft_is_synchronized", state.shaft_is_synchronized);
trigger_shape_s * shape = &ec2.triggerShape;
assertFalseM("shaft_is_synchronized", state.shaft_is_synchronized);
assertEquals(0, state.current_index);
int now = 0;
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_UP, now++);
assertTrueM("shaft_is_synchronized", state.shaft_is_synchronized);
assertEquals(0, state.current_index);
processTriggerEvent(&state, shape, &ec.triggerConfig, SHAFT_PRIMARY_DOWN, now++);
assertTrueM("shaft_is_synchronized", state.shaft_is_synchronized);
assertEquals(1, state.current_index);
}
void testTriggerDecoder(void) {
printf("*************************************************** testTriggerDecoder\r\n");
engine_configuration2_s ec2;
initializeSkippedToothTriggerShapeExt(&ec2, 2, 0);
assertEquals(ec2.triggerShape.size, 4);
assertEquals(ec2.triggerShape.wave.switchTimes[0], 0.25);
assertEquals(ec2.triggerShape.wave.switchTimes[1], 0.5);
assertEquals(ec2.triggerShape.wave.switchTimes[2], 0.75);
assertEquals(ec2.triggerShape.wave.switchTimes[3], 1);
testDodgeNeonDecoder();
testFordAspire();
test1995FordInline6TriggerDecoder();
testMazdaMianaNbDecoder();
testGY6_139QMB();
testMazda323();
}

View File

@ -21,7 +21,7 @@ endif
# C++ specific options here (added to USE_OPT).
ifeq ($(USE_CPPOPT),)
USE_CPPOPT = -fno-rtti -fpermissive -fno-exceptions -fno-use-cxa-atexit
USE_CPPOPT = -std=c++11 -fno-rtti -fpermissive -fno-exceptions -fno-use-cxa-atexit
endif
# Enable this if you want the linker to remove unused code and data
@ -109,7 +109,6 @@ CSRC = ${PORTSRC} \
${CHIBIOS}/os/various/chprintf.c \
${CHIBIOS}/os/various/memstreams.c \
$(UTILSRC) \
simulator/rusEfiFunctionalTest.c \
simulator/boards.c \
$(PROJECT_DIR)/emulation/analog_chart.c \
main.c
@ -121,8 +120,11 @@ CPPSRC = $(UTILSRC_CPP) \
$(PROJECT_DIR)/controllers/settings.cpp \
$(TRIGGER_SRC_CPP) \
$(SYSTEMSRC_CPP) \
$(CONSOLE_SRC_CPP) \
$(CONTROLLERS_SENSORS_SRC_CPP) \
$(CONTROLLERS_MATH_SRC_CPP) \
$(ENGINES_SRC_CPP) \
$(PROJECT_DIR)/simulator/rusEfiFunctionalTest.cpp \
$(TEST_SRC_CPP)
# C sources to be compiled in ARM mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler

View File

@ -1,2 +0,0 @@
make clean
compile.bat 2> err > log

View File

@ -1,45 +0,0 @@
#include <ch.h>
#include <hal.h>
#include <time.h>
#include <math.h>
#ifndef GLOBAL_FT_H_
#define GLOBAL_FT_H_
#define EFI_SIMULATOR TRUE
#define EFI_SUPPORT_DODGE_NEON TRUE
#define EFI_SUPPORT_FORD_ASPIRE TRUE
#define EFI_SUPPORT_FORD_FIESTA TRUE
#define EFI_SUPPORT_NISSAN_PRIMERA TRUE
#define EFI_SUPPORT_1995_FORD_INLINE_6 TRUE
#define EFI_SIGNAL_EXECUTOR_SLEEP TRUE
#define EFI_WAVE_CHART TRUE
#include "eficonsole_logic.h"
#include "rusefi_enums.h"
#define EFI_CUSTOM_PANIC_METHOD 1
// project-wide default thread stack size
#define UTILITY_THREAD_STACK_SIZE 1384
/**
* @brief @p Win32TestStream virtual methods table.
*/
struct Win32TestStreamVMT {
_base_sequential_stream_methods
};
typedef struct {
const struct Win32TestStreamVMT *vmt;
} TestStream;
extern TestStream testStream;
//##define TRUE 1
//#define FALSE 0
#endif /* GLOBAL_FT_H_ */

View File

@ -1,6 +0,0 @@
rm build/rusefi_simulator.exe
make
cd build
rusefi_simulator.exe

View File

@ -1,174 +0,0 @@
/**
* @file rusEfiFunctionalTest.c
*
* @date Mar 1, 2014
* @author Andrey Belomutskiy, (c) 2012-2013
*/
#include "global.h"
#include "rusEfiFunctionalTest.h"
#include "eficonsole.h"
#include "engine_configuration.h"
#include "rusefi_enums.h"
#include "pwm_generator_logic.h"
#include "wave_math.h"
#include "boards.h"
#include "trigger_central.h"
#include "datalogging.h"
#include "algo.h"
#include "rpm_calculator.h"
#include "wave_chart.h"
#include "status_loop.h"
#include "trigger_emulator_algo.h"
#include "main_trigger_callback.h"
#include "allsensors.h"
#include "analog_chart.h"
extern WaveChart waveChart;
static persistent_config_s config;
static engine_configuration2_s ec2;
engine_configuration_s * engineConfiguration = &config.engineConfiguration;
board_configuration_s *boardConfiguration = &config.boardConfiguration;
engine_configuration2_s *engineConfiguration2 = &ec2;
void setOutputPinValue(io_pin_e pin, int logicValue) {
}
int isInjectionEnabled(void) {
return TRUE;
}
//void initOutputSignal(OutputSignal *signal, io_pin_e ioPin) {
//
//}
void idleDebug(char *msg, int value) {
}
float getMap(void) {
return 0;
}
static int primaryWheelState = FALSE;
static int secondaryWheelState = FALSE;
static void triggerEmulatorCallback(PwmConfig *state, int stateIndex) {
int newPrimaryWheelState = state->multiWave.waves[0].pinStates[stateIndex];
int newSecondaryWheelState = state->multiWave.waves[1].pinStates[stateIndex];
if (primaryWheelState != newPrimaryWheelState) {
primaryWheelState = newPrimaryWheelState;
hwHandleShaftSignal(primaryWheelState ? SHAFT_PRIMARY_UP : SHAFT_PRIMARY_DOWN);
}
if (secondaryWheelState != newSecondaryWheelState) {
secondaryWheelState = newSecondaryWheelState;
hwHandleShaftSignal(secondaryWheelState ? SHAFT_SECONDARY_UP : SHAFT_SECONDARY_DOWN);
}
// print("hello %d\r\n", chTimeNow());
}
void rusEfiFunctionalTest(void) {
initializeConsole();
initFakeBoard();
initStatusLoop();
resetConfigurationExt(FORD_ASPIRE_1996, engineConfiguration, engineConfiguration2, boardConfiguration);
initThermistors();
initAlgo();
initRpmCalculator();
initAnalogChart();
initTriggerEmulatorLogic(triggerEmulatorCallback);
initMainEventListener();
initTriggerCentral();
}
void printPendingMessages(void) {
printPending();
if (getFullLog()) {
printState(getCrankEventCounter());
finishStatusLine();
publishChartIfFull(&waveChart);
}
}
static size_t wt_writes(void *ip, const uint8_t *bp, size_t n) {
printToWin32Console((char*)bp);
return DELEGATE->vmt->write(DELEGATE, bp, n);
}
static size_t wt_reads(void *ip, uint8_t *bp, size_t n) {
return DELEGATE->vmt->read(DELEGATE, bp, n);
}
static char putMessageBuffer[2];
static msg_t wt_put(void *ip, uint8_t b) {
putMessageBuffer[0] = b;
putMessageBuffer[1] = 0;
printToWin32Console((char*)putMessageBuffer);
// cputs("wt_put");
return DELEGATE->vmt->put(DELEGATE, b);
}
static msg_t wt_get(void *ip) {
// cputs("wt_get");
//return 0;
return DELEGATE->vmt->get(DELEGATE);
}
static const struct Win32TestStreamVMT vmt = { wt_writes, wt_reads, wt_put, wt_get };
void initTestStream(TestStream *ts) {
ts->vmt = &vmt;
}
int isSerialOverTcpReady;
int is_serial_ready(void) {
return isSerialOverTcpReady;
}
void onFatalError(const char *msg, char * file, int line) {
printf("onFatalError %s %s%d", msg, file, line);
exit(-1);
}
int warning(obd_code_e code, const char *fmt, ...) {
printf("Warning: %s\r\n", fmt);
return 0;
}
void firmwareError(const char *fmt, ...) {
fatal3((char*)fmt, __FILE__, __LINE__);
}
int hasFatalError(void) {
return false;
}
void chDbgPanic3(const char *msg, char * file, int line) {
onFatalError(msg, file, line);
}
uint64_t getTimeNowUs(void) {
return chTimeNow() * (1000000 / CH_FREQUENCY);
}
int getRusEfiVersion(void) {
return 239;
}

View File

@ -8,8 +8,17 @@
#ifndef RUSEFIFUNCTIONALTEST_H_
#define RUSEFIFUNCTIONALTEST_H_
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
void rusEfiFunctionalTest(void);
void initTestStream(TestStream *ts);
void printPendingMessages(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* RUSEFIFUNCTIONALTEST_H_ */

View File

@ -1,2 +0,0 @@
int getRusEfiVersion(void);