LCOV - code coverage report
Current view: top level - firmware/console/binary - tunerstudio_commands.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 5 25 20.0 %
Date: 2024-04-25 02:23:43 Functions: 2 4 50.0 %

          Line data    Source code
       1             : #include "pch.h"
       2             : 
       3             : #include "tunerstudio_impl.h"
       4             : #include "tunerstudio.h"
       5             : #include "tunerstudio_io.h"
       6             : 
       7             : #include "live_data.h"
       8             : 
       9             : #include "status_loop.h"
      10             : 
      11             : #if EFI_TUNER_STUDIO
      12             : 
      13           1 : static constexpr size_t getTunerStudioPageSize() {
      14           1 :         return TOTAL_CONFIG_SIZE;
      15             : }
      16             : 
      17             : // Validate whether the specified offset and count would cause an overrun in the tune.
      18             : // Returns true if an overrun would occur.
      19           1 : bool validateOffsetCount(size_t offset, size_t count, TsChannelBase* tsChannel) {
      20           1 :         if (offset + count > getTunerStudioPageSize()) {
      21           0 :                 efiPrintf("TS: Project mismatch? Too much configuration requested %d/%d", offset, count);
      22           0 :                 tunerStudioError(tsChannel, "ERROR: out of range");
      23           0 :                 sendErrorCode(tsChannel, TS_RESPONSE_OUT_OF_RANGE);
      24           0 :                 return true;
      25             :         }
      26             : 
      27           1 :         return false;
      28             : }
      29             : 
      30             : 
      31             : // This is used to prevent TS from reading/writing when we have just applied a preset, to prevent TS getting confused.
      32             : // At the same time an ECU reboot is forced by triggering a fatal error, informing the user to please restart
      33             : // the ECU.  Forcing a reboot will force TS to re-read the tune CRC,
      34             : bool rebootForPresetPending = false;
      35             : 
      36             : static Timer channelsRequestTimer;
      37             : 
      38           0 : int getSecondsSinceChannelsRequest() {
      39           0 :     return channelsRequestTimer.getElapsedSeconds();
      40             : }
      41             : 
      42             : /**
      43             :  * @brief 'Output' command sends out a snapshot of current values
      44             :  * Gauges refresh
      45             :  */
      46           0 : void TunerStudio::cmdOutputChannels(TsChannelBase* tsChannel, uint16_t offset, uint16_t count) {
      47           0 :         if (offset + count > TS_TOTAL_OUTPUT_SIZE) {
      48           0 :                 efiPrintf("TS: Version Mismatch? Too much outputs requested offset=%d + count=%d/total=%d", offset, count,
      49             :                                 sizeof(TunerStudioOutputChannels));
      50           0 :                 sendErrorCode(tsChannel, TS_RESPONSE_OUT_OF_RANGE);
      51           0 :                 return;
      52             :         }
      53             : 
      54           0 :         if (offset < BLOCKING_FACTOR) {
      55           0 :                 engine->outputChannels.outputRequestPeriod = channelsRequestTimer.getElapsedUs();
      56           0 :                 channelsRequestTimer.reset();
      57             :         }
      58             : 
      59           0 :         tsState.outputChannelsCommandCounter++;
      60           0 :         updateTunerStudioState();
      61           0 :         tsChannel->assertPacketSize(count, false);
      62             :         // this method is invoked too often to print any debug information
      63           0 :         uint8_t * scratchBuffer = (uint8_t *)tsChannel->scratchBuffer;
      64             :         /**
      65             :          * collect data from all models
      66             :          */
      67           0 :         copyRange(scratchBuffer + 3, getLiveDataFragments(), offset, count);
      68             : 
      69           0 :         tsChannel->crcAndWriteBuffer(TS_RESPONSE_OK, count);
      70             : }
      71             : 
      72             : #endif // EFI_TUNER_STUDIO

Generated by: LCOV version 1.14