2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file tunerstudio.h
|
|
|
|
*
|
|
|
|
* @date Aug 26, 2013
|
2020-01-13 18:57:43 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
|
2020-04-01 16:00:56 -07:00
|
|
|
#pragma once
|
2018-09-16 19:25:17 -07:00
|
|
|
#include "global.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "tunerstudio_io.h"
|
|
|
|
|
|
|
|
#if EFI_TUNER_STUDIO
|
2020-05-25 10:02:05 -07:00
|
|
|
#include "tunerstudio_outputs.h"
|
2021-03-18 11:07:22 -07:00
|
|
|
#include "thread_controller.h"
|
|
|
|
#include "thread_priority.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int queryCommandCounter;
|
|
|
|
int outputChannelsCommandCounter;
|
|
|
|
int readPageCommandsCounter;
|
|
|
|
int burnCommandCounter;
|
|
|
|
int pageCommandCounter;
|
|
|
|
int writeValueCommandCounter;
|
|
|
|
int crc32CheckCommandCounter;
|
|
|
|
int writeChunkCommandCounter;
|
|
|
|
int errorCounter;
|
2017-03-26 14:19:08 -07:00
|
|
|
int totalCounter;
|
|
|
|
int textCommandCounter;
|
2017-05-09 09:07:52 -07:00
|
|
|
int testCommandCounter;
|
2015-07-10 06:01:56 -07:00
|
|
|
} tunerstudio_counters_s;
|
|
|
|
|
2019-10-08 18:02:51 -07:00
|
|
|
extern tunerstudio_counters_s tsState;
|
|
|
|
|
2020-08-07 14:24:02 -07:00
|
|
|
// SD protocol file removal is one of the stack consuming use-cases
|
|
|
|
#define CONNECTIVITY_THREAD_STACK (3 * UTILITY_THREAD_STACK_SIZE)
|
2020-08-02 07:52:52 -07:00
|
|
|
|
2018-04-01 20:38:34 -07:00
|
|
|
/**
|
|
|
|
* handle non CRC wrapped command
|
|
|
|
*/
|
2021-02-19 23:11:39 -08:00
|
|
|
bool handlePlainCommand(TsChannelBase* tsChannel, uint8_t command);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2018-04-01 20:38:34 -07:00
|
|
|
/**
|
|
|
|
* this command is part of protocol initialization
|
|
|
|
*/
|
2021-02-19 23:11:39 -08:00
|
|
|
void handleQueryCommand(TsChannelBase* tsChannel, ts_response_format_e mode);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2020-01-07 04:56:45 -08:00
|
|
|
char *getWorkingPageAddr();
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
void tunerStudioDebug(const char *msg);
|
|
|
|
void tunerStudioError(const char *msg);
|
|
|
|
|
2017-05-15 20:33:22 -07:00
|
|
|
void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ENGINE_PARAMETER_SUFFIX);
|
2015-07-10 06:01:56 -07:00
|
|
|
void printTsStats(void);
|
|
|
|
void requestBurn(void);
|
|
|
|
|
|
|
|
void startTunerStudioConnectivity(void);
|
|
|
|
void syncTunerStudioCopy(void);
|
2021-02-19 23:11:39 -08:00
|
|
|
void runBinaryProtocolLoop(TsChannelBase* tsChannel);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
#if defined __GNUC__
|
|
|
|
// GCC
|
|
|
|
#define pre_packed
|
|
|
|
#define post_packed __attribute__((packed))
|
|
|
|
#else
|
|
|
|
// IAR
|
|
|
|
#define pre_packed __packed
|
|
|
|
#define post_packed
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef pre_packed struct
|
2020-12-08 00:05:43 -08:00
|
|
|
post_packed {
|
|
|
|
short int offset;
|
|
|
|
short int count;
|
|
|
|
} TunerStudioWriteChunkRequest;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-03-18 11:07:22 -07:00
|
|
|
class TunerstudioThread : public ThreadController<CONNECTIVITY_THREAD_STACK> {
|
|
|
|
public:
|
|
|
|
TunerstudioThread(const char* name)
|
|
|
|
: ThreadController(name, PRIO_CONSOLE)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize and return the channel to use for this thread.
|
|
|
|
virtual TsChannelBase* setupChannel() = 0;
|
|
|
|
|
|
|
|
void ThreadTask() override;
|
|
|
|
};
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
#endif /* EFI_TUNER_STUDIO */
|