diff --git a/firmware/chibios/os/ports/GCC/ARMCMx/chcore_v7m.h b/firmware/chibios/os/ports/GCC/ARMCMx/chcore_v7m.h index 8abe905783..1125859e21 100644 --- a/firmware/chibios/os/ports/GCC/ARMCMx/chcore_v7m.h +++ b/firmware/chibios/os/ports/GCC/ARMCMx/chcore_v7m.h @@ -486,10 +486,18 @@ struct context { #define port_wait_for_interrupt() #endif -void chDbgStackOverflowPanic(Thread *otp); +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ +void chDbgStackOverflowPanic(Thread *otp); int getRemainingStack(Thread *otp); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + /** * @brief Performs a context switch between two threads. * @details This is the most critical code in any port, this function diff --git a/firmware/console/console_io.cpp b/firmware/console/console_io.cpp index eabf8a12ce..d19b9c2526 100644 --- a/firmware/console/console_io.cpp +++ b/firmware/console/console_io.cpp @@ -112,7 +112,7 @@ static bool getConsoleLine(BaseSequentialStream *chp, char *line, unsigned size) // todo: this is ugly as hell! static char consoleInput[] = " "; -void (*console_line_callback)(char *); +CommandHandler console_line_callback; static bool is_serial_over_uart; @@ -200,7 +200,7 @@ static void switchToBinaryProtocol(void) { scheduleMsg(logger, "switching to binary protocol"); } -void startConsole(Logging *sharedLogger, void (*console_line_callback_p)(char *)) { +void startConsole(Logging *sharedLogger, CommandHandler console_line_callback_p) { logger = sharedLogger; console_line_callback = console_line_callback_p; diff --git a/firmware/console/console_io.h b/firmware/console/console_io.h index f7aa7711e5..68a6e8ed91 100644 --- a/firmware/console/console_io.h +++ b/firmware/console/console_io.h @@ -11,12 +11,7 @@ #include #include -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif +typedef void (*CommandHandler)(char *); #include "efifeatures.h" #include "datalogging.h" @@ -24,16 +19,11 @@ #define GET_CONSOLE_MODE_VALUE() palReadPad(CONSOLE_MODE_SWITCH_PORT, CONSOLE_MODE_SWITCH_PIN) #define SHOULD_INGORE_FLASH() (palReadPad(CONFIG_RESET_SWITCH_PORT, CONFIG_RESET_SWITCH_PIN) == 0) -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - SerialDriver * getConsoleChannel(void); void consolePutChar(int x); void consoleOutputBuffer(const uint8_t *buf, int size); -void startConsole(Logging *sharedLogger, void (*console_line_callback_p)(char *)); +void startConsole(Logging *sharedLogger, CommandHandler console_line_callback_p); bool isSerialOverUart(void); #if EFI_PROD_CODE || EFI_SIMULATOR || EFI_EGT @@ -42,8 +32,4 @@ bool isConsoleReady(void); #define isConsoleReady() true #endif -#ifdef __cplusplus -} -#endif /* __cplusplus */ - #endif /* CONSOLE_IO_H_ */ diff --git a/firmware/console/eficonsole.h b/firmware/console/eficonsole.h index de1eb453b5..7cba687ff2 100644 --- a/firmware/console/eficonsole.h +++ b/firmware/console/eficonsole.h @@ -15,14 +15,4 @@ void initializeConsole(Logging *sharedLogger); void print(const char *fmt, ...); -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - #endif /* RFICONSOLE_H_ */ diff --git a/firmware/console/tunerstudio/tunerstudio.cpp b/firmware/console/tunerstudio/tunerstudio.cpp index eaeb9337e1..bbb99a08cc 100644 --- a/firmware/console/tunerstudio/tunerstudio.cpp +++ b/firmware/console/tunerstudio/tunerstudio.cpp @@ -97,7 +97,7 @@ extern persistent_config_container_s persistentState; static efitimems_t previousWriteReportMs = 0; -static uint8_t crcReadBuffer[300]; +static char crcReadBuffer[300]; extern uint8_t crcWriteBuffer[300]; static int ts_serial_ready(void) { @@ -405,7 +405,7 @@ void runBinaryProtocolLoop(void) { continue; } - recieved = chnReadTimeout(getTsSerialDevice(), crcReadBuffer, 1, MS2ST(TS_READ_TIMEOUT)); + recieved = chnReadTimeout(getTsSerialDevice(), (uint8_t*)crcReadBuffer, 1, MS2ST(TS_READ_TIMEOUT)); if (recieved != 1) { tunerStudioError("ERROR: did not receive command"); continue; @@ -526,6 +526,11 @@ void handleTestCommand(void) { tunerStudioWriteData((const uint8_t *) " ts_p_alive\r\n", 8); } +static void handleExecuteCommand(char *data, int incomingPacketSize) { + data[incomingPacketSize] = 0; + +} + /** * @return true if legacy command was processed, false otherwise */ @@ -597,12 +602,14 @@ bool handlePlainCommand(uint8_t command) { } } -int tunerStudioHandleCrcCommand(uint8_t *data, int incomingPacketSize) { +int tunerStudioHandleCrcCommand(char *data, int incomingPacketSize) { char command = data[0]; data++; if (command == TS_HELLO_COMMAND || command == TS_HELLO_COMMAND_DEPRECATED) { tunerStudioDebug("got Query command"); handleQueryCommand(TS_CRC); + } else if (command == TS_EXECUTE) { + handleExecuteCommand(data, incomingPacketSize); } else if (command == TS_OUTPUT_COMMAND) { handleOutputChannelsCommand(TS_CRC); } else if (command == TS_PAGE_COMMAND) { diff --git a/firmware/console/tunerstudio/tunerstudio.h b/firmware/console/tunerstudio/tunerstudio.h index edd0c551b7..993ac11172 100644 --- a/firmware/console/tunerstudio/tunerstudio.h +++ b/firmware/console/tunerstudio/tunerstudio.h @@ -30,7 +30,7 @@ typedef struct { } tunerstudio_counters_s; bool handlePlainCommand(uint8_t command); -int tunerStudioHandleCrcCommand(uint8_t *data, int incomingPacketSize); +int tunerStudioHandleCrcCommand(char *data, int incomingPacketSize); void handleTestCommand(void); void handleQueryCommand(ts_response_format_e mode); diff --git a/firmware/console/tunerstudio/tunerstudio_io.h b/firmware/console/tunerstudio/tunerstudio_io.h index 161dd8ba42..52e19effbf 100644 --- a/firmware/console/tunerstudio/tunerstudio_io.h +++ b/firmware/console/tunerstudio/tunerstudio_io.h @@ -33,6 +33,7 @@ typedef enum { #define TS_READ_COMMAND 'R' #define TS_PAGE_COMMAND 'P' #define TS_COMMAND_F 'F' +#define TS_EXECUTE 'E' #define TS_SINGLE_WRITE_COMMAND 'W' #define TS_CHUNK_WRITE_COMMAND 'C' diff --git a/firmware/main.h b/firmware/main.h index 8d2a092d74..2c0cc8e058 100644 --- a/firmware/main.h +++ b/firmware/main.h @@ -10,6 +10,8 @@ #include +#include "efilib.h" + #ifdef __cplusplus extern "C" { @@ -17,7 +19,6 @@ extern "C" #include "global.h" -#include "efilib.h" #include "rusefi.h" #include "efifeatures.h" diff --git a/firmware/util/efilib.h b/firmware/util/efilib.h index 4610e7da2b..4a84c7bdd4 100644 --- a/firmware/util/efilib.h +++ b/firmware/util/efilib.h @@ -26,22 +26,15 @@ // number of microseconds in one period of given frequency (per second) #define frequency2periodUs(freq) ((1000000.0f) / (freq)) -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE (!FALSE) -#endif +#define ERROR_CODE 311223344 + +const char * boolToString(bool value); #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -#define ERROR_CODE 311223344 - -const char * boolToString(bool value); - uint32_t efiStrlen(const char *param); int efiPow10(int param); bool startsWith(const char *line, const char *prefix);