rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures | Functions | Variables
tunerstudio.h File Reference

Detailed Description

Date
Aug 26, 2013
Author
Andrey Belomutskiy, (c) 2012-2020

Definition in file tunerstudio.h.

Data Structures

struct  tunerstudio_counters_s
 
struct  TunerStudioRWChunkRequest
 
struct  TunerStudioPageRWChunkRequest
 
class  TunerstudioThread
 

Functions

void tunerStudioDebug (TsChannelBase *tsChannel, const char *msg)
 
void tunerStudioError (TsChannelBase *tsChannel, const char *msg)
 
void sendErrorCode (TsChannelBase *tsChannel, uint8_t code, const char *msg="")
 
void requestBurn ()
 
int getSecondsSinceChannelsRequest ()
 
void updateTunerStudioState ()
 
bool isTuningVeNow ()
 
void startTunerStudioConnectivity ()
 
bool needToTriggerTsRefresh ()
 
void onApplyPreset ()
 
struct TunerStudioRWChunkRequest __attribute__ ((packed))
 
bool isTouchingArea (uint16_t offset, uint16_t count, int areaStart, int areaSize)
 

Variables

tunerstudio_counters_s tsState
 
uint16_t offset
 
uint16_t count
 
uint16_t page
 
TunerstudioThread __attribute__
 

Function Documentation

◆ __attribute__()

struct TunerStudioRWChunkRequest __attribute__ ( (packed)  )

Definition at line 38 of file tooth_logger.h.

40 {
41 // the whole order of all packet bytes is reversed, not just the 'endian-swap' integers
42 uint32_t timestamp;
43 // unfortunately all these fields are required by TS...
44 bool priLevel : 1;
45 bool secLevel : 1;
46 bool trigger : 1;
47 bool sync : 1;
48 bool coil : 1;
49 bool injector : 1;
static bool sync(void *instance)
composite_logger_s

◆ getSecondsSinceChannelsRequest()

int getSecondsSinceChannelsRequest ( )

Definition at line 15 of file tunerstudio_commands.cpp.

15 {
16 return channelsRequestTimer.getElapsedSeconds();
17}
static Timer channelsRequestTimer

Referenced by configureRusefiLuaHooks().

Here is the caller graph for this function:

◆ isTouchingArea()

bool isTouchingArea ( uint16_t  offset,
uint16_t  count,
int  areaStart,
int  areaSize 
)

Definition at line 283 of file tunerstudio.cpp.

283 {
284 if (offset + count < areaStart) {
285 // we are touching below for instance VE table
286 return false;
287 }
288 if (offset > areaStart + areaSize) {
289 // we are touching after for instance VE table
290 return false;
291 }
292 // else - we are touching it!
293 return true;
294}
uint16_t offset
Definition tunerstudio.h:0
uint16_t count
Definition tunerstudio.h:1

Referenced by isTouchingVe().

Here is the caller graph for this function:

◆ isTuningVeNow()

bool isTuningVeNow ( )

Definition at line 1039 of file tunerstudio.cpp.

1039 {
1041 !calibrationsVeWriteTimer.hasElapsedSec(TunerDetectorUtils::getUserEnteredTuningDetector());
1042}
static uint8_t getUserEnteredTuningDetector()
static bool isTuningDetectorUndefined()

Referenced by checkIfTuningVeNow(), and TpsAccelEnrichment::getTpsEnrichment().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ needToTriggerTsRefresh()

bool needToTriggerTsRefresh ( )

Definition at line 265 of file tunerstudio.cpp.

265 {
266 return !engine->engineTypeChangeTimer.hasElapsedSec(1);
267}
Timer engineTypeChangeTimer
Definition engine.h:309
static EngineAccessor engine
Definition engine.h:413

Referenced by handleBurnCommand(), TunerStudio::handleWriteChunkCommand(), and updateTunerStudioState().

Here is the caller graph for this function:

◆ onApplyPreset()

void onApplyPreset ( )

Definition at line 269 of file tunerstudio.cpp.

269 {
271}

Referenced by applyPreset().

Here is the caller graph for this function:

◆ requestBurn()

void requestBurn ( )

Definition at line 449 of file tunerstudio.cpp.

449 {
450#if !EFI_UNIT_TEST
452
453#if EFI_CONFIGURATION_STORAGE
455#endif /* EFI_CONFIGURATION_STORAGE */
456#endif // !EFI_UNIT_TEST
457}
void onBurnRequest()
void setNeedToWriteConfiguration()

Referenced by configureRusefiLuaHooks(), handleBurnCommand(), initFlash(), and unlockEcu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendErrorCode()

void sendErrorCode ( TsChannelBase tsChannel,
uint8_t  code,
const char msg = "" 
)

Definition at line 226 of file tunerstudio.cpp.

226 {
227 //TODO uncomment once I have test it myself
228 UNUSED(msg);
229 //if (msg != DO_NOT_LOG) {
230 // efiPrintf("TS <- Err: %d [%s]", code, msg);
231 //}
232
233 switch (code) {
234 case TS_RESPONSE_UNDERRUN:
236 break;
237 case TS_RESPONSE_OVERRUN:
239 break;
240 case TS_RESPONSE_CRC_FAILURE:
242 break;
243 case TS_RESPONSE_UNRECOGNIZED_COMMAND:
245 break;
246 case TS_RESPONSE_OUT_OF_RANGE:
248 break;
249 default:
251 break;
252 }
253
254 tsChannel->writeCrcResponse(code);
255}
uint8_t code
Definition bluetooth.cpp:40
void writeCrcResponse(uint8_t responseCode)
UNUSED(samplingTimeSeconds)
tunerstudio_counters_s tsState

Referenced by handleBurnCommand(), tsProcessOne(), and validateOffsetCount().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ startTunerStudioConnectivity()

void startTunerStudioConnectivity ( )

Definition at line 1044 of file tunerstudio.cpp.

1044 {
1045 // Assert tune & output channel struct sizes
1046 static_assert(sizeof(persistent_config_s) == TOTAL_CONFIG_SIZE, "TS datapage size mismatch");
1047 // useful trick if you need to know how far off is the static_assert
1048 //char (*__kaboom)[sizeof(persistent_config_s)] = 1;
1049 // another useful trick
1050 //static_assert(offsetof (engine_configuration_s,HD44780_e) == 700);
1051
1052 memset(&tsState, 0, sizeof(tsState));
1053
1054 addConsoleAction("tsinfo", printTsStats);
1055 addConsoleAction("reset_ts", resetTs);
1056 addConsoleActionI("set_ts_speed", setTsSpeed);
1057
1058#if EFI_BLUETOOTH_SETUP
1059 // module initialization start (it waits for disconnect and then communicates to the module)
1060 // Usage: "bluetooth_hc06 <baud> <name> <pincode>"
1061 // Example: "bluetooth_hc06 38400 rusefi 1234"
1062 // bluetooth_jdy 115200 alphax 1234
1063 addConsoleActionSSS("bluetooth_hc05", [](const char *baudRate, const char *name, const char *pinCode) {
1064 bluetoothStart(BLUETOOTH_HC_05, baudRate, name, pinCode);
1065 });
1066 addConsoleActionSSS("bluetooth_hc06", [](const char *baudRate, const char *name, const char *pinCode) {
1067 bluetoothStart(BLUETOOTH_HC_06, baudRate, name, pinCode);
1068 });
1069 addConsoleActionSSS("bluetooth_bk", [](const char *baudRate, const char *name, const char *pinCode) {
1070 bluetoothStart(BLUETOOTH_BK3231, baudRate, name, pinCode);
1071 });
1072 addConsoleActionSSS("bluetooth_jdy", [](const char *baudRate, const char *name, const char *pinCode) {
1073 bluetoothStart(BLUETOOTH_JDY_3x, baudRate, name, pinCode);
1074 });
1075 addConsoleActionSSS("bluetooth_jdy31", [](const char *baudRate, const char *name, const char *pinCode) {
1076 bluetoothStart(BLUETOOTH_JDY_31, baudRate, name, pinCode);
1077 });
1078#endif /* EFI_BLUETOOTH_SETUP */
1079}
void bluetoothStart(bluetooth_module_e moduleType, const char *baudRate, const char *name, const char *pinCode)
@ BLUETOOTH_HC_05
Definition bluetooth.h:22
@ BLUETOOTH_BK3231
Definition bluetooth.h:27
@ BLUETOOTH_JDY_3x
Definition bluetooth.h:29
@ BLUETOOTH_JDY_31
Definition bluetooth.h:30
@ BLUETOOTH_HC_06
Definition bluetooth.h:23
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
void addConsoleActionSSS(const char *token, VoidCharPtrCharPtrCharPtr callback)
void addConsoleActionI(const char *token, VoidInt callback)
Register a console command with one Integer parameter.
static void setTsSpeed(int value)
static void resetTs()
static void printTsStats(void)

Referenced by runRusEfi().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tunerStudioDebug()

void tunerStudioDebug ( TsChannelBase tsChannel,
const char msg 
)

Definition at line 163 of file tunerstudio.cpp.

163 {
164#if EFI_TUNER_STUDIO_VERBOSE
165 efiPrintf("%s: %s", tsChannel->name, msg);
166#endif /* EFI_TUNER_STUDIO_VERBOSE */
167}
const char * name

Referenced by TunerStudio::handleCrcCommand(), TunerStudio::handlePlainCommand(), handleTestCommand(), and tunerStudioError().

Here is the caller graph for this function:

◆ tunerStudioError()

void tunerStudioError ( TsChannelBase tsChannel,
const char msg 
)

Definition at line 762 of file tunerstudio.cpp.

762 {
763 tunerStudioDebug(tsChannel, msg);
766}
void tunerStudioDebug(TsChannelBase *tsChannel, const char *msg)
static void printErrorCounters()

Referenced by getWorkingPageAddr(), TunerStudio::handleCrc32Check(), TunerStudio::handleCrcCommand(), TunerStudio::handlePageReadCommand(), TunerStudio::handleWriteChunkCommand(), tsProcessOne(), and validateOffsetCount().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateTunerStudioState()

void updateTunerStudioState ( )

Definition at line 626 of file status_loop.cpp.

626 {
627 TunerStudioOutputChannels *tsOutputChannels = &engine->outputChannels;
628#if EFI_USB_SERIAL
629 // pretty much SD card logs know if specifically USB serial is active
631#endif // EFI_USB_SERIAL
632
633 float rpm = Sensor::get(SensorType::Rpm).value_or(0);
634
635
636 static Timer blinkIndicatorsTimer;
637 constexpr float blinkHalfPeriod = 0.3;
638 bool isBlinkPhase = blinkIndicatorsTimer.hasElapsedSec(blinkHalfPeriod);
639#if EFI_ELECTRONIC_THROTTLE_BODY
640 blinkEtbErrorCodes(isBlinkPhase);
641#endif // EFI_ELECTRONIC_THROTTLE_BODY
642 if (isBlinkPhase) {
645
646 if (blinkIndicatorsTimer.hasElapsedSec(2 * blinkHalfPeriod)) {
647 blinkIndicatorsTimer.reset();
648 }
649 } else {
652 }
653
654
655#if EFI_PROD_CODE
657#endif /* EFI_PROD_CODE */
658
661 engine->dc_motors.isEnabled0_int = dc->msg() == nullptr;
662
663 tsOutputChannels->RPMValue = rpm;
664#if EFI_SHAFT_POSITION_INPUT
668
670#endif // EFI_SHAFT_POSITION_INPUT
671
674 updateIgnition(rpm);
675 updateFlags();
676 // update calibration channel, reset to None state after timeout
678
679 // Output both the estimated air flow, and measured air flow (if available)
680 tsOutputChannels->mafMeasured = Sensor::getOrZero(SensorType::Maf);
682 tsOutputChannels->mafEstimate = engine->engineState.airflowEstimate;
683
684#if EFI_ENGINE_CONTROL
685 tsOutputChannels->injectorDutyCycle = minF(/*let's avoid scaled "uint8_t, 2" overflow*/127, getInjectorDutyCycle(rpm));
687#endif
688
689 tsOutputChannels->seconds = getTimeNowS();
690
691 tsOutputChannels->engineMode = packEngineMode();
692 tsOutputChannels->firmwareVersion = getRusEfiVersion();
693
694 tsOutputChannels->accelerationLat = engine->sensors.accelerometer.lat;
695 tsOutputChannels->accelerationLon = engine->sensors.accelerometer.lon;
696 tsOutputChannels->accelerationVert = engine->sensors.accelerometer.vert;
697 tsOutputChannels->gyroYaw = engine->sensors.accelerometer.yawRate;
698
699#if EFI_DYNO_VIEW
700 tsOutputChannels->hp = getDynoviewHP();
701 tsOutputChannels->torque = getDynoviewTorque();
702#else
703 tsOutputChannels->hp = -1;
704 tsOutputChannels->torque = -1;
705#endif
706
712
713 tsOutputChannels->hasCriticalError = hasFirmwareError() || hasConfigError() || engine->engineState.warnings.hasWarningMessage();
714 tsOutputChannels->hasFaultReportFile = hasErrorReportFile();
716
717 tsOutputChannels->isWarnNow = engine->engineState.warnings.isWarningNow();
718
719 tsOutputChannels->tpsAccelFuel = engine->engineState.tpsAccelEnrich;
720
721 tsOutputChannels->checkEngine = hasErrorCodes();
722
724
727
728
730
731#if EFI_CLOCK_LOCKS
732 tsOutputChannels->maxLockedDuration = NT2US(maxLockedDuration);
733#endif /* EFI_CLOCK_LOCKS */
734
735#if EFI_SHAFT_POSITION_INPUT
736 tsOutputChannels->maxTriggerReentrant = maxTriggerReentrant;
739
742
743#endif // EFI_SHAFT_POSITION_INPUT
744
745#if HAL_USE_PAL && EFI_PROD_CODE
746 tsOutputChannels->extiOverflowCount = getExtiOverflowCounter();
747#endif
748
750 case DBG_LOGIC_ANALYZER:
751#if EFI_LOGIC_ANALYZER
752 // used by HW CI
754#endif /* EFI_LOGIC_ANALYZER */
755 break;
756 default:
757 ;
758 }
759}
const char * msg()
Definition dc_motors.h:70
TwoPinDcMotor dcMotor
Definition dc_motors.h:63
TriggerCentral triggerCentral
Definition engine.h:318
dc_motors_s dc_motors
Definition engine.h:346
EngineState engineState
Definition engine.h:344
RpmCalculator rpmCalculator
Definition engine.h:306
TunerStudioOutputChannels outputChannels
Definition engine.h:109
SensorsState sensors
Definition engine.h:353
RegisteredOutputPin starterControl
Definition efi_gpio.h:82
RegisteredOutputPin starterRelayDisable
Definition efi_gpio.h:84
floatms_t tpsAccelEnrich
float airflowEstimate
WarningCodeState warnings
bool getLogicValue() const
Definition efi_gpio.cpp:667
float getRpmAcceleration() const
uint32_t getRevolutionCounterSinceStart(void) const
virtual SensorResult get() const =0
static float getOrZero(SensorType type)
Definition sensor.h:83
InstantRpmCalculator instantRpm
PrimaryTriggerDecoder triggerState
int getHwEventCounter(int index) const
uint32_t totalTriggerErrorCounter
float get() const override
Get the current motor duty cycle.
Definition dc_motor.cpp:48
bool hasWarningMessage()
Definition engine2.cpp:102
bool isWarningNow() const
Definition engine2.cpp:114
bool is_usb_serial_ready()
DcHardware * getPrimaryDCHardwareForLogging()
Definition dc_motors.cpp:86
uint8_t getExtiOverflowCounter()
int getDynoviewHP()
Definition dynoview.cpp:164
int getDynoviewTorque()
Definition dynoview.cpp:168
EnginePins enginePins
Definition efi_gpio.cpp:24
efitimesec_t getTimeNowS()
Current system time in seconds (32 bits)
Definition efitime.cpp:42
void blinkEtbErrorCodes(bool blinkPhase)
static constexpr engine_configuration_s * engineConfiguration
bool hasConfigError()
bool hasErrorReportFile()
int getRusEfiVersion()
percent_t getInjectorDutyCycleStage2(float rpm)
percent_t getInjectorDutyCycle(float rpm)
FrequencySensor inputShaftSpeedSensor(SensorType::InputShaftSpeed, MS2NT(500))
FrequencySensor vehicleSpeedSensor(SensorType::VehicleSpeed, MS2NT(500))
void reportLogicAnalyzerToTS()
bool ltftNeedVeRefresh()
bool hasErrorCodes(void)
void executorStatistics()
@ SHAFT_SECONDARY_RISING
@ SHAFT_SECONDARY_FALLING
@ SHAFT_PRIMARY_FALLING
@ SHAFT_PRIMARY_RISING
static void updateFlags()
uint32_t maxLockedDuration
static void updateFuelInfo()
static void updateIgnition(float rpm)
static int packEngineMode()
int maxTriggerReentrant
static void updateSensors()
Accelerometer accelerometer
scaled_channel< int16_t, 1000, 1 > accelerationLat
scaled_channel< int16_t, 1000, 1 > accelerationVert
scaled_channel< uint16_t, 10, 1 > mafEstimate
scaled_channel< uint8_t, 2, 1 > injectorDutyCycle
scaled_channel< int16_t, 1000, 1 > accelerationLon
scaled_channel< int16_t, 300, 1 > tpsAccelFuel
scaled_channel< int16_t, 1000, 1 > gyroYaw
scaled_channel< uint16_t, 10, 1 > mafMeasured2
scaled_channel< uint16_t, 10, 1 > mafMeasured
scaled_channel< uint8_t, 2, 1 > injectorDutyCycleStage2
bool needToTriggerTsRefresh()

Referenced by TunerStudio::cmdOutputChannels(), configureRusefiLuaHooks(), and MLG::writeSdLogLine().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ __attribute__

TunerstudioThread __attribute__

◆ count

uint16_t count

◆ offset

uint16_t offset

◆ page

uint16_t page

◆ tsState

tunerstudio_counters_s tsState
extern

Go to the source code of this file.