rusEFI
The most advanced open source ECU
Functions | Variables
tunerstudio.cpp File Reference

Detailed Description

Binary protocol implementation.

This implementation would not happen without the documentation provided by Jon Zeeff (jon@z.nosp@m.eeff.nosp@m..com)

Integration with EFI Analytics Tuner Studio software

Tuner Studio has a really simple protocol, a minimal implementation capable of displaying current engine state on the gauges would require only two commands: queryCommand and ochGetCommand

queryCommand: Communication initialization command. TunerStudio sends a single byte H ECU response: One of the known ECU id strings.

ochGetCommand: Request for output channels state.TunerStudio sends a single byte O ECU response: A snapshot of output channels as described in [OutputChannels] section of the .ini file The length of this block is 'ochBlockSize' property of the .ini file

These two commands are enough to get working gauges. In order to start configuring the ECU using tuner studio, three more commands should be implemented:

Date
Oct 22, 2013
Author
Andrey Belomutskiy, (c) 2012-2020

This file is part of rusEfi - see http://rusefi.com

rusEfi is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

This file is part of rusEfi - see http://rusefi.com

rusEfi is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file tunerstudio.cpp.

Functions

static void printErrorCounters ()
 
static void printScatterList ()
 
static void resetTs ()
 
static void printTsStats (void)
 
static void setTsSpeed (int value)
 
void tunerStudioDebug (TsChannelBase *tsChannel, const char *msg)
 
uint8_t * getWorkingPageAddr ()
 
static void sendOkResponse (TsChannelBase *tsChannel)
 
void sendErrorCode (TsChannelBase *tsChannel, uint8_t code, const char *msg)
 
bool validateOffsetCount (size_t offset, size_t count, TsChannelBase *tsChannel)
 
void requestBurn ()
 
static void handleBurnCommand (TsChannelBase *tsChannel)
 
static bool isKnownCommand (char command)
 
static void handleTestCommand (TsChannelBase *tsChannel)
 
static int tsProcessOne (TsChannelBase *tsChannel)
 
void tunerStudioError (TsChannelBase *tsChannel, const char *msg)
 
static void handleGetVersion (TsChannelBase *tsChannel)
 
static void handleGetText (TsChannelBase *tsChannel)
 
void startTunerStudioConnectivity (void)
 

Variables

bool rebootForPresetPending
 
TunerStudio tsInstance
 
tunerstudio_counters_s tsState
 
CommandHandler console_line_callback
 

Function Documentation

◆ getWorkingPageAddr()

uint8_t* getWorkingPageAddr ( )

Definition at line 154 of file tunerstudio.cpp.

154  {
155  return (uint8_t*)engineConfiguration;
156 }
engine_configuration_s * engineConfiguration

Referenced by TunerStudio::handleCrc32Check(), TunerStudio::handlePageReadCommand(), TunerStudio::handleWriteChunkCommand(), and TunerStudio::handleWriteValueCommand().

Here is the caller graph for this function:

◆ handleBurnCommand()

static void handleBurnCommand ( TsChannelBase tsChannel)
static

'Burn' command is a command to commit the changes

Definition at line 383 of file tunerstudio.cpp.

383  {
384  Timer t;
385  t.reset();
386 
388 
389  efiPrintf("TS -> Burn");
391 
392  // Skip the burn if a preset was just loaded - we don't want to overwrite it
393  if (!rebootForPresetPending) {
394  requestBurn();
395  }
396 
397  tsChannel->writeCrcResponse(TS_RESPONSE_BURN_OK);
398  efiPrintf("Burned in %.1fms", t.getElapsedSeconds() * 1e3);
399 }
void writeCrcResponse(uint8_t responseCode)
bool validateConfigOnStartUpOrBurn()
tunerstudio_counters_s tsState
void requestBurn()
bool rebootForPresetPending

Referenced by TunerStudio::handleCrcCommand().

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

◆ handleGetText()

static void handleGetText ( TsChannelBase tsChannel)
static

Definition at line 683 of file tunerstudio.cpp.

683  {
685 
687 
688  size_t outputSize;
689  const char* output = swapOutputBuffers(&outputSize);
690 #if EFI_SIMULATOR
691  logMsg("get test sending [%d]\r\n", outputSize);
692 #endif
693 
694  tsChannel->writeCrcPacket(TS_RESPONSE_OK, reinterpret_cast<const uint8_t*>(output), outputSize, true);
695 #if EFI_SIMULATOR
696  logMsg("sent [%d]\r\n", outputSize);
697 #endif // EFI_SIMULATOR
698 }
virtual void writeCrcPacket(uint8_t responseCode, const uint8_t *buf, size_t size, bool allowLongPackets=false)
const char * swapOutputBuffers(size_t *actualOutputBufferSize)
void printOverallStatus()

Referenced by TunerStudio::handleCrcCommand().

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

◆ handleGetVersion()

static void handleGetVersion ( TsChannelBase tsChannel)
static

Definition at line 676 of file tunerstudio.cpp.

676  {
677  char versionBuffer[32];
678  chsnprintf(versionBuffer, sizeof(versionBuffer), "%s v%d@%u", FRONTEND_TITLE_BAR_NAME, getRusEfiVersion(), SIGNATURE_HASH);
679  tsChannel->sendResponse(TS_CRC, (const uint8_t *) versionBuffer, strlen(versionBuffer) + 1);
680 }
void sendResponse(ts_response_format_e mode, const uint8_t *buffer, int size, bool allowLongPackets=false)
int getRusEfiVersion(void)
@ TS_CRC

Referenced by TunerStudio::handleCrcCommand().

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

◆ handleTestCommand()

static void handleTestCommand ( TsChannelBase tsChannel)
static

rusEfi own test command

this is NOT a standard TunerStudio command, this is my own extension of the protocol to simplify troubleshooting

Definition at line 432 of file tunerstudio.cpp.

432  {
434  char testOutputBuffer[64];
435  /**
436  * this is NOT a standard TunerStudio command, this is my own
437  * extension of the protocol to simplify troubleshooting
438  */
439  tunerStudioDebug(tsChannel, "got T (Test)");
440  tsChannel->write((const uint8_t*)QUOTE(SIGNATURE_HASH), sizeof(QUOTE(SIGNATURE_HASH)));
441 
442  chsnprintf(testOutputBuffer, sizeof(testOutputBuffer), " %d %d", engine->engineState.warnings.lastErrorCode, tsState.testCommandCounter);
443  tsChannel->write((const uint8_t*)testOutputBuffer, strlen(testOutputBuffer));
444 
445  chsnprintf(testOutputBuffer, sizeof(testOutputBuffer), " uptime=%ds ", (int)getTimeNowS());
446  tsChannel->write((const uint8_t*)testOutputBuffer, strlen(testOutputBuffer));
447 
448  chsnprintf(testOutputBuffer, sizeof(testOutputBuffer), __DATE__ " %s\r\n", PROTOCOL_TEST_RESPONSE_TAG);
449  tsChannel->write((const uint8_t*)testOutputBuffer, strlen(testOutputBuffer));
450 
451  if (hasFirmwareError()) {
452  const char* error = getCriticalErrorMessage();
453  chsnprintf(testOutputBuffer, sizeof(testOutputBuffer), "error=%s\r\n", error);
454  tsChannel->write((const uint8_t*)testOutputBuffer, strlen(testOutputBuffer));
455  }
456  tsChannel->flush();
457 }
EngineState engineState
Definition: engine.h:312
WarningCodeState warnings
Definition: engine_state.h:43
virtual void flush()
virtual void write(const uint8_t *buffer, size_t size, bool isEndOfPacket=false)=0
ObdCode lastErrorCode
Definition: engine_parts.h:63
efitimesec_t getTimeNowS()
Current system time in seconds (32 bits)
Definition: efitime.cpp:42
Engine * engine
const char * getCriticalErrorMessage(void)
void tunerStudioDebug(TsChannelBase *tsChannel, const char *msg)

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

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

◆ isKnownCommand()

static bool isKnownCommand ( char  command)
static

Definition at line 403 of file tunerstudio.cpp.

403  {
404  return command == TS_HELLO_COMMAND || command == TS_READ_COMMAND || command == TS_OUTPUT_COMMAND
405  || command == TS_PAGE_COMMAND || command == TS_BURN_COMMAND || command == TS_SINGLE_WRITE_COMMAND
406  || command == TS_CHUNK_WRITE_COMMAND || command == TS_EXECUTE
407  || command == TS_IO_TEST_COMMAND
408 #if EFI_SIMULATOR
409  || command == TS_SIMULATE_CAN
410 #endif // EFI_SIMULATOR
411 #if EFI_TS_SCATTER
412  || command == TS_GET_SCATTERED_GET_COMMAND
413 #endif
414  || command == TS_SET_LOGGER_SWITCH
415  || command == TS_GET_COMPOSITE_BUFFER_DONE_DIFFERENTLY
416  || command == TS_GET_TEXT
417  || command == TS_CRC_CHECK_COMMAND
418  || command == TS_GET_FIRMWARE_VERSION
419 #ifdef KNOCK_SPECTROGRAM
420  || command == TS_KNOCK_SPECTROGRAM_ENABLE
421  || command == TS_KNOCK_SPECTROGRAM_DISABLE
422 #endif
423  || command == TS_PERF_TRACE_BEGIN
424  || command == TS_PERF_TRACE_GET_BUFFER
425  || command == TS_GET_CONFIG_ERROR
426  || command == TS_QUERY_BOOTLOADER;
427 }

Referenced by tsProcessOne().

Here is the caller graph for this function:

◆ printErrorCounters()

static void printErrorCounters ( )
static

Definition at line 93 of file tunerstudio.cpp.

93  {
94  efiPrintf("TunerStudio size=%d / total=%d / errors=%d / H=%d / O=%d / P=%d / B=%d",
97  efiPrintf("TunerStudio W=%d / C=%d / P=%d", tsState.writeValueCommandCounter,
99  efiPrintf("TunerStudio errors: underrun=%d / overrun=%d / crc=%d / unrecognized=%d / outofrange=%d / other=%d",
102 }
TunerStudioOutputChannels outputChannels
Definition: engine.h:99

Referenced by printTsStats(), and tunerStudioError().

Here is the caller graph for this function:

◆ printScatterList()

static void printScatterList ( )
static

Definition at line 104 of file tunerstudio.cpp.

104  {
105  efiPrintf("Scatter list (global)");
106  for (int i = 0; i < HIGH_SPEED_COUNT; i++) {
107  uint16_t packed = engineConfiguration->highSpeedOffsets[i];
108  uint16_t type = packed >> 13;
109  uint16_t offset = packed & 0x1FFF;
110 
111  if (type == 0)
112  continue;
113  size_t size = 1 << (type - 1);
114 
115  efiPrintf("%02d offset 0x%04x size %d", i, offset, size);
116  }
117 }
composite packet size

Referenced by printTsStats().

Here is the caller graph for this function:

◆ printTsStats()

static void printTsStats ( void  )
static

Definition at line 128 of file tunerstudio.cpp.

128  {
129 #ifdef EFI_CONSOLE_RX_BRAIN_PIN
130  efiPrintf("Primary UART RX %s", hwPortname(EFI_CONSOLE_RX_BRAIN_PIN));
131  efiPrintf("Primary UART TX %s", hwPortname(EFI_CONSOLE_TX_BRAIN_PIN));
132 #endif /* EFI_CONSOLE_RX_BRAIN_PIN */
133 
134 #if EFI_USB_SERIAL
136 #endif // EFI_USB_SERIAL
137 
139 
141 }
void printUsbConnectorStats()
Definition: usb_console.cpp:60
const char * hwPortname(brain_pin_e brainPin)
static void printScatterList()
static void printErrorCounters()
Definition: tunerstudio.cpp:93

Referenced by setTsSpeed(), and startTunerStudioConnectivity().

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

◆ requestBurn()

void requestBurn ( )

Definition at line 368 of file tunerstudio.cpp.

368  {
369 #if !EFI_UNIT_TEST
370  onBurnRequest();
371 
372 #if EFI_CONFIGURATION_STORAGE
374 #endif /* EFI_CONFIGURATION_STORAGE */
375 #endif // !EFI_UNIT_TEST
376 }
void onBurnRequest()
void setNeedToWriteConfiguration()
Definition: flash_main.cpp:79

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

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

◆ resetTs()

static void resetTs ( )
static

Definition at line 124 of file tunerstudio.cpp.

124  {
125  memset(&tsState, 0, sizeof(tsState));
126 }

Referenced by startTunerStudioConnectivity().

Here is the caller graph for this function:

◆ sendErrorCode()

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

Definition at line 162 of file tunerstudio.cpp.

162  {
163 //TODO uncomment once I have test it myself if (msg != DO_NOT_LOG) {
164 // efiPrintf("TS <- Err: %d [%s]", code, msg);
165 // }
166 
167  switch (code) {
168  case TS_RESPONSE_UNDERRUN:
170  break;
171  case TS_RESPONSE_OVERRUN:
173  break;
174  case TS_RESPONSE_CRC_FAILURE:
176  break;
177  case TS_RESPONSE_UNRECOGNIZED_COMMAND:
179  break;
180  case TS_RESPONSE_OUT_OF_RANGE:
182  break;
183  default:
185  break;
186  }
187 
188  tsChannel->writeCrcResponse(code);
189 }
uint8_t code
Definition: bluetooth.cpp:40

Referenced by tsProcessOne(), and validateOffsetCount().

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

◆ sendOkResponse()

static void sendOkResponse ( TsChannelBase tsChannel)
static

Definition at line 158 of file tunerstudio.cpp.

158  {
159  tsChannel->sendResponse(TS_CRC, nullptr, 0);
160 }

Referenced by TunerStudio::handleCrcCommand(), TunerStudio::handlePageSelectCommand(), and TunerStudio::handleWriteChunkCommand().

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

◆ setTsSpeed()

static void setTsSpeed ( int  value)
static

Definition at line 143 of file tunerstudio.cpp.

143  {
145  printTsStats();
146 }
static void printTsStats(void)

Referenced by startTunerStudioConnectivity().

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

◆ startTunerStudioConnectivity()

void startTunerStudioConnectivity ( void  )

Definition at line 936 of file tunerstudio.cpp.

936  {
937  // Assert tune & output channel struct sizes
938  static_assert(sizeof(persistent_config_s) == TOTAL_CONFIG_SIZE, "TS datapage size mismatch");
939 // useful trick if you need to know how far off is the static_assert
940 // char (*__kaboom)[sizeof(persistent_config_s)] = 1;
941 // another useful trick
942 // static_assert(offsetof (engine_configuration_s,HD44780_e) == 700);
943 
944  memset(&tsState, 0, sizeof(tsState));
945 
946  addConsoleAction("tsinfo", printTsStats);
947  addConsoleAction("reset_ts", resetTs);
948  addConsoleActionI("set_ts_speed", setTsSpeed);
949 
950 #if EFI_BLUETOOTH_SETUP
951  // module initialization start (it waits for disconnect and then communicates to the module)
952  // Usage: "bluetooth_hc06 <baud> <name> <pincode>"
953  // Example: "bluetooth_hc06 38400 rusefi 1234"
954  // bluetooth_jdy 115200 alphax 1234
955  addConsoleActionSSS("bluetooth_hc05", [](const char *baudRate, const char *name, const char *pinCode) {
956  bluetoothStart(BLUETOOTH_HC_05, baudRate, name, pinCode);
957  });
958  addConsoleActionSSS("bluetooth_hc06", [](const char *baudRate, const char *name, const char *pinCode) {
959  bluetoothStart(BLUETOOTH_HC_06, baudRate, name, pinCode);
960  });
961  addConsoleActionSSS("bluetooth_bk", [](const char *baudRate, const char *name, const char *pinCode) {
962  bluetoothStart(BLUETOOTH_BK3231, baudRate, name, pinCode);
963  });
964  addConsoleActionSSS("bluetooth_jdy", [](const char *baudRate, const char *name, const char *pinCode) {
965  bluetoothStart(BLUETOOTH_JDY_3x, baudRate, name, pinCode);
966  });
967  addConsoleActionSSS("bluetooth_jdy31", [](const char *baudRate, const char *name, const char *pinCode) {
968  bluetoothStart(BLUETOOTH_JDY_31, baudRate, name, pinCode);
969  });
970 #endif /* EFI_BLUETOOTH_SETUP */
971 }
void bluetoothStart(bluetooth_module_e moduleType, const char *baudRate, const char *name, const char *pinCode)
Definition: bluetooth.cpp:275
@ 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()

Referenced by runRusEfi().

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

◆ tsProcessOne()

static int tsProcessOne ( TsChannelBase tsChannel)
static

Definition at line 511 of file tunerstudio.cpp.

511  {
512  assertStack("communication", ObdCode::STACK_USAGE_COMMUNICATION, EXPECTED_REMAINING_STACK, -1);
513 
514  if (!tsChannel->isReady()) {
515  chThdSleepMilliseconds(10);
516  return -1;
517  }
518 
520 
521  uint8_t firstByte;
522  size_t received = tsChannel->readTimeout(&firstByte, 1, TS_COMMUNICATION_TIMEOUT);
523 #if EFI_SIMULATOR
524  logMsg("received %d\r\n", received);
525 #endif // EFI_SIMULATOR
526 
527  if (received != 1) {
528 // tunerStudioError("ERROR: no command");
529 #if EFI_BLUETOOTH_SETUP
530  if (tsChannel == getBluetoothChannel()) {
531  // no data in a whole second means time to disconnect BT
532  // assume there's connection loss and notify the bluetooth init code
534  }
535 #endif /* EFI_BLUETOOTH_SETUP */
536  tsChannel->in_sync = false;
537  return -1;
538  }
539 
540  if (tsInstance.handlePlainCommand(tsChannel, firstByte)) {
541  return 0;
542  }
543 
544  uint8_t secondByte;
545  /* second byte should be received within minimal delay */
546  received = tsChannel->readTimeout(&secondByte, 1, TS_COMMUNICATION_TIMEOUT_SHORT);
547  if (received != 1) {
548  tunerStudioError(tsChannel, "TS: ERROR: no second byte");
549  tsChannel->in_sync = false;
550  return -1;
551  }
552 
553  uint16_t incomingPacketSize = firstByte << 8 | secondByte;
554  size_t expectedSize = incomingPacketSize + TS_PACKET_TAIL_SIZE;
555 
556  if ((incomingPacketSize == 0) || (expectedSize > sizeof(tsChannel->scratchBuffer))) {
557  if (tsChannel->in_sync) {
558  efiPrintf("process_ts: channel=%s invalid size: %d", tsChannel->name, incomingPacketSize);
559  tunerStudioError(tsChannel, "process_ts: ERROR: packet size");
560  /* send error only if previously we were in sync */
561  sendErrorCode(tsChannel, TS_RESPONSE_OUT_OF_RANGE, "invalid size");
562  }
563  tsChannel->in_sync = false;
564  return -1;
565  }
566 
567  char command;
568  if (tsChannel->in_sync) {
569  /* we are in sync state, packet size should be correct so lets receive full packet and then check if command is supported
570  * otherwise (if abort reception in middle of packet) it will break synchronization and cause error on next packet */
571  received = tsChannel->readTimeout((uint8_t*)(tsChannel->scratchBuffer), expectedSize, TS_COMMUNICATION_TIMEOUT);
572  command = tsChannel->scratchBuffer[0];
573 
574  if (received != expectedSize) {
575  /* print and send error as we were in sync */
576  efiPrintf("Got only %d bytes while expecting %d for command 0x%02x", received,
577  expectedSize, command);
578  tunerStudioError(tsChannel, "ERROR: not enough bytes in stream");
579  // MS serial protocol spec: There was a timeout before all data was received. (25ms per character.)
580  sendErrorCode(tsChannel, TS_RESPONSE_UNDERRUN, "underrun");
581  tsChannel->in_sync = false;
582  return -1;
583  }
584 
585  if (!isKnownCommand(command)) {
586  /* print and send error as we were in sync */
587  efiPrintf("unexpected command %x", command);
588  sendErrorCode(tsChannel, TS_RESPONSE_UNRECOGNIZED_COMMAND, "unknown");
589  tsChannel->in_sync = false;
590  return -1;
591  }
592  } else {
593  /* receive only command byte to check if it is supported */
594  received = tsChannel->readTimeout((uint8_t*)(tsChannel->scratchBuffer), 1, TS_COMMUNICATION_TIMEOUT_SHORT);
595  command = tsChannel->scratchBuffer[0];
596 
597  if (!isKnownCommand(command)) {
598  /* do not report any error as we are not in sync */
599  return -1;
600  }
601 
602  received = tsChannel->readTimeout((uint8_t*)(tsChannel->scratchBuffer) + 1, expectedSize - 1, TS_COMMUNICATION_TIMEOUT);
603  if (received != expectedSize - 1) {
604  /* do not report any error as we are not in sync */
605  return -1;
606  }
607  }
608 
609 #if EFI_SIMULATOR
610  logMsg("command %c\r\n", command);
611 #endif
612 
613  uint32_t expectedCrc = *(uint32_t*) (tsChannel->scratchBuffer + incomingPacketSize);
614 
615  expectedCrc = SWAP_UINT32(expectedCrc);
616 
617  uint32_t actualCrc = crc32(tsChannel->scratchBuffer, incomingPacketSize);
618  if (actualCrc != expectedCrc) {
619  /* send error only if previously we were in sync */
620  if (tsChannel->in_sync) {
621  efiPrintf("TunerStudio: command %c actual CRC %x/expected %x", tsChannel->scratchBuffer[0],
622  (unsigned int)actualCrc, (unsigned int)expectedCrc);
623  tunerStudioError(tsChannel, "ERROR: CRC issue");
624  sendErrorCode(tsChannel, TS_RESPONSE_CRC_FAILURE, "crc_issue");
625  tsChannel->in_sync = false;
626  }
627  return -1;
628  }
629 
630  /* we were able to receive known command with correct crc and size! */
631  tsChannel->in_sync = true;
632 
633  int success = tsInstance.handleCrcCommand(tsChannel, tsChannel->scratchBuffer, incomingPacketSize);
634 
635  if (!success) {
636  efiPrintf("got unexpected TunerStudio command %x:%c", command, command);
637  return -1;
638  }
639 
640  return 0;
641 }
void bluetoothSoftwareDisconnectNotify(SerialTsChannelBase *tsChannel)
Definition: bluetooth.cpp:338
virtual bool isReady() const
const char * name
char scratchBuffer[BLOCKING_FACTOR+30]
virtual size_t readTimeout(uint8_t *buffer, size_t size, int timeout)=0
bool handlePlainCommand(TsChannelBase *tsChannel, uint8_t command)
int handleCrcCommand(TsChannelBase *tsChannel, char *data, int incomingPacketSize)
uint32_t SWAP_UINT32(uint32_t x)
Definition: efilib.h:27
@ STACK_USAGE_COMMUNICATION
static bool isKnownCommand(char command)
TunerStudio tsInstance
void sendErrorCode(TsChannelBase *tsChannel, uint8_t code, const char *msg)
void tunerStudioError(TsChannelBase *tsChannel, const char *msg)
SerialTsChannelBase * getBluetoothChannel()

Referenced by TunerstudioThread::ThreadTask().

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

148  {
149 #if EFI_TUNER_STUDIO_VERBOSE
150  efiPrintf("%s: %s", tsChannel->name, msg);
151 #endif /* EFI_TUNER_STUDIO_VERBOSE */
152 }

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

664  {
665  tunerStudioDebug(tsChannel, msg);
668 }

Referenced by TunerStudio::handleCrcCommand(), tsProcessOne(), and validateOffsetCount().

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

◆ validateOffsetCount()

bool validateOffsetCount ( size_t  offset,
size_t  count,
TsChannelBase tsChannel 
)

Definition at line 19 of file tunerstudio_commands.cpp.

19  {
20  if (offset + count > getTunerStudioPageSize()) {
21  efiPrintf("TS: Project mismatch? Too much configuration requested %d/%d", offset, count);
22  tunerStudioError(tsChannel, "ERROR: out of range");
23  sendErrorCode(tsChannel, TS_RESPONSE_OUT_OF_RANGE, "bad_offset");
24  return true;
25  }
26 
27  return false;
28 }
static constexpr size_t getTunerStudioPageSize()

Referenced by TunerStudio::handleCrc32Check(), TunerStudio::handlePageReadCommand(), TunerStudio::handleWriteChunkCommand(), and TunerStudio::handleWriteValueCommand().

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

Variable Documentation

◆ console_line_callback

CommandHandler console_line_callback
extern

Definition at line 53 of file console_io.cpp.

Referenced by TunerStudio::handleExecuteCommand(), and startConsole().

◆ rebootForPresetPending

bool rebootForPresetPending
extern

◆ tsInstance

TunerStudio tsInstance

Definition at line 509 of file tunerstudio.cpp.

Referenced by tsProcessOne().

◆ tsState

Go to the source code of this file.