163 lines
3.6 KiB
C++
163 lines
3.6 KiB
C++
/**
|
|
* @file rusEfiFunctionalTest.cpp
|
|
*
|
|
* @date Mar 1, 2014
|
|
* @author Andrey Belomutskiy, (c) 2012-2015
|
|
*/
|
|
|
|
#include "global.h"
|
|
#include "boards.h"
|
|
#include "rusEfiFunctionalTest.h"
|
|
#include "console_io.h"
|
|
#include "eficonsole.h"
|
|
#include "engine_configuration.h"
|
|
#include "rusefi_enums.h"
|
|
#include "pwm_generator_logic.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"
|
|
#include "injector_central.h"
|
|
#include "engine.h"
|
|
#include "tunerstudio.h"
|
|
#include "trigger_emulator.h"
|
|
#include "engine_controller.h"
|
|
|
|
EXTERN_ENGINE;
|
|
extern engine_configuration2_s * engineConfiguration2;
|
|
|
|
extern WaveChart waveChart;
|
|
|
|
uint32_t maxLockTime = 0;
|
|
|
|
// todo: move this field to trigger_central
|
|
bool isInsideTriggerHandler;
|
|
|
|
//persistent_config_container_s persistentState;
|
|
//static engine_configuration2_s ec2;
|
|
|
|
static LoggingWithStorage sharedLogger("simulator");
|
|
|
|
//engine_configuration_s * engineConfiguration = &persistentState.persistentConfiguration.engineConfiguration;
|
|
//board_configuration_s *boardConfiguration = &persistentState.persistentConfiguration.engineConfiguration.bc;
|
|
//engine_configuration2_s *engineConfiguration2 = &ec2;
|
|
|
|
void outputPinRegisterExt2(const char *msg, OutputPin *output, brain_pin_e brainPin, pin_output_mode_e *outputMode) {
|
|
}
|
|
|
|
//int isInjectionEnabled(void) {
|
|
// return true;
|
|
//}
|
|
|
|
int getRemainingStack(Thread *otp) {
|
|
return 99999;
|
|
}
|
|
|
|
void idleDebug(const char *msg, percent_t value) {
|
|
}
|
|
|
|
float getMap(void) {
|
|
return getRawMap();
|
|
}
|
|
|
|
void rusEfiFunctionalTest(void) {
|
|
initializeConsole(&sharedLogger);
|
|
|
|
initFakeBoard();
|
|
|
|
initStatusLoop(engine);
|
|
initDataStructures(PASS_ENGINE_PARAMETER_F);
|
|
|
|
engine->engineConfiguration2 = engineConfiguration2;
|
|
|
|
// todo: reduce code duplication with initEngineContoller
|
|
|
|
resetConfigurationExt(NULL, FORD_ESCORT_GT PASS_ENGINE_PARAMETER);
|
|
prepareShapes(PASS_ENGINE_PARAMETER_F);
|
|
|
|
initSensors(&sharedLogger PASS_ENGINE_PARAMETER);
|
|
|
|
initAlgo(&sharedLogger, engineConfiguration);
|
|
initConfigActions();
|
|
|
|
initRpmCalculator(engine);
|
|
|
|
#if EFI_ANALOG_CHART
|
|
initAnalogChart();
|
|
#endif /* EFI_ANALOG_CHART */
|
|
|
|
initTriggerEmulator(&sharedLogger, engine);
|
|
|
|
initMainEventListener(&sharedLogger, engine);
|
|
|
|
initTriggerCentral(&sharedLogger, engine);
|
|
|
|
startStatusThreads(engine);
|
|
|
|
#if EFI_TUNER_STUDIO
|
|
if (engineConfiguration->isTunerStudioEnabled) {
|
|
startTunerStudioConnectivity();
|
|
}
|
|
#endif
|
|
|
|
initPeriodicEvents(engine);
|
|
}
|
|
|
|
void printPendingMessages(void) {
|
|
updateDevConsoleState(engine);
|
|
waveChart.publishChartIfFull();
|
|
}
|
|
|
|
int isSerialOverTcpReady;
|
|
|
|
int maxNesting = 0;
|
|
|
|
bool isConsoleReady(void) {
|
|
return isSerialOverTcpReady;
|
|
}
|
|
|
|
bool hasFirmwareErrorFlag = false;
|
|
|
|
void onFatalError(const char *msg, const char * file, int line) {
|
|
printf("onFatalError %s %s%d", msg, file, line);
|
|
exit(-1);
|
|
}
|
|
|
|
static time_t timeOfPreviousWarning = -10;
|
|
|
|
// todo: re-use primary firmware implementation?
|
|
int warning(obd_code_e code, const char *fmt, ...) {
|
|
int now = currentTimeMillis() / 1000;
|
|
if (absI(now - timeOfPreviousWarning) < 10)
|
|
return TRUE; // we just had another warning, let's not spam
|
|
timeOfPreviousWarning = now;
|
|
printf("Warning: %s\r\n", fmt);
|
|
return FALSE;
|
|
}
|
|
|
|
void firmwareError(const char *fmt, ...) {
|
|
printf("firmwareError [%s]\r\n", fmt);
|
|
|
|
va_list ap;
|
|
va_start(ap, fmt);
|
|
vprintf(fmt, ap);
|
|
va_end(ap);
|
|
|
|
|
|
exit(-1);
|
|
}
|
|
|
|
SerialDriver * getConsoleChannel(void) {
|
|
return (SerialDriver *)EFI_CONSOLE_UART_DEVICE;
|
|
}
|
|
|
|
void chDbgPanic3(const char *msg, const char * file, int line) {
|
|
onFatalError(msg, file, line);
|
|
}
|