start peeling out ts commands (#2045)
* start peeling out commands * guard Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
ac186d2b85
commit
99b9391ae8
|
@ -211,6 +211,10 @@ static void sendErrorCode(ts_channel_s *tsChannel, uint8_t code) {
|
||||||
sr5WriteCrcPacket(tsChannel, code, nullptr, 0);
|
sr5WriteCrcPacket(tsChannel, code, nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TunerStudio::sendErrorCode(ts_channel_s* tsChannel, uint8_t code) {
|
||||||
|
::sendErrorCode(tsChannel, code);
|
||||||
|
}
|
||||||
|
|
||||||
static void handlePageSelectCommand(ts_channel_s *tsChannel, ts_response_format_e mode) {
|
static void handlePageSelectCommand(ts_channel_s *tsChannel, ts_response_format_e mode) {
|
||||||
tsState.pageCommandCounter++;
|
tsState.pageCommandCounter++;
|
||||||
|
|
||||||
|
@ -460,7 +464,7 @@ static bool isKnownCommand(char command) {
|
||||||
|| command == TS_GET_CONFIG_ERROR;
|
|| command == TS_GET_CONFIG_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
TunerStudioBase tsInstance;
|
TunerStudio tsInstance(&tsLogger);
|
||||||
|
|
||||||
static void tsProcessOne(ts_channel_s* tsChannel) {
|
static void tsProcessOne(ts_channel_s* tsChannel) {
|
||||||
validateStack("communication", STACK_USAGE_COMMUNICATION, 128);
|
validateStack("communication", STACK_USAGE_COMMUNICATION, 128);
|
||||||
|
@ -616,24 +620,6 @@ void handleQueryCommand(ts_channel_s *tsChannel, ts_response_format_e mode) {
|
||||||
sr5SendResponse(tsChannel, mode, (const uint8_t *)signature, strlen(signature) + 1);
|
sr5SendResponse(tsChannel, mode, (const uint8_t *)signature, strlen(signature) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 'Output' command sends out a snapshot of current values
|
|
||||||
* Gauges refresh
|
|
||||||
*/
|
|
||||||
static void handleOutputChannelsCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t offset, uint16_t count) {
|
|
||||||
if (offset + count > sizeof(TunerStudioOutputChannels)) {
|
|
||||||
scheduleMsg(&tsLogger, "TS: Version Mismatch? Too much outputs requested %d/%d/%d", offset, count,
|
|
||||||
sizeof(TunerStudioOutputChannels));
|
|
||||||
sendErrorCode(tsChannel, TS_RESPONSE_OUT_OF_RANGE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
tsState.outputChannelsCommandCounter++;
|
|
||||||
prepareTunerStudioOutputs();
|
|
||||||
// this method is invoked too often to print any debug information
|
|
||||||
sr5SendResponse(tsChannel, mode, ((const uint8_t *) &tsOutputChannels) + offset, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rusEfi own test command
|
* rusEfi own test command
|
||||||
*/
|
*/
|
||||||
|
@ -659,10 +645,10 @@ static void handleTestCommand(ts_channel_s *tsChannel) {
|
||||||
|
|
||||||
extern CommandHandler console_line_callback;
|
extern CommandHandler console_line_callback;
|
||||||
|
|
||||||
static void handleGetVersion(ts_channel_s *tsChannel, ts_response_format_e mode) {
|
static void handleGetVersion(ts_channel_s *tsChannel) {
|
||||||
static char versionBuffer[32];
|
static char versionBuffer[32];
|
||||||
chsnprintf(versionBuffer, sizeof(versionBuffer), "rusEFI v%d@%s", getRusEfiVersion(), VCS_VERSION);
|
chsnprintf(versionBuffer, sizeof(versionBuffer), "rusEFI v%d@%s", getRusEfiVersion(), VCS_VERSION);
|
||||||
sr5SendResponse(tsChannel, mode, (const uint8_t *) versionBuffer, strlen(versionBuffer) + 1);
|
sr5SendResponse(tsChannel, TS_CRC, (const uint8_t *) versionBuffer, strlen(versionBuffer) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleGetText(ts_channel_s *tsChannel) {
|
static void handleGetText(ts_channel_s *tsChannel) {
|
||||||
|
@ -743,14 +729,14 @@ int TunerStudioBase::handleCrcCommand(ts_channel_s *tsChannel, char *data, int i
|
||||||
switch(command)
|
switch(command)
|
||||||
{
|
{
|
||||||
case TS_OUTPUT_COMMAND:
|
case TS_OUTPUT_COMMAND:
|
||||||
handleOutputChannelsCommand(tsChannel, TS_CRC, offset, count);
|
cmdOutputChannels(tsChannel, offset, count);
|
||||||
break;
|
break;
|
||||||
case TS_HELLO_COMMAND:
|
case TS_HELLO_COMMAND:
|
||||||
tunerStudioDebug("got Query command");
|
tunerStudioDebug("got Query command");
|
||||||
handleQueryCommand(tsChannel, TS_CRC);
|
handleQueryCommand(tsChannel, TS_CRC);
|
||||||
break;
|
break;
|
||||||
case TS_GET_FIRMWARE_VERSION:
|
case TS_GET_FIRMWARE_VERSION:
|
||||||
handleGetVersion(tsChannel, TS_CRC);
|
handleGetVersion(tsChannel);
|
||||||
break;
|
break;
|
||||||
#if EFI_FILE_LOGGING || EFI_SIMULATOR
|
#if EFI_FILE_LOGGING || EFI_SIMULATOR
|
||||||
case TS_SD_R_COMMAND:
|
case TS_SD_R_COMMAND:
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
TUNERSTUDIO_SRC_CPP = $(PROJECT_DIR)/console/binary/tunerstudio_io.cpp \
|
TUNERSTUDIO_SRC_CPP = $(PROJECT_DIR)/console/binary/tunerstudio_io.cpp \
|
||||||
$(PROJECT_DIR)/console/binary/tunerstudio.cpp \
|
$(PROJECT_DIR)/console/binary/tunerstudio.cpp \
|
||||||
|
$(PROJECT_DIR)/console/binary/tunerstudio_commands.cpp \
|
||||||
$(PROJECT_DIR)/console/binary/bluetooth.cpp \
|
$(PROJECT_DIR)/console/binary/bluetooth.cpp \
|
||||||
$(PROJECT_DIR)/console/binary/signature.cpp
|
$(PROJECT_DIR)/console/binary/signature.cpp
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
#include "tunerstudio_impl.h"
|
||||||
|
#include "tunerstudio.h"
|
||||||
|
#include "tunerstudio_io.h"
|
||||||
|
|
||||||
|
#include "status_loop.h"
|
||||||
|
|
||||||
|
#if EFI_TUNER_STUDIO
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 'Output' command sends out a snapshot of current values
|
||||||
|
* Gauges refresh
|
||||||
|
*/
|
||||||
|
void TunerStudio::cmdOutputChannels(ts_channel_s *tsChannel, uint16_t offset, uint16_t count) {
|
||||||
|
if (offset + count > sizeof(TunerStudioOutputChannels)) {
|
||||||
|
scheduleMsg(tsLogger, "TS: Version Mismatch? Too much outputs requested %d/%d/%d", offset, count,
|
||||||
|
sizeof(TunerStudioOutputChannels));
|
||||||
|
sendErrorCode(tsChannel, TS_RESPONSE_OUT_OF_RANGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tsState.outputChannelsCommandCounter++;
|
||||||
|
prepareTunerStudioOutputs();
|
||||||
|
// this method is invoked too often to print any debug information
|
||||||
|
sr5SendResponse(tsChannel, TS_CRC, ((const uint8_t *) &tsOutputChannels) + offset, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // EFI_TUNER_STUDIO
|
|
@ -1,8 +1,28 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
class ts_channel_s;
|
class ts_channel_s;
|
||||||
|
|
||||||
class TunerStudioBase {
|
class TunerStudioBase {
|
||||||
public:
|
public:
|
||||||
int handleCrcCommand(ts_channel_s *tsChannel, char *data, int incomingPacketSize);
|
int handleCrcCommand(ts_channel_s *tsChannel, char *data, int incomingPacketSize);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void cmdOutputChannels(ts_channel_s *tsChannel, uint16_t offset, uint16_t count) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TunerStudio : public TunerStudioBase {
|
||||||
|
public:
|
||||||
|
TunerStudio(Logging* logger)
|
||||||
|
: tsLogger(logger)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmdOutputChannels(ts_channel_s *tsChannel, uint16_t offset, uint16_t count) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void sendErrorCode(ts_channel_s* tsChannel, uint8_t code);
|
||||||
|
|
||||||
|
Logging* tsLogger;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue