rusEFI
The most advanced open source ECU
Public Member Functions | Private Member Functions
TunerStudio Class Reference

#include <tunerstudio_impl.h>

Inheritance diagram for TunerStudio:
Inheritance graph
[legend]
Collaboration diagram for TunerStudio:
Collaboration graph
[legend]

Public Member Functions

int handleCrcCommand (TsChannelBase *tsChannel, char *data, int incomingPacketSize)
 
bool handlePlainCommand (TsChannelBase *tsChannel, uint8_t command)
 
void cmdOutputChannels (TsChannelBase *tsChannel, uint16_t offset, uint16_t count) override
 'Output' command sends out a snapshot of current values Gauges refresh More...
 
void handleQueryCommand (TsChannelBase *tsChannel, ts_response_format_e mode)
 
void handleExecuteCommand (TsChannelBase *tsChannel, char *data, int incomingPacketSize)
 
void handlePageSelectCommand (TsChannelBase *tsChannel)
 
void handleWriteChunkCommand (TsChannelBase *tsChannel, uint16_t offset, uint16_t count, void *content)
 
void handleCrc32Check (TsChannelBase *tsChannel, uint16_t offset, uint16_t count)
 
void handleWriteValueCommand (TsChannelBase *tsChannel, uint16_t offset, uint8_t value)
 
void handlePageReadCommand (TsChannelBase *tsChannel, uint16_t offset, uint16_t count)
 
void handleScatteredReadCommand (TsChannelBase *tsChannel)
 

Private Member Functions

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

Additional Inherited Members

Detailed Description

Definition at line 23 of file tunerstudio_impl.h.

Member Function Documentation

◆ cmdOutputChannels()

void TunerStudio::cmdOutputChannels ( TsChannelBase tsChannel,
uint16_t  offset,
uint16_t  count 
)
overridevirtual

'Output' command sends out a snapshot of current values Gauges refresh

collect data from all models

Implements TunerStudioBase.

Definition at line 46 of file tunerstudio_commands.cpp.

46  {
47  if (offset + count > TS_TOTAL_OUTPUT_SIZE) {
48  efiPrintf("TS: Version Mismatch? Too much outputs requested offset=%d + count=%d/total=%d", offset, count,
50  sendErrorCode(tsChannel, TS_RESPONSE_OUT_OF_RANGE, "cmd_size");
51  return;
52  }
53 
54  if (offset < BLOCKING_FACTOR) {
56  channelsRequestTimer.reset();
57  }
58 
61  tsChannel->assertPacketSize(count, false);
62  // this method is invoked too often to print any debug information
63  uint8_t * scratchBuffer = (uint8_t *)tsChannel->scratchBuffer;
64  /**
65  * collect data from all models
66  */
67  copyRange(scratchBuffer + 3, getLiveDataFragments(), offset, count);
68 
69  tsChannel->crcAndWriteBuffer(TS_RESPONSE_OK, count);
70 }
TunerStudioOutputChannels outputChannels
Definition: engine.h:99
void crcAndWriteBuffer(const uint8_t responseCode, const size_t size)
char scratchBuffer[BLOCKING_FACTOR+30]
void assertPacketSize(size_t size, bool allowLongPackets)
void sendErrorCode(TsChannelBase *tsChannel, uint8_t code, const char *msg="")
Engine * engine
FragmentList getLiveDataFragments()
Definition: live_data.cpp:224
tunerstudio_counters_s tsState
void updateTunerStudioState()
static Timer channelsRequestTimer

Referenced by handleCrcCommand().

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

◆ handleCrc32Check()

void TunerStudio::handleCrc32Check ( TsChannelBase tsChannel,
uint16_t  offset,
uint16_t  count 
)

Definition at line 236 of file tunerstudio.cpp.

236  {
238 
239  // Ensure we are reading from in bounds
240  if (validateOffsetCount(offset, count, tsChannel)) {
241  return;
242  }
243 
244 #if EFI_TS_SCATTER
245  /*
246  * highSpeedOffsets is noMsqSave, but located on settings page,
247  * zero highSpeedOffsets as TS expect all noMsqSave data to be zero during CRC matching
248  * TODO:
249  * Move highSpeedOffsets to separate page as it is done on MS devices
250  * Zero highSpeedOffsets on start and reconnect
251  * TODO:
252  * Is Crc check command good sing of new TS session?
253  * TODO:
254  * Support settings pages!
255  */
257 #endif // EFI_TS_SCATTER
258 
259  const uint8_t* start = getWorkingPageAddr() + offset;
260 
261  uint32_t crc = SWAP_UINT32(crc32(start, count));
262  tsChannel->sendResponse(TS_CRC, (const uint8_t *) &crc, 4);
263  efiPrintf("TS <- Get CRC offset %d count %d result %08x", offset, count, (unsigned int)crc);
264 }
void sendResponse(ts_response_format_e mode, const uint8_t *buffer, int size, bool allowLongPackets=false)
uint32_t SWAP_UINT32(uint32_t x)
Definition: efilib.h:27
engine_configuration_s * engineConfiguration
bool validateOffsetCount(size_t offset, size_t count, TsChannelBase *tsChannel)
uint8_t * getWorkingPageAddr()
@ TS_CRC

Referenced by handleCrcCommand().

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

◆ handleCrcCommand()

int TunerStudio::handleCrcCommand ( TsChannelBase tsChannel,
char *  data,
int  incomingPacketSize 
)

Definition at line 712 of file tunerstudio.cpp.

712  {
714 
715  char command = data[0];
716  data++;
717 
718  const uint16_t* data16 = reinterpret_cast<uint16_t*>(data);
719 
720  uint16_t offset = 0;
721  uint16_t count = 0;
722 
723  // command may not have offset field - keep safe default value
724  // not used by .ini at the moment TODO actually use that version of the command in the .ini
725  if (incomingPacketSize >= 3) {
726  offset = data16[0];
727  }
728  // command may not have count/size filed - keep safe default value
729  if (incomingPacketSize >= 5) {
730  count = data16[1];
731  }
732 
733  switch(command)
734  {
735  case TS_OUTPUT_COMMAND:
736  if (incomingPacketSize == 1) {
737  // Read command with no offset and size - read whole livedata
738  count = TS_TOTAL_OUTPUT_SIZE;
739  }
740  cmdOutputChannels(tsChannel, offset, count);
741  break;
742  case TS_HELLO_COMMAND:
743  tunerStudioDebug(tsChannel, "got Query command");
744  handleQueryCommand(tsChannel, TS_CRC);
745  break;
746  case TS_GET_FIRMWARE_VERSION:
747  handleGetVersion(tsChannel);
748  break;
749 #if EFI_TEXT_LOGGING
750  case TS_GET_TEXT:
751  handleGetText(tsChannel);
752  break;
753 #endif // EFI_TEXT_LOGGING
754  case TS_EXECUTE:
755  handleExecuteCommand(tsChannel, data, incomingPacketSize - 1);
756  break;
757  case TS_PAGE_COMMAND:
758  handlePageSelectCommand(tsChannel);
759  break;
760  case TS_CHUNK_WRITE_COMMAND:
761  handleWriteChunkCommand(tsChannel, offset, count, data + sizeof(TunerStudioWriteChunkRequest));
762  break;
763  case TS_SINGLE_WRITE_COMMAND:
764  {
765  uint8_t value = data[4];
766  handleWriteValueCommand(tsChannel, offset, value);
767  }
768  break;
769  case TS_GET_SCATTERED_GET_COMMAND:
770 #if EFI_TS_SCATTER
771  handleScatteredReadCommand(tsChannel);
772 #else
773  criticalError("Slow/wireless mode not supported");
774 #endif // EFI_TS_SCATTER
775  break;
776  case TS_CRC_CHECK_COMMAND:
777  handleCrc32Check(tsChannel, offset, count);
778  break;
779  case TS_BURN_COMMAND:
780  handleBurnCommand(tsChannel);
781  break;
782  case TS_READ_COMMAND:
783  handlePageReadCommand(tsChannel, offset, count);
784  break;
785  case TS_TEST_COMMAND:
786  [[fallthrough]];
787  case 'T':
788  handleTestCommand(tsChannel);
789  break;
790 #if EFI_SIMULATOR
791  case TS_SIMULATE_CAN:
792  void handleWrapCan(TsChannelBase* tsChannel, char *data, int incomingPacketSize);
793  handleWrapCan(tsChannel, data, incomingPacketSize - 1);
794  break;
795 #endif // EFI_SIMULATOR
796  case TS_IO_TEST_COMMAND:
797  {
798 #if EFI_PROD_CODE
799  uint16_t subsystem = SWAP_UINT16(data16[0]);
800  uint16_t index = SWAP_UINT16(data16[1]);
801 
802  executeTSCommand(subsystem, index);
803 #endif /* EFI_PROD_CODE */
804  sendOkResponse(tsChannel);
805  }
806  break;
807 #if EFI_TOOTH_LOGGER
808  case TS_SET_LOGGER_SWITCH:
809  switch(data[0]) {
810  case TS_COMPOSITE_ENABLE:
812  break;
813  case TS_COMPOSITE_DISABLE:
815  break;
816  case TS_COMPOSITE_READ:
817  {
818  auto toothBuffer = GetToothLoggerBufferNonblocking();
819 
820  if (toothBuffer) {
821  tsChannel->sendResponse(TS_CRC, reinterpret_cast<const uint8_t*>(toothBuffer->buffer), toothBuffer->nextIdx * sizeof(composite_logger_s), true);
822 
823  ReturnToothLoggerBuffer(toothBuffer);
824  } else {
825  // TS asked for a tooth logger buffer, but we don't have one to give it.
826  sendErrorCode(tsChannel, TS_RESPONSE_OUT_OF_RANGE, DO_NOT_LOG);
827  }
828  }
829  break;
830 #ifdef TRIGGER_SCOPE
831  case TS_TRIGGER_SCOPE_ENABLE:
833  break;
834  case TS_TRIGGER_SCOPE_DISABLE:
836  break;
837  case TS_TRIGGER_SCOPE_READ:
838  {
839  const auto& buffer = triggerScopeGetBuffer();
840 
841  if (buffer) {
842  tsChannel->sendResponse(TS_CRC, buffer.get<uint8_t>(), buffer.size(), true);
843  } else {
844  // TS asked for a tooth logger buffer, but we don't have one to give it.
845  sendErrorCode(tsChannel, TS_RESPONSE_OUT_OF_RANGE, DO_NOT_LOG);
846  }
847  }
848  break;
849 #endif // TRIGGER_SCOPE
850  default:
851  // dunno what that was, send NAK
852  return false;
853  }
854 
855  sendOkResponse(tsChannel);
856 
857  break;
858  case TS_GET_COMPOSITE_BUFFER_DONE_DIFFERENTLY:
859  {
861 
862  auto toothBuffer = GetToothLoggerBufferNonblocking();
863 
864  if (toothBuffer) {
865  tsChannel->sendResponse(TS_CRC, reinterpret_cast<const uint8_t*>(toothBuffer->buffer), toothBuffer->nextIdx * sizeof(composite_logger_s), true);
866 
867  ReturnToothLoggerBuffer(toothBuffer);
868  } else {
869  // TS asked for a tooth logger buffer, but we don't have one to give it.
870  sendErrorCode(tsChannel, TS_RESPONSE_OUT_OF_RANGE, DO_NOT_LOG);
871  }
872  }
873 
874  break;
875 #else // EFI_TOOTH_LOGGER
876  case TS_GET_COMPOSITE_BUFFER_DONE_DIFFERENTLY:
877  sendErrorCode(tsChannel, TS_RESPONSE_OUT_OF_RANGE, DO_NOT_LOG);
878  break;
879 #endif /* EFI_TOOTH_LOGGER */
880 #ifdef KNOCK_SPECTROGRAM
881  case TS_KNOCK_SPECTROGRAM_ENABLE:
883  sendOkResponse(tsChannel);
884  break;
885  case TS_KNOCK_SPECTROGRAM_DISABLE:
887  sendOkResponse(tsChannel);
888  break;
889 #endif /* KNOCK_SPECTROGRAM */
890 #if ENABLE_PERF_TRACE
891  case TS_PERF_TRACE_BEGIN:
892  perfTraceEnable();
893  sendOkResponse(tsChannel);
894  break;
895  case TS_PERF_TRACE_GET_BUFFER:
896  {
897  auto trace = perfTraceGetBuffer();
898  tsChannel->sendResponse(TS_CRC, trace.get<uint8_t>(), trace.size(), true);
899  }
900 
901  break;
902 #endif /* ENABLE_PERF_TRACE */
903  case TS_GET_CONFIG_ERROR: {
904  const char* configError = getCriticalErrorMessage();
905 #if HW_CHECK_MODE
906  // analog input errors are returned as firmware error in QC mode
907  if (!hasFirmwareError()) {
908  strcpy((char*)configError, "FACTORY_MODE_PLEASE_CONTACT_SUPPORT");
909  }
910 #endif // HW_CHECK_MODE
911  tsChannel->sendResponse(TS_CRC, reinterpret_cast<const uint8_t*>(configError), strlen(configError), true);
912  break;
913  }
914  case TS_QUERY_BOOTLOADER: {
915  uint8_t bldata = TS_QUERY_BOOTLOADER_NONE;
916 #if EFI_USE_OPENBLT
917  bldata = TS_QUERY_BOOTLOADER_OPENBLT;
918 #endif
919 
920  tsChannel->sendResponse(TS_CRC, &bldata, 1, false);
921  break;
922  }
923  default:
924  sendErrorCode(tsChannel, TS_RESPONSE_UNRECOGNIZED_COMMAND, "unknown_command");
925 static char tsErrorBuff[80];
926  chsnprintf(tsErrorBuff, sizeof(tsErrorBuff), "ERROR: ignoring unexpected command %d [%c]", command, command);
927  tunerStudioError(tsChannel, tsErrorBuff);
928  return false;
929  }
930 
931  return true;
932 }
void executeTSCommand(uint16_t subsystem, uint16_t index)
Definition: bench_test.cpp:539
size_t size() const
Definition: big_buffer.h:43
const TBuffer * get() const
Definition: big_buffer.h:34
void handleScatteredReadCommand(TsChannelBase *tsChannel)
void handleWriteChunkCommand(TsChannelBase *tsChannel, uint16_t offset, uint16_t count, void *content)
void handlePageSelectCommand(TsChannelBase *tsChannel)
void handleQueryCommand(TsChannelBase *tsChannel, ts_response_format_e mode)
void cmdOutputChannels(TsChannelBase *tsChannel, uint16_t offset, uint16_t count) override
'Output' command sends out a snapshot of current values Gauges refresh
void handleCrc32Check(TsChannelBase *tsChannel, uint16_t offset, uint16_t count)
void handleWriteValueCommand(TsChannelBase *tsChannel, uint16_t offset, uint8_t value)
void handlePageReadCommand(TsChannelBase *tsChannel, uint16_t offset, uint16_t count)
void handleExecuteCommand(TsChannelBase *tsChannel, char *data, int incomingPacketSize)
uint16_t SWAP_UINT16(uint16_t x)
Definition: efilib.h:22
const char * getCriticalErrorMessage(void)
const BigBufferHandle perfTraceGetBuffer()
Definition: perf_trace.cpp:132
void perfTraceEnable()
Definition: perf_trace.cpp:119
@ TunerStudioHandleCrcCommand
void knockSpectrogramEnable()
void knockSpectrogramDisable()
void DisableToothLogger()
void EnableToothLogger()
CompositeBuffer * GetToothLoggerBufferNonblocking()
void ReturnToothLoggerBuffer(CompositeBuffer *buffer)
void EnableToothLoggerIfNotEnabled()
composite_logger_s
Definition: tooth_logger.h:48
void triggerScopeEnable()
const BigBufferHandle & triggerScopeGetBuffer()
static BigBufferHandle buffer
void triggerScopeDisable()
static void handleBurnCommand(TsChannelBase *tsChannel)
static void handleGetVersion(TsChannelBase *tsChannel)
static void handleGetText(TsChannelBase *tsChannel)
static void sendOkResponse(TsChannelBase *tsChannel)
static void handleTestCommand(TsChannelBase *tsChannel)
void tunerStudioDebug(TsChannelBase *tsChannel, const char *msg)
void tunerStudioError(TsChannelBase *tsChannel, const char *msg)

Referenced by tsProcessOne().

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

◆ handleExecuteCommand()

void TunerStudio::handleExecuteCommand ( TsChannelBase tsChannel,
char *  data,
int  incomingPacketSize 
)

Definition at line 701 of file tunerstudio.cpp.

701  {
702  data[incomingPacketSize] = 0;
703  char *trimmed = efiTrim(data);
704 #if EFI_SIMULATOR
705  logMsg("execute [%s]\r\n", trimmed);
706 #endif // EFI_SIMULATOR
707  (console_line_callback)(trimmed);
708 
709  tsChannel->writeCrcResponse(TS_RESPONSE_OK);
710 }
void writeCrcResponse(uint8_t responseCode)
char * efiTrim(char *param)
Definition: efilib.cpp:39
CommandHandler console_line_callback
Definition: console_io.cpp:53

Referenced by handleCrcCommand().

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

◆ handlePageReadCommand()

void TunerStudio::handlePageReadCommand ( TsChannelBase tsChannel,
uint16_t  offset,
uint16_t  count 
)

Definition at line 339 of file tunerstudio.cpp.

339  {
341 
343  sendErrorCode(tsChannel, TS_RESPONSE_UNRECOGNIZED_COMMAND, "reboot");
344  return;
345  }
346 
347  efiPrintf("TS <- Read chunk offset %d count %d", offset, count);
348 
349  if (validateOffsetCount(offset, count, tsChannel)) {
350  return;
351  }
352 
353  uint8_t* addr;
354  if (isLockedFromUser()) {
355  // to have rusEFI console happy just send all zeros within a valid packet
356  addr = (uint8_t*)&tsChannel->scratchBuffer + TS_PACKET_HEADER_SIZE;
357  memset(addr, 0, count);
358  } else {
359  addr = getWorkingPageAddr() + offset;
360  }
361  tsChannel->sendResponse(TS_CRC, addr, count);
362 #if EFI_TUNER_STUDIO_VERBOSE
363 // efiPrintf("Sending %d done", count);
364 #endif
365 }
constexpr uint8_t addr
Definition: ads1015.cpp:5
bool isLockedFromUser()
Definition: engine2.cpp:256
bool rebootForPresetPending

Referenced by handleCrcCommand().

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

◆ handlePageSelectCommand()

void TunerStudio::handlePageSelectCommand ( TsChannelBase tsChannel)

Definition at line 195 of file tunerstudio.cpp.

195  {
197 
198  efiPrintf("TS -> Set page (no-op)");
199 
200  sendOkResponse(tsChannel);
201 }

Referenced by handleCrcCommand().

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

◆ handlePlainCommand()

bool TunerStudio::handlePlainCommand ( TsChannelBase tsChannel,
uint8_t  command 
)

handle non CRC wrapped command

Returns
true if legacy command was processed, false otherwise

http://www.msextra.com/forums/viewtopic.php?f=122&t=48327 Response from TS support: This is an optional command * "The F command is used to find what ini. file needs to be loaded in TunerStudio to match the controller. If you are able to just make your firmware ignore the command that would work. Currently on some firmware versions the F command is not used and is just ignored by the firmware as a unknown command."

Definition at line 478 of file tunerstudio.cpp.

478  {
479  // Bail fast if guaranteed not to be a plain command
480  if (command == 0) {
481  return false;
482  } else if (command == TS_HELLO_COMMAND || command == TS_QUERY_COMMAND) {
483  // We interpret 'Q' as TS_HELLO_COMMAND, since TS uses hardcoded 'Q' during ECU detection (scan all serial ports)
484  efiPrintf("Got naked Query command");
485  handleQueryCommand(tsChannel, TS_PLAIN);
486  return true;
487  } else if (command == TS_TEST_COMMAND || command == 'T') {
488  handleTestCommand(tsChannel);
489  return true;
490  } else if (command == TS_COMMAND_F) {
491  /**
492  * http://www.msextra.com/forums/viewtopic.php?f=122&t=48327
493  * Response from TS support: This is an optional command *
494  * "The F command is used to find what ini. file needs to be loaded in TunerStudio to match the controller.
495  * If you are able to just make your firmware ignore the command that would work.
496  * Currently on some firmware versions the F command is not used and is just ignored by the firmware as a unknown command."
497  */
498 
499  tunerStudioDebug(tsChannel, "not ignoring F");
500  tsChannel->write((const uint8_t *)TS_PROTOCOL, strlen(TS_PROTOCOL));
501  tsChannel->flush();
502  return true;
503  } else {
504  // This wasn't a valid command
505  return false;
506  }
507 }
virtual void flush()
virtual void write(const uint8_t *buffer, size_t size, bool isEndOfPacket=false)=0
@ TS_PLAIN

Referenced by tsProcessOne().

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

◆ handleQueryCommand()

void TunerStudio::handleQueryCommand ( TsChannelBase tsChannel,
ts_response_format_e  mode 
)

this command is part of protocol initialization

this command is part of protocol initialization

Query with CRC takes place while re-establishing connection Query without CRC takes place on TunerStudio startup

Definition at line 465 of file tunerstudio.cpp.

465  {
467  const char *signature = getTsSignature();
468 
469  efiPrintf("TS <- Query signature: %s", signature);
470  tsChannel->sendResponse(mode, (const uint8_t *)signature, strlen(signature) + 1);
471 }
const char * getTsSignature()
Definition: signature.cpp:31

Referenced by handleCrcCommand(), and handlePlainCommand().

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

◆ handleScatteredReadCommand()

void TunerStudio::handleScatteredReadCommand ( TsChannelBase tsChannel)

Definition at line 267 of file tunerstudio.cpp.

267  {
268  int totalResponseSize = 0;
269  for (int i = 0; i < HIGH_SPEED_COUNT; i++) {
270  uint16_t packed = engineConfiguration->highSpeedOffsets[i];
271  uint16_t type = packed >> 13;
272 
273  size_t size = type == 0 ? 0 : 1 << (type - 1);
274 #if EFI_SIMULATOR
275 // printf("handleScatteredReadCommand 0x%x %d %d\n", packed, size, offset);
276 #endif /* EFI_SIMULATOR */
277  totalResponseSize += size;
278  }
279 #if EFI_SIMULATOR
280 // printf("totalResponseSize %d\n", totalResponseSize);
281 #endif /* EFI_SIMULATOR */
282 
283 
284  // Command part of CRC
285  uint32_t crc = tsChannel->writePacketHeader(TS_RESPONSE_OK, totalResponseSize);
286 
287  uint8_t dataBuffer[8];
288  for (int i = 0; i < HIGH_SPEED_COUNT; i++) {
289  uint16_t packed = engineConfiguration->highSpeedOffsets[i];
290  uint16_t type = packed >> 13;
291  uint16_t offset = packed & 0x1FFF;
292 
293  if (type == 0)
294  continue;
295  size_t size = 1 << (type - 1);
296 
297  // write each data point and CRC incrementally
298  copyRange(dataBuffer, getLiveDataFragments(), offset, size);
299  tsChannel->write(dataBuffer, size, false);
300  crc = crc32inc((void*)dataBuffer, crc, size);
301  }
302 #if EFI_SIMULATOR
303 // printf("CRC %x\n", crc);
304 #endif /* EFI_SIMULATOR */
305  // now write total CRC
306  *(uint32_t*)dataBuffer = SWAP_UINT32(crc);
307  tsChannel->write(reinterpret_cast<uint8_t*>(dataBuffer), 4, true);
308  tsChannel->flush();
309 }
uint32_t writePacketHeader(const uint8_t responseCode, const size_t size)
composite packet size

Referenced by handleCrcCommand().

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

◆ handleWriteChunkCommand()

void TunerStudio::handleWriteChunkCommand ( TsChannelBase tsChannel,
uint16_t  offset,
uint16_t  count,
void *  content 
)

This command is needed to make the whole transfer a bit faster

Note
See also handleWriteValueCommand

Definition at line 211 of file tunerstudio.cpp.

212  {
214  if (isLockedFromUser()) {
215  sendErrorCode(tsChannel, TS_RESPONSE_UNRECOGNIZED_COMMAND, "locked");
216  return;
217  }
218 
219  efiPrintf("TS -> Write chunk offset %d count %d (output_count=%d)", offset, count, tsState.outputChannelsCommandCounter);
220 
221  if (validateOffsetCount(offset, count, tsChannel)) {
222  return;
223  }
224 
225  // Skip the write if a preset was just loaded - we don't want to overwrite it
226  if (!rebootForPresetPending) {
227  uint8_t * addr = (uint8_t *) (getWorkingPageAddr() + offset);
228  memcpy(addr, content, count);
229  }
230  // Force any board configuration options that humans shouldn't be able to change
232 
233  sendOkResponse(tsChannel);
234 }
void setBoardConfigOverrides()

Referenced by handleCrcCommand().

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

◆ handleWriteValueCommand()

void TunerStudio::handleWriteValueCommand ( TsChannelBase tsChannel,
uint16_t  offset,
uint8_t  value 
)

'Write' command receives a single value at a given offset

Note
Writing values one by one is pretty slow

Definition at line 316 of file tunerstudio.cpp.

316  {
317  UNUSED(tsChannel);
318 
320  if (isLockedFromUser()) {
321  sendErrorCode(tsChannel, TS_RESPONSE_UNRECOGNIZED_COMMAND, "locked");
322  return;
323  }
324 
325  efiPrintf("TS -> Write value offset %d value %d", offset, value);
326 
327  if (validateOffsetCount(offset, 1, tsChannel)) {
328  return;
329  }
330 
331  // Skip the write if a preset was just loaded - we don't want to overwrite it
332  if (!rebootForPresetPending) {
333  getWorkingPageAddr()[offset] = value;
334  }
335  // Force any board configuration options that humans shouldn't be able to change
337 }
UNUSED(samplingTimeSeconds)

Referenced by handleCrcCommand().

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

◆ sendErrorCode()

void TunerStudio::sendErrorCode ( TsChannelBase tsChannel,
uint8_t  code,
const char *  msg = "" 
)
private

Definition at line 191 of file tunerstudio.cpp.

191  {
192  ::sendErrorCode(tsChannel, code, msg);
193 }
uint8_t code
Definition: bluetooth.cpp:40

Referenced by cmdOutputChannels(), handleCrcCommand(), handlePageReadCommand(), handleWriteChunkCommand(), and handleWriteValueCommand().

Here is the caller graph for this function:

The documentation for this class was generated from the following files: