auto-sync

This commit is contained in:
rusEfi 2015-03-11 23:04:52 -05:00
parent 5fd6f2eff4
commit 8e85ee8945
5 changed files with 32 additions and 2 deletions

View File

@ -251,6 +251,23 @@ void handleWriteChunkCommand(ts_channel_s *tsChannel, ts_response_format_e mode,
printTsStats();
}
void handleCrc32Check(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t pageId, uint16_t offset, uint16_t count) {
tsState.crc32CheckCommandCounter++;
count = SWAP_UINT16(count);
count = 14008;
scheduleMsg(tsLogger, "CRC32 request: offset %d size %d", offset, count);
uint32_t crc = SWAP_UINT32(crc32((void *) getWorkingPageAddr(0), count));
scheduleMsg(tsLogger, "CRC32 response: %x", crc);
tsSendResponse(tsChannel, mode, (const uint8_t *)&crc, 4);
}
/**
* 'Write' command receives a single value at a given offset
* @note Writing values one by one is pretty slow
@ -362,7 +379,8 @@ static bool isKnownCommand(char command) {
return command == TS_HELLO_COMMAND || command == TS_READ_COMMAND || command == TS_OUTPUT_COMMAND
|| command == TS_PAGE_COMMAND || command == TS_BURN_COMMAND || command == TS_SINGLE_WRITE_COMMAND
|| command == TS_LEGACY_HELLO_COMMAND || command == TS_CHUNK_WRITE_COMMAND
|| command == TS_EXECUTE || command == TS_GET_TEXT;
|| command == TS_EXECUTE || command == TS_GET_TEXT
|| command == TS_CRC_CHECK_COMMAND;
}
static uint8_t firstByte;
@ -648,6 +666,11 @@ int tunerStudioHandleCrcCommand(ts_channel_s *tsChannel, char *data, int incomin
uint16_t offset = *(uint16_t *) (data + 2);
uint8_t value = data[4];
handleWriteValueCommand(tsChannel, TS_CRC, page, offset, value);
} else if (command == TS_CRC_CHECK_COMMAND) {
uint16_t page = *(uint16_t *) data;
uint16_t offset = *(uint16_t *) (data + 2);
uint16_t count = *(uint16_t *) (data + 4);
handleCrc32Check(tsChannel, TS_CRC, page, offset, count);
} else if (command == TS_BURN_COMMAND) {
uint16_t page = *(uint16_t *) data;
handleBurnCommand(tsChannel, TS_CRC, page);

View File

@ -24,6 +24,7 @@ typedef struct {
int burnCommandCounter;
int pageCommandCounter;
int writeValueCommandCounter;
int crc32CheckCommandCounter;
int writeChunkCommandCounter;
int errorCounter;
int tsCounter;

View File

@ -51,6 +51,8 @@ typedef struct {
#define TS_CHUNK_WRITE_COMMAND 'C'
#define TS_BURN_COMMAND 'B'
#define TS_CRC_CHECK_COMMAND 'k'
#define CRC_VALUE_SIZE 4
// todo: double-check this
#define CRC_WRAPPING_SIZE (CRC_VALUE_SIZE + 3)

View File

@ -276,5 +276,5 @@ int getRusEfiVersion(void) {
return 1; // this is here to make the compiler happy about the unused array
if (UNUSED_CCM_SIZE[0] == 0)
return 1; // this is here to make the compiler happy about the unused array
return 20150310;
return 20150311;
}

View File

@ -13,6 +13,8 @@ enable2ndByteCanID = false
endianness = little
nPages = 1
pageSize = 14008
pageIdentifier = "\x00\x00"
pageReadCommand = "R\x00\x00%2o%2c"
@ -20,6 +22,8 @@ enable2ndByteCanID = false
pageActivate = "P\x00\x00"
pageValueWrite = "W\x00\x00%2o%v"
pageChunkWrite = "C\x00\x00%2o%2c%v"
; crc32CheckCommand = "k%2i%2o\xB8\x36"
crc32CheckCommand = "k\x00\x00\x00\x00\x36\xB8"
;communication settings
;e.g. put writeblocks off and add an interwrite delay