GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 0.0% 0 / 0 / 22
Functions: 0.0% 0 / 0 / 2
Branches: 0.0% 0 / 0 / 17
Decisions: 0.0% 0 / - / 6

firmware/console/binary/tunerstudio_commands.cpp
Line Branch Decision Exec Source
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 static Timer channelsRequestTimer;
14
15 int getSecondsSinceChannelsRequest() {
16 return channelsRequestTimer.getElapsedSeconds();
17 }
18
19 /**
20 * @brief 'Output' command sends out a snapshot of current values
21 * Gauges refresh
22 */
23 void TunerStudio::cmdOutputChannels(TsChannelBase* tsChannel, uint16_t offset, uint16_t count) {
24 if (offset + count > TS_TOTAL_OUTPUT_SIZE) {
25 efiPrintf("TS: Version Mismatch? Too much outputs requested offset=%d + count=%d/total=%d", offset, count,
26 TS_TOTAL_OUTPUT_SIZE);
27 sendErrorCode(tsChannel, TS_RESPONSE_OUT_OF_RANGE, "cmd_size");
28 return;
29 }
30
31 if (offset < BLOCKING_FACTOR) {
32 engine->outputChannels.outputRequestPeriod = channelsRequestTimer.getElapsedUs();
33 channelsRequestTimer.reset();
34 }
35
36 tsState.outputChannelsCommandCounter++;
37 updateTunerStudioState();
38 // this method is invoked too often to print any debug information
39 uint8_t * scratchBuffer = (uint8_t *)tsChannel->scratchBuffer;
40 /**
41 * collect data from all models
42 */
43 FragmentList list = getLiveDataFragments();
44
45 uint32_t crc = tsChannel->writePacketHeader(TS_RESPONSE_OK, count);
46
47 while (count) {
48 size_t chunkSize = minI(count, sizeof(tsChannel->scratchBuffer));
49 /**
50 * collect data from all models
51 */
52 size_t actualSize = copyRange(scratchBuffer, list, offset, chunkSize);
53 crc = tsChannel->writePacketBody(scratchBuffer, actualSize, crc);
54
55 count -= chunkSize;
56 offset += chunkSize;
57 }
58
59 tsChannel->writeCrcPacketTail(crc);
60 }
61
62 #endif // EFI_TUNER_STUDIO
63