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 291 of file tunerstudio.cpp.

291 {
292 if (offset + count < areaStart) {
293 // we are touching below for instance VE table
294 return false;
295 }
296 if (offset > areaStart + areaSize) {
297 // we are touching after for instance VE table
298 return false;
299 }
300 // else - we are touching it!
301 return true;
302}
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 1044 of file tunerstudio.cpp.

1044 {
1045 int tuningDetector = engineConfiguration->isTuningDetectorEnabled ? 0 : 20;
1046 return !calibrationsVeWriteTimer.hasElapsedSec(tuningDetector);
1047}
static constexpr engine_configuration_s * engineConfiguration

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

Here is the caller graph for this function:

◆ needToTriggerTsRefresh()

bool needToTriggerTsRefresh ( )

Definition at line 273 of file tunerstudio.cpp.

273 {
274 return !engine->engineTypeChangeTimer.hasElapsedSec(1);
275}
Timer engineTypeChangeTimer
Definition engine.h:317
static EngineAccessor engine
Definition engine.h:421

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

Here is the caller graph for this function:

◆ onApplyPreset()

void onApplyPreset ( )

Definition at line 277 of file tunerstudio.cpp.

277 {
279}

Referenced by applyPreset(), handleCommandX14(), and vinStrategy().

Here is the caller graph for this function:

◆ requestBurn()

void requestBurn ( )

Definition at line 457 of file tunerstudio.cpp.

457 {
458#if !EFI_UNIT_TEST
460
461#if EFI_CONFIGURATION_STORAGE
463#endif /* EFI_CONFIGURATION_STORAGE */
464#endif // !EFI_UNIT_TEST
465}
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 234 of file tunerstudio.cpp.

234 {
235 //TODO uncomment once I have test it myself
236 UNUSED(msg);
237 //if (msg != DO_NOT_LOG) {
238 // efiPrintf("TS <- Err: %d [%s]", code, msg);
239 //}
240
241 switch (code) {
242 case TS_RESPONSE_UNDERRUN:
244 break;
245 case TS_RESPONSE_OVERRUN:
247 break;
248 case TS_RESPONSE_CRC_FAILURE:
250 break;
251 case TS_RESPONSE_UNRECOGNIZED_COMMAND:
253 break;
254 case TS_RESPONSE_OUT_OF_RANGE:
256 break;
257 default:
259 break;
260 }
261
262 tsChannel->writeCrcResponse(code);
263}
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 1049 of file tunerstudio.cpp.

1049 {
1050 // Assert tune & output channel struct sizes
1051 static_assert(sizeof(persistent_config_s) == TOTAL_CONFIG_SIZE, "TS datapage size mismatch");
1052 // useful trick if you need to know how far off is the static_assert
1053 //char (*__kaboom)[sizeof(persistent_config_s)] = 1;
1054 // another useful trick
1055 //static_assert(offsetof (engine_configuration_s,HD44780_e) == 700);
1056
1057 memset(&tsState, 0, sizeof(tsState));
1058
1059 addConsoleAction("tsinfo", printTsStats);
1060 addConsoleAction("reset_ts", resetTs);
1061 addConsoleActionI("set_ts_speed", setTsSpeed);
1062
1063#if EFI_BLUETOOTH_SETUP
1064 // module initialization start (it waits for disconnect and then communicates to the module)
1065 // Usage: "bluetooth_hc06 <baud> <name> <pincode>"
1066 // Example: "bluetooth_hc06 38400 rusefi 1234"
1067 // bluetooth_jdy 115200 alphax 1234
1068 addConsoleActionSSS("bluetooth_hc05", [](const char *baudRate, const char *name, const char *pinCode) {
1069 bluetoothStart(BLUETOOTH_HC_05, baudRate, name, pinCode);
1070 });
1071 addConsoleActionSSS("bluetooth_hc06", [](const char *baudRate, const char *name, const char *pinCode) {
1072 bluetoothStart(BLUETOOTH_HC_06, baudRate, name, pinCode);
1073 });
1074 addConsoleActionSSS("bluetooth_bk", [](const char *baudRate, const char *name, const char *pinCode) {
1075 bluetoothStart(BLUETOOTH_BK3231, baudRate, name, pinCode);
1076 });
1077 addConsoleActionSSS("bluetooth_jdy", [](const char *baudRate, const char *name, const char *pinCode) {
1078 bluetoothStart(BLUETOOTH_JDY_3x, baudRate, name, pinCode);
1079 });
1080 addConsoleActionSSS("bluetooth_jdy31", [](const char *baudRate, const char *name, const char *pinCode) {
1081 bluetoothStart(BLUETOOTH_JDY_31, baudRate, name, pinCode);
1082 });
1083#endif /* EFI_BLUETOOTH_SETUP */
1084}
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 162 of file tunerstudio.cpp.

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

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

Here is the caller graph for this function:

◆ tunerStudioError()

void tunerStudioError ( TsChannelBase tsChannel,
const char msg 
)

Definition at line 768 of file tunerstudio.cpp.

768 {
769 tunerStudioDebug(tsChannel, msg);
772}
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 627 of file status_loop.cpp.

627 {
628 TunerStudioOutputChannels *tsOutputChannels = &engine->outputChannels;
629#if EFI_USB_SERIAL
630 // pretty much SD card logs know if specifically USB serial is active
632#endif // EFI_USB_SERIAL
633
634 float rpm = Sensor::get(SensorType::Rpm).value_or(0);
635
636
637 static Timer blinkIndicatorsTimer;
638 constexpr float blinkHalfPeriod = 0.3;
639 bool isBlinkPhase = blinkIndicatorsTimer.hasElapsedSec(blinkHalfPeriod);
640#if EFI_ELECTRONIC_THROTTLE_BODY
641 blinkEtbErrorCodes(isBlinkPhase);
642#endif // EFI_ELECTRONIC_THROTTLE_BODY
643 if (isBlinkPhase) {
646
647 if (blinkIndicatorsTimer.hasElapsedSec(2 * blinkHalfPeriod)) {
648 blinkIndicatorsTimer.reset();
649 }
650 } else {
653 }
654
655
656#if EFI_PROD_CODE
658#endif /* EFI_PROD_CODE */
659
662 engine->dc_motors.isEnabled0_int = dc->msg() == nullptr;
663
664 tsOutputChannels->RPMValue = rpm;
665#if EFI_SHAFT_POSITION_INPUT
669
671#endif // EFI_SHAFT_POSITION_INPUT
672
675 updateIgnition(rpm);
676 updateFlags();
677 // update calibration channel, reset to None state after timeout
679
680 // Output both the estimated air flow, and measured air flow (if available)
681 tsOutputChannels->mafMeasured = Sensor::getOrZero(SensorType::Maf);
683 tsOutputChannels->mafEstimate = engine->engineState.airflowEstimate;
684
685#if EFI_ENGINE_CONTROL
686 tsOutputChannels->injectorDutyCycle = minF(/*let's avoid scaled "uint8_t, 2" overflow*/127, getInjectorDutyCycle(rpm));
688#endif
689
690 tsOutputChannels->seconds = getTimeNowS();
691
692 tsOutputChannels->engineMode = packEngineMode();
693 tsOutputChannels->firmwareVersion = getRusEfiVersion();
694
695 tsOutputChannels->accelerationLat = engine->sensors.accelerometer.lat;
696 tsOutputChannels->accelerationLon = engine->sensors.accelerometer.lon;
697 tsOutputChannels->accelerationVert = engine->sensors.accelerometer.vert;
698 tsOutputChannels->gyroYaw = engine->sensors.accelerometer.yawRate;
699
700#if EFI_DYNO_VIEW
701 tsOutputChannels->hp = getDynoviewHP();
702 tsOutputChannels->torque = getDynoviewTorque();
703#else
704 tsOutputChannels->hp = -1;
705 tsOutputChannels->torque = -1;
706#endif
707
713
714 tsOutputChannels->hasCriticalError = hasFirmwareError() || hasConfigError() || engine->engineState.warnings.hasWarningMessage();
715 tsOutputChannels->hasFaultReportFile = hasErrorReportFile();
717
718 tsOutputChannels->isWarnNow = engine->engineState.warnings.isWarningNow();
719
720 tsOutputChannels->tpsAccelFuel = engine->engineState.tpsAccelEnrich;
721
722 tsOutputChannels->checkEngine = hasErrorCodes();
723
725
728
729
731
732#if EFI_CLOCK_LOCKS
733 tsOutputChannels->maxLockedDuration = NT2US(maxLockedDuration);
734#endif /* EFI_CLOCK_LOCKS */
735
736#if EFI_SHAFT_POSITION_INPUT
737 tsOutputChannels->maxTriggerReentrant = maxTriggerReentrant;
740
743
744#endif // EFI_SHAFT_POSITION_INPUT
745
746#if HAL_USE_PAL && EFI_PROD_CODE
747 tsOutputChannels->extiOverflowCount = getExtiOverflowCounter();
748#endif
749
751 case DBG_LOGIC_ANALYZER:
752#if EFI_LOGIC_ANALYZER
753 // used by HW CI
755#endif /* EFI_LOGIC_ANALYZER */
756 break;
757 default:
758 ;
759 }
760}
const char * msg()
Definition dc_motors.h:70
TwoPinDcMotor dcMotor
Definition dc_motors.h:63
TriggerCentral triggerCentral
Definition engine.h:326
dc_motors_s dc_motors
Definition engine.h:354
EngineState engineState
Definition engine.h:352
RpmCalculator rpmCalculator
Definition engine.h:314
TunerStudioOutputChannels outputChannels
Definition engine.h:113
SensorsState sensors
Definition engine.h:361
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)
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

Definition at line 0 of file tunerstudio.h.

Referenced by addSkippedToothTriggerEvents(), addTooth(), TunerStudio::cmdOutputChannels(), configureBarra3plus1cam(), configureGm60_2_2_2(), configureTriTach(), getBit(), getByte(), getFloat(), getFourBytesLsb(), getInt(), getShiftedLSB_intel(), getShort(), getTwoBytesLsb(), getTwoBytesMsb(), getWorkingPageAddr(), gpiochips_getPinName(), hackEngineConfigurationPointer(), TunerStudio::handleCrc32Check(), TunerStudio::handleCrcCommand(), TunerStudio::handlePageReadCommand(), TunerStudio::handleScatteredReadCommand(), TunerStudio::handleWriteChunkCommand(), hexdump(), initialize36_2_1(), initialize36_2_1_1(), initializeMazdaMiataNb1ShapeWithOffset(), initializeNissanVQvvt(), initializeSubaru7_6_camOnly(), initializeSubaru7_6_crankOnly(), initializeSubaru_SVX(), initJeep_XJ_4cyl_2500(), isTouchingArea(), isTouchingVe(), MLG::Entries::Field::memcpy_swapend(), onCalibrationWrite(), printScatterList(), putTwoSymbolDecimal(), CanStreamerState::sendDataTimeout(), IsoTpBase::sendFrame(), setBit(), setByte(), setFloat(), setInt(), LuaPid::setOffset(), LuaIndustrialPid::setOffset(), setShort(), CanTxMessage::setShortValue(), CanTxMessage::setShortValueMsb(), snor_device_init(), snor_device_program(), snor_device_read(), snor_device_read_sfdp(), snor_device_start_erase_sector(), snor_device_verify_erase(), CanStreamerState::streamAddToTxTimeout(), validateOffsetCount(), MLG::Entries::Field::writeData(), MLG::writeSdBlock(), and IsoTpRxTx::writeTimeout().

◆ page

uint16_t page

◆ tsState

tunerstudio_counters_s tsState
extern

Go to the source code of this file.