BUG? handleCrc32Check does not use 'offset' parameter #1429

This commit is contained in:
rusefi 2020-05-21 00:14:08 -04:00
parent c25afadb94
commit 9ab7507e67
3 changed files with 16 additions and 32 deletions

View File

@ -233,7 +233,7 @@ static void sendErrorCode(ts_channel_s *tsChannel) {
sr5WriteCrcPacket(tsChannel, TS_RESPONSE_CRC_FAILURE, NULL, 0); sr5WriteCrcPacket(tsChannel, TS_RESPONSE_CRC_FAILURE, NULL, 0);
} }
void handlePageSelectCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t pageId) { static void handlePageSelectCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t pageId) {
tsState.pageCommandCounter++; tsState.pageCommandCounter++;
scheduleMsg(&tsLogger, "PAGE %d", pageId); scheduleMsg(&tsLogger, "PAGE %d", pageId);
@ -345,7 +345,7 @@ static void handleReadFileContent(ts_channel_s *tsChannel, short fileId, uint16_
* This command is needed to make the whole transfer a bit faster * This command is needed to make the whole transfer a bit faster
* @note See also handleWriteValueCommand * @note See also handleWriteValueCommand
*/ */
void handleWriteChunkCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t offset, uint16_t count, static void handleWriteChunkCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t offset, uint16_t count,
void *content) { void *content) {
tsState.writeChunkCommandCounter++; tsState.writeChunkCommandCounter++;
@ -362,15 +362,12 @@ void handleWriteChunkCommand(ts_channel_s *tsChannel, ts_response_format_e mode,
sendOkResponse(tsChannel, mode); sendOkResponse(tsChannel, mode);
} }
void handleCrc32Check(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t pageId, uint16_t offset, static void handleCrc32Check(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t pageId) {
uint16_t count) {
UNUSED(pageId); UNUSED(pageId);
tsState.crc32CheckCommandCounter++; tsState.crc32CheckCommandCounter++;
count = getTunerStudioPageSize(); uint16_t count = getTunerStudioPageSize();
scheduleMsg(&tsLogger, "CRC32 request: offset %d size %d", offset, count);
uint32_t crc = SWAP_UINT32(crc32((void * ) getWorkingPageAddr(), count)); uint32_t crc = SWAP_UINT32(crc32((void * ) getWorkingPageAddr(), count));
@ -383,7 +380,7 @@ void handleCrc32Check(ts_channel_s *tsChannel, ts_response_format_e mode, uint16
* 'Write' command receives a single value at a given offset * 'Write' command receives a single value at a given offset
* @note Writing values one by one is pretty slow * @note Writing values one by one is pretty slow
*/ */
void handleWriteValueCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t page, uint16_t offset, static void handleWriteValueCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t page, uint16_t offset,
uint8_t value) { uint8_t value) {
UNUSED(tsChannel); UNUSED(tsChannel);
UNUSED(mode); UNUSED(mode);
@ -414,7 +411,7 @@ void handleWriteValueCommand(ts_channel_s *tsChannel, ts_response_format_e mode,
// scheduleMsg(logger, "va=%d", configWorkingCopy.boardConfiguration.idleValvePin); // scheduleMsg(logger, "va=%d", configWorkingCopy.boardConfiguration.idleValvePin);
} }
void handlePageReadCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t pageId, uint16_t offset, static void handlePageReadCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t pageId, uint16_t offset,
uint16_t count) { uint16_t count) {
tsState.readPageCommandsCounter++; tsState.readPageCommandsCounter++;
@ -455,7 +452,7 @@ static void sendResponseCode(ts_response_format_e mode, ts_channel_s *tsChannel,
/** /**
* 'Burn' command is a command to commit the changes * 'Burn' command is a command to commit the changes
*/ */
void handleBurnCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t page) { static void handleBurnCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t page) {
UNUSED(page); UNUSED(page);
efitimems_t nowMs = currentTimeMillis(); efitimems_t nowMs = currentTimeMillis();
@ -645,8 +642,9 @@ void handleQueryCommand(ts_channel_s *tsChannel, ts_response_format_e mode) {
/** /**
* @brief 'Output' command sends out a snapshot of current values * @brief 'Output' command sends out a snapshot of current values
* Gauges refresh
*/ */
void handleOutputChannelsCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t offset, uint16_t count) { static void handleOutputChannelsCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t offset, uint16_t count) {
if (offset + count > sizeof(TunerStudioOutputChannels)) { if (offset + count > sizeof(TunerStudioOutputChannels)) {
scheduleMsg(&tsLogger, "TS: Version Mismatch? Too much data requested %d+%d", offset, count); scheduleMsg(&tsLogger, "TS: Version Mismatch? Too much data requested %d+%d", offset, count);
sendErrorCode(tsChannel); sendErrorCode(tsChannel);
@ -659,7 +657,10 @@ void handleOutputChannelsCommand(ts_channel_s *tsChannel, ts_response_format_e m
sr5SendResponse(tsChannel, mode, ((const uint8_t *) &tsOutputChannels) + offset, count); sr5SendResponse(tsChannel, mode, ((const uint8_t *) &tsOutputChannels) + offset, count);
} }
void handleTestCommand(ts_channel_s *tsChannel) { /**
* rusEfi own test command
*/
static void handleTestCommand(ts_channel_s *tsChannel) {
tsState.testCommandCounter++; tsState.testCommandCounter++;
static char testOutputBuffer[24]; static char testOutputBuffer[24];
/** /**
@ -794,7 +795,7 @@ int tunerStudioHandleCrcCommand(ts_channel_s *tsChannel, char *data, int incomin
} }
break; break;
case TS_CRC_CHECK_COMMAND: case TS_CRC_CHECK_COMMAND:
handleCrc32Check(tsChannel, TS_CRC, data16[0], data16[1], data16[2]); handleCrc32Check(tsChannel, TS_CRC, data16[0]);
break; break;
case TS_BURN_COMMAND: case TS_BURN_COMMAND:
handleBurnCommand(tsChannel, TS_CRC, data16[0]); handleBurnCommand(tsChannel, TS_CRC, data16[0]);

View File

@ -35,25 +35,12 @@ extern tunerstudio_counters_s tsState;
bool handlePlainCommand(ts_channel_s *tsChannel, uint8_t command); bool handlePlainCommand(ts_channel_s *tsChannel, uint8_t command);
int tunerStudioHandleCrcCommand(ts_channel_s *tsChannel, char *data, int incomingPacketSize); int tunerStudioHandleCrcCommand(ts_channel_s *tsChannel, char *data, int incomingPacketSize);
/**
* rusEfi own test command
*/
void handleTestCommand(ts_channel_s *tsChannel);
/** /**
* this command is part of protocol initialization * this command is part of protocol initialization
*/ */
void handleQueryCommand(ts_channel_s *tsChannel, ts_response_format_e mode); void handleQueryCommand(ts_channel_s *tsChannel, ts_response_format_e mode);
/**
* Gauges refresh
*/
void handleOutputChannelsCommand(ts_channel_s *tsChannel, ts_response_format_e mode);
char *getWorkingPageAddr(); char *getWorkingPageAddr();
void handleWriteValueCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t page, uint16_t offset, uint8_t value);
void handleWriteChunkCommand(ts_channel_s *tsChannel, ts_response_format_e mode, short offset, short count, void *content);
void handlePageSelectCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t pageId);
void handlePageReadCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t pageId, uint16_t offset, uint16_t count);
void handleBurnCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t page);
void tunerStudioDebug(const char *msg); void tunerStudioDebug(const char *msg);
void tunerStudioError(const char *msg); void tunerStudioError(const char *msg);

View File

@ -63,12 +63,8 @@ enable2ndByteCanID = false
pageActivate = "P\x00\x00" pageActivate = "P\x00\x00"
pageValueWrite = "W\x00\x00%2o%v" pageValueWrite = "W\x00\x00%2o%v"
pageChunkWrite = "C\x00\x00%2o%2c%v" pageChunkWrite = "C\x00\x00%2o%2c%v"
; crc32CheckCommand = "k%2i%2o\xB8\x36" ; todo: make this command shorter one day, no need to have all these zeros
; crc32CheckCommand = "k\x00\x00\x00\x00\x00\x00"
; TODO: interesting - 0x36B8 equals 14008 which looks like pageSize at some point in the past? is this a defect here - should
; we have current pageSize or (pageSize + 8) here?
;
crc32CheckCommand = "k\x00\x00\x00\x00\x36\xB8"
retrieveConfigError = "e" retrieveConfigError = "e"
;communication settings ;communication settings