mirror of https://github.com/rusefi/rusefi-1.git
make the simulator usable (#2717)
* these start themselves now * dead * configure ports * start serial * dead * minimal pins * simulator logging works * why not enable lua * speeeeeed * start lua * spammy print
This commit is contained in:
parent
8f03d1f938
commit
5a5f25244a
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
EXTERN_ENGINE;
|
EXTERN_ENGINE;
|
||||||
|
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE || EFI_SIMULATOR
|
||||||
size_t TsChannelBase::read(uint8_t* buffer, size_t size) {
|
size_t TsChannelBase::read(uint8_t* buffer, size_t size) {
|
||||||
return readTimeout(buffer, size, SR5_READ_TIMEOUT);
|
return readTimeout(buffer, size, SR5_READ_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE || EFI_SIMULATOR
|
||||||
#include "tunerstudio.h"
|
#include "tunerstudio.h"
|
||||||
#include "tunerstudio_io.h"
|
#include "tunerstudio_io.h"
|
||||||
#include "connector_uart_dma.h"
|
#include "connector_uart_dma.h"
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "rusefi_lua.h"
|
#include "rusefi_lua.h"
|
||||||
#include "thread_controller.h"
|
#include "thread_controller.h"
|
||||||
#include "perf_trace.h"
|
#include "perf_trace.h"
|
||||||
|
#include "thread_priority.h"
|
||||||
|
|
||||||
#if EFI_LUA
|
#if EFI_LUA
|
||||||
|
|
||||||
|
@ -10,7 +11,7 @@
|
||||||
|
|
||||||
#define TAG "LUA "
|
#define TAG "LUA "
|
||||||
|
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE || EFI_SIMULATOR
|
||||||
#include "ch.h"
|
#include "ch.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "tunerstudio_outputs.h"
|
#include "tunerstudio_outputs.h"
|
||||||
|
|
|
@ -83,7 +83,7 @@ static void doScheduleForLater(scheduling_s *scheduling, int delayUs, action_s a
|
||||||
|
|
||||||
#if EFI_SIMULATOR
|
#if EFI_SIMULATOR
|
||||||
if (action.getCallback() == (schfunc_t)&turnInjectionPinLow) {
|
if (action.getCallback() == (schfunc_t)&turnInjectionPinLow) {
|
||||||
printf("setTime cb=turnInjectionPinLow p=%d\r\n", (int)action.getArgument());
|
//printf("setTime cb=turnInjectionPinLow p=%d\r\n", (int)action.getArgument());
|
||||||
} else {
|
} else {
|
||||||
// printf("setTime cb=%d p=%d\r\n", (int)callback, (int)param);
|
// printf("setTime cb=%d p=%d\r\n", (int)callback, (int)param);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ void LogBuffer<TBufferSize>::writeInternal(const char* buffer) {
|
||||||
// for unit tests
|
// for unit tests
|
||||||
template class LogBuffer<10>;
|
template class LogBuffer<10>;
|
||||||
|
|
||||||
#if EFI_PROD_CODE && EFI_TEXT_LOGGING
|
#if (EFI_PROD_CODE || EFI_SIMULATOR) && EFI_TEXT_LOGGING
|
||||||
|
|
||||||
// This mutex protects the LogBuffer instances below
|
// This mutex protects the LogBuffer instances below
|
||||||
chibios_rt::Mutex logBufferMutex;
|
chibios_rt::Mutex logBufferMutex;
|
||||||
|
@ -167,12 +167,6 @@ void startLoggingProcessor() {
|
||||||
|
|
||||||
#endif // EFI_PROD_CODE
|
#endif // EFI_PROD_CODE
|
||||||
|
|
||||||
#if EFI_SIMULATOR
|
|
||||||
const char* swapOutputBuffers(size_t* actualOutputBufferSize) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if EFI_UNIT_TEST || EFI_SIMULATOR
|
#if EFI_UNIT_TEST || EFI_SIMULATOR
|
||||||
extern bool verboseMode;
|
extern bool verboseMode;
|
||||||
#endif
|
#endif
|
||||||
|
@ -189,7 +183,7 @@ void efiPrintfInternal(const char *format, ...) {
|
||||||
printf("\r\n");
|
printf("\r\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if EFI_PROD_CODE && EFI_TEXT_LOGGING
|
#if (EFI_PROD_CODE || EFI_SIMULATOR) && EFI_TEXT_LOGGING
|
||||||
for (unsigned int i = 0; i < strlen(format); i++) {
|
for (unsigned int i = 0; i < strlen(format); i++) {
|
||||||
// todo: open question which layer would not handle CR/LF properly?
|
// todo: open question which layer would not handle CR/LF properly?
|
||||||
efiAssertVoid(OBD_PCM_Processor_Fault, format[i] != '\n', "No CRLF please");
|
efiAssertVoid(OBD_PCM_Processor_Fault, format[i] != '\n', "No CRLF please");
|
||||||
|
@ -222,10 +216,6 @@ void efiPrintfInternal(const char *format, ...) {
|
||||||
// Push the buffer in to the written list so it can be written back
|
// Push the buffer in to the written list so it can be written back
|
||||||
chibios_rt::CriticalSectionLocker csl;
|
chibios_rt::CriticalSectionLocker csl;
|
||||||
|
|
||||||
if ((void*)lineBuffer == (void*)&filledBuffers) {
|
|
||||||
__asm volatile("BKPT #0\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
filledBuffers.postI(lineBuffer);
|
filledBuffers.postI(lineBuffer);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -239,7 +229,7 @@ void efiPrintfInternal(const char *format, ...) {
|
||||||
* This is a legacy function, most normal logging should use efiPrintf
|
* This is a legacy function, most normal logging should use efiPrintf
|
||||||
*/
|
*/
|
||||||
void scheduleLogging(Logging *logging) {
|
void scheduleLogging(Logging *logging) {
|
||||||
#if EFI_PROD_CODE && EFI_TEXT_LOGGING
|
#if (EFI_PROD_CODE || EFI_SIMULATOR) && EFI_TEXT_LOGGING
|
||||||
// Lock the buffer mutex - inhibit buffer swaps while writing
|
// Lock the buffer mutex - inhibit buffer swaps while writing
|
||||||
{
|
{
|
||||||
chibios_rt::MutexLocker lock(logBufferMutex);
|
chibios_rt::MutexLocker lock(logBufferMutex);
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "chprintf.h"
|
#include "chprintf.h"
|
||||||
#include "rusEfiFunctionalTest.h"
|
#include "rusEfiFunctionalTest.h"
|
||||||
#include "framework.h"
|
|
||||||
|
|
||||||
#define CONSOLE_WA_SIZE THD_WORKING_AREA_SIZE(4096)
|
#define CONSOLE_WA_SIZE THD_WORKING_AREA_SIZE(4096)
|
||||||
|
|
||||||
|
@ -31,8 +30,6 @@ void printToConsole(char *p) {
|
||||||
cputs(p);
|
cputs(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseChannel serialAdapterInstance;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Console print server done using synchronous messages. This makes the access
|
* Console print server done using synchronous messages. This makes the access
|
||||||
* to the C printf() thread safe and the print operation atomic among threads.
|
* to the C printf() thread safe and the print operation atomic among threads.
|
||||||
|
@ -136,9 +133,6 @@ bool verboseMode = true;
|
||||||
* Simulator main. *
|
* Simulator main. *
|
||||||
*------------------------------------------------------------------------*/
|
*------------------------------------------------------------------------*/
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
|
||||||
initTestStream(&serialAdapterInstance);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* System initializations.
|
* System initializations.
|
||||||
* - HAL initialization, this also initializes the configured device drivers
|
* - HAL initialization, this also initializes the configured device drivers
|
||||||
|
@ -149,12 +143,6 @@ int main(void) {
|
||||||
halInit();
|
halInit();
|
||||||
chSysInit();
|
chSysInit();
|
||||||
|
|
||||||
/*
|
|
||||||
* Serial ports (simulated) initialization.
|
|
||||||
*/
|
|
||||||
sdStart(&SD1, NULL);
|
|
||||||
sdStart(&SD2, NULL);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Console thread started.
|
* Console thread started.
|
||||||
*/
|
*/
|
||||||
|
@ -179,7 +167,7 @@ int main(void) {
|
||||||
while (!chThdShouldTerminateX()) {
|
while (!chThdShouldTerminateX()) {
|
||||||
chEvtDispatch(fhandlers, chEvtWaitOne(ALL_EVENTS));
|
chEvtDispatch(fhandlers, chEvtWaitOne(ALL_EVENTS));
|
||||||
printPendingMessages();
|
printPendingMessages();
|
||||||
chThdSleepMilliseconds(100);
|
chThdSleepMilliseconds(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -10,16 +10,6 @@
|
||||||
#define ADC_LOGIC_INTAKE_AIR 0
|
#define ADC_LOGIC_INTAKE_AIR 0
|
||||||
#define ADC_LOGIC_COOLANT 0
|
#define ADC_LOGIC_COOLANT 0
|
||||||
|
|
||||||
// see SIM_SD1_PORT
|
|
||||||
#define CONSOLE_PORT (&SD1)
|
|
||||||
// see SIM_SD2_PORT
|
|
||||||
//#define TS_PRIMARY_SERIAL SD2
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This implementation writes to both windows console and console port
|
|
||||||
*/
|
|
||||||
#define TS_PRIMARY_SERIAL (&serialAdapterInstance)
|
|
||||||
|
|
||||||
int getAdcValue(const char *msg, int channel);
|
int getAdcValue(const char *msg, int channel);
|
||||||
#define getSlowAdcCounter() 0
|
#define getSlowAdcCounter() 0
|
||||||
#define waitForSlowAdc(x) {}
|
#define waitForSlowAdc(x) {}
|
||||||
|
|
|
@ -9,13 +9,17 @@
|
||||||
|
|
||||||
#include "rusefi_true.h"
|
#include "rusefi_true.h"
|
||||||
|
|
||||||
|
// see SIM_SD1_PORT and SIM_SD2_PORT
|
||||||
|
#define TS_PRIMARY_SERIAL SD1
|
||||||
|
#define TS_SECONDARY_SERIAL SD2
|
||||||
|
|
||||||
#define EFI_ENABLE_ASSERTS TRUE
|
#define EFI_ENABLE_ASSERTS TRUE
|
||||||
#define EFI_LAUNCH_CONTROL FALSE
|
#define EFI_LAUNCH_CONTROL FALSE
|
||||||
#define EFI_ENABLE_MOCK_ADC TRUE
|
#define EFI_ENABLE_MOCK_ADC TRUE
|
||||||
|
|
||||||
#define ENABLE_PERF_TRACE FALSE
|
#define ENABLE_PERF_TRACE FALSE
|
||||||
|
|
||||||
#define EFI_PRINTF_FUEL_DETAILS TRUE
|
#define EFI_PRINTF_FUEL_DETAILS FALSE
|
||||||
#define EFI_ENABLE_CRITICAL_ENGINE_STOP TRUE
|
#define EFI_ENABLE_CRITICAL_ENGINE_STOP TRUE
|
||||||
#define EFI_ENABLE_ENGINE_WARNING TRUE
|
#define EFI_ENABLE_ENGINE_WARNING TRUE
|
||||||
|
|
||||||
|
@ -147,3 +151,5 @@
|
||||||
|
|
||||||
#define EFI_BOARD_TEST FALSE
|
#define EFI_BOARD_TEST FALSE
|
||||||
#define EFI_JOYSTICK FALSE
|
#define EFI_JOYSTICK FALSE
|
||||||
|
|
||||||
|
#define EFI_LUA TRUE
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "framework.h"
|
|
||||||
#include "efitime.h"
|
#include "efitime.h"
|
||||||
|
|
||||||
efitick_t getTimeNowNt(void) {
|
efitick_t getTimeNowNt(void) {
|
||||||
|
@ -20,70 +19,3 @@ uint32_t getTimeNowLowerNt(void) {
|
||||||
efitimeus_t getTimeNowUs(void) {
|
efitimeus_t getTimeNowUs(void) {
|
||||||
return chVTGetSystemTimeX() * (1000000 / CH_CFG_ST_FREQUENCY);
|
return chVTGetSystemTimeX() * (1000000 / CH_CFG_ST_FREQUENCY);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t wt_writes(void *ip, const uint8_t *bp, size_t n) {
|
|
||||||
printToConsole((char*)bp);
|
|
||||||
return CONSOLE_PORT->vmt->write(CONSOLE_PORT, bp, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t wt_reads(void *ip, uint8_t *bp, size_t n) {
|
|
||||||
return CONSOLE_PORT->vmt->read(CONSOLE_PORT, bp, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static msg_t wt_putt(void *instance, uint8_t b, systime_t time) {
|
|
||||||
return CONSOLE_PORT->vmt->putt(CONSOLE_PORT, b, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
static msg_t wt_gett(void *instance, systime_t time) {
|
|
||||||
return CONSOLE_PORT->vmt->gett(CONSOLE_PORT, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t wt_writet(void *instance, const uint8_t *bp,
|
|
||||||
size_t n, systime_t time) {
|
|
||||||
return CONSOLE_PORT->vmt->writet(CONSOLE_PORT, bp, n, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t wt_readt(void *instance, uint8_t *bp, size_t n, systime_t time) {
|
|
||||||
return CONSOLE_PORT->vmt->readt(CONSOLE_PORT, bp, n, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char putMessageBuffer[2];
|
|
||||||
|
|
||||||
static msg_t wt_put(void *ip, uint8_t b) {
|
|
||||||
putMessageBuffer[0] = b;
|
|
||||||
putMessageBuffer[1] = 0;
|
|
||||||
printToConsole((char*)putMessageBuffer);
|
|
||||||
// cputs("wt_put");
|
|
||||||
return CONSOLE_PORT->vmt->put(CONSOLE_PORT, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
static msg_t wt_get(void *ip) {
|
|
||||||
// cputs("wt_get");
|
|
||||||
//return 0;
|
|
||||||
return CONSOLE_PORT->vmt->get(CONSOLE_PORT);
|
|
||||||
}
|
|
||||||
|
|
||||||
static msg_t _ctl(void *ip, unsigned int operation, void *arg) {
|
|
||||||
|
|
||||||
(void)ip;
|
|
||||||
(void)operation;
|
|
||||||
(void)arg;
|
|
||||||
|
|
||||||
return MSG_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* These implementation print same content on console screen and send data over the underlying CONSOLE_PORT
|
|
||||||
* this is useful to see what's going on.
|
|
||||||
* See #wt_get() as a typical implementation
|
|
||||||
*/
|
|
||||||
static const struct BaseChannelVMT vmt = {
|
|
||||||
(size_t)0,
|
|
||||||
wt_writes, wt_reads, wt_put, wt_get,
|
|
||||||
wt_putt, wt_gett, wt_writet, wt_readt,
|
|
||||||
_ctl
|
|
||||||
};
|
|
||||||
|
|
||||||
void initTestStream(BaseChannel *ts) {
|
|
||||||
ts->vmt = &vmt;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
/**
|
|
||||||
* @file framework.h
|
|
||||||
*
|
|
||||||
* @date Sep 25, 2014
|
|
||||||
* @author Andrey Belomutskiy, (c) 2012-2014
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
void initTestStream(BaseChannel *ts);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
|
@ -46,8 +46,6 @@
|
||||||
// project-wide default thread stack size
|
// project-wide default thread stack size
|
||||||
#define UTILITY_THREAD_STACK_SIZE 1384
|
#define UTILITY_THREAD_STACK_SIZE 1384
|
||||||
|
|
||||||
extern BaseChannel serialAdapterInstance;
|
|
||||||
|
|
||||||
#define UNIT_TEST_BUSY_WAIT_CALLBACK() {}
|
#define UNIT_TEST_BUSY_WAIT_CALLBACK() {}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "map_averaging.h"
|
#include "map_averaging.h"
|
||||||
#include "memstreams.h"
|
#include "memstreams.h"
|
||||||
#include <chprintf.h>
|
#include <chprintf.h>
|
||||||
|
#include "rusefi_lua.h"
|
||||||
|
|
||||||
#define DEFAULT_SIM_RPM 1200
|
#define DEFAULT_SIM_RPM 1200
|
||||||
#define DEFAULT_SNIFFER_THR 2500
|
#define DEFAULT_SNIFFER_THR 2500
|
||||||
|
@ -102,7 +103,7 @@ void rusEfiFunctionalTest(void) {
|
||||||
|
|
||||||
// todo: reduce code duplication with initEngineContoller
|
// todo: reduce code duplication with initEngineContoller
|
||||||
|
|
||||||
resetConfigurationExt(FORD_ESCORT_GT PASS_ENGINE_PARAMETER_SUFFIX);
|
resetConfigurationExt(MINIMAL_PINS PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
enableTriggerStimulator();
|
enableTriggerStimulator();
|
||||||
|
|
||||||
commonInitEngineController();
|
commonInitEngineController();
|
||||||
|
@ -112,12 +113,18 @@ void rusEfiFunctionalTest(void) {
|
||||||
|
|
||||||
startStatusThreads();
|
startStatusThreads();
|
||||||
|
|
||||||
|
startLoggingProcessor();
|
||||||
|
|
||||||
runChprintfTest();
|
runChprintfTest();
|
||||||
|
|
||||||
initPeriodicEvents(PASS_ENGINE_PARAMETER_SIGNATURE);
|
initPeriodicEvents(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
setTriggerEmulatorRPM(DEFAULT_SIM_RPM PASS_ENGINE_PARAMETER_SUFFIX);
|
setTriggerEmulatorRPM(DEFAULT_SIM_RPM PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
engineConfiguration->engineSnifferRpmThreshold = DEFAULT_SNIFFER_THR;
|
engineConfiguration->engineSnifferRpmThreshold = DEFAULT_SNIFFER_THR;
|
||||||
|
|
||||||
|
startSerialChannels();
|
||||||
|
|
||||||
|
startLua();
|
||||||
}
|
}
|
||||||
|
|
||||||
void printPendingMessages(void) {
|
void printPendingMessages(void) {
|
||||||
|
@ -149,7 +156,3 @@ void logMsg(const char *format, ...) {
|
||||||
//
|
//
|
||||||
// fclose(fp);
|
// fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseChannel * getConsoleChannel(void) {
|
|
||||||
return (BaseChannel *)TS_PRIMARY_SERIAL;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue