TS SD integration #1653

This commit is contained in:
rusefi 2020-08-06 22:05:26 -04:00
parent a8ac9bc201
commit 0ebe7ba059
7 changed files with 42 additions and 4 deletions

View File

@ -23,7 +23,9 @@ typedef enum {
} ts_response_format_e; } ts_response_format_e;
struct ts_channel_s { struct ts_channel_s {
#if ! EFI_UNIT_TEST
BaseChannel * channel = nullptr; BaseChannel * channel = nullptr;
#endif
uint8_t writeBuffer[7]; // size(2 bytes) + response(1 byte) + crc32 (4 bytes) uint8_t writeBuffer[7]; // size(2 bytes) + response(1 byte) + crc32 (4 bytes)
/** /**
* See 'blockingFactor' in rusefi.ini * See 'blockingFactor' in rusefi.ini

View File

@ -52,8 +52,6 @@ static int totalSyncCounter = 0;
#define LOG_INDEX_FILENAME "index.txt" #define LOG_INDEX_FILENAME "index.txt"
#define DOT_MLG ".mlg"
#define RUSEFI_LOG_PREFIX "re_" #define RUSEFI_LOG_PREFIX "re_"
#define PREFIX_LEN 3 #define PREFIX_LEN 3
#define SHORT_TIME_LEN 13 #define SHORT_TIME_LEN 13

View File

@ -11,6 +11,9 @@
#include "tunerstudio_io.h" #include "tunerstudio_io.h"
#define DOT_MLG ".mlg"
bool isLogFile(const char *fileName);
void initMmcCard(void); void initMmcCard(void);
bool isSdCardAlive(void); bool isSdCardAlive(void);
void appendToLog(const char *line, size_t length); void appendToLog(const char *line, size_t length);

View File

@ -5,6 +5,28 @@
#include "global.h" #include "global.h"
#if EFI_FILE_LOGGING || EFI_SIMULATOR || EFI_UNIT_TEST
#include "mmc_card.h"
#include "efilib.h"
/**
* for funny reasons file name has to be at least 4 symbols before the dot
*/
bool isLogFile(const char *fileName) {
int dotIndex = indexOf(fileName, '.');
if (dotIndex == -1) {
return false;
}
if (dotIndex < 4) {
return false;
}
return 0 == strncmp(fileName + dotIndex, DOT_MLG, 4);
}
#endif
#if EFI_FILE_LOGGING || EFI_SIMULATOR #if EFI_FILE_LOGGING || EFI_SIMULATOR
#include "mmc_card.h" #include "mmc_card.h"

View File

@ -96,7 +96,7 @@ bool startsWith(const char *line, const char *prefix) {
} }
int indexOf(const char *string, char ch) { int indexOf(const char *string, char ch) {
// todo: there should be a standard function for this // a standard function for this is strnchr?
// todo: on the other hand MISRA wants us not to use standard headers // todo: on the other hand MISRA wants us not to use standard headers
int len = efiStrlen(string); int len = efiStrlen(string);
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {

View File

@ -327,6 +327,12 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
response[offset + 11] = 1; // file response[offset + 11] = 1; // file
// 12-15 = undefined // 12-15 = undefined
response[offset + 14] = 0x11;
response[offset + 15] = 0x13; // time
response[offset + 16] = 0x24;
response[offset + 17] = 0x25; // 0x2425 = FAT16 date format September 4, 1998
for (int i = 18; i < 22; i++) for (int i = 18; i < 22; i++)
response[offset + i] = (byte) (i + 10 * index); // sector number response[offset + i] = (byte) (i + 10 * index); // sector number

View File

@ -17,7 +17,7 @@
#include "engine_controller.h" #include "engine_controller.h"
#include "nmea.h" #include "nmea.h"
#include "mmc_card.h"
#include "lcd_menu_tree.h" #include "lcd_menu_tree.h"
#include "crc.h" #include "crc.h"
#include "fl_stack.h" #include "fl_stack.h"
@ -28,6 +28,13 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
TEST(util, isLogFileName) {
ASSERT_FALSE(isLogFile("aaaa"));
ASSERT_FALSE(isLogFile("aaa.mlq"));
ASSERT_TRUE (isLogFile("aaaa.mlg"));
ASSERT_FALSE(isLogFile("aaaa.aaa"));
}
TEST(util, negativeZero) { TEST(util, negativeZero) {
ASSERT_TRUE(IS_NEGATIVE_ZERO(-0.0)); ASSERT_TRUE(IS_NEGATIVE_ZERO(-0.0));