diff --git a/CanUds.c b/CanUds.c index bf40961..530b532 100644 --- a/CanUds.c +++ b/CanUds.c @@ -78,9 +78,9 @@ char *sendLogCanUdsHex(tCanUds *env, uint8_t *data, size_t size) { for (uint8_t i = 0; i < full; ++i) { PrintfDebug(&data[i * 8], 8); - if ((len + strlen(strPrintfDebug_UDS)) < LEN_DEBUG_TP_BUFF) { + if ((len + strlen(strPrintfDebug_UDS)) < LEN_DEBUG_TP_BUFF) { + memcpy(&env->hexString[len], strPrintfDebug_UDS, strlen(strPrintfDebug_UDS)); len += strlen(strPrintfDebug_UDS); - memcpy(env->hexString, strPrintfDebug_UDS, strlen(strPrintfDebug_UDS)); } else { return env->hexString; } @@ -90,9 +90,9 @@ char *sendLogCanUdsHex(tCanUds *env, uint8_t *data, size_t size) { if (tail > 0) { PrintfDebug(&data[full * 8], tail); - if ((len + strlen(strPrintfDebug_UDS)) < LEN_DEBUG_TP_BUFF) { + if ((len + strlen(strPrintfDebug_UDS)) < LEN_DEBUG_TP_BUFF) { + memcpy(&env->hexString[len], strPrintfDebug_UDS, strlen(strPrintfDebug_UDS)); len += strlen(strPrintfDebug_UDS); - memcpy(env->hexString, strPrintfDebug_UDS, strlen(strPrintfDebug_UDS)); } else { return env->hexString; } @@ -147,9 +147,9 @@ static uint16_t TesterPresent_3E(tCanUds *env) { return setResponseError(env, UDS_TesterPresent, UDS_error_incorrectMessageLengthOrInvalidFormat); } - tTesterPresent testerPresent; - testerPresent.ServiceId = UDS_TesterPresent | 0b1000000; - testerPresent.zeroSubFunction = 0; + tTesterPresent *testerPresent = (tTesterPresent *) env->dataResponse; + testerPresent->ServiceId = UDS_TesterPresent | 0b1000000; + testerPresent->zeroSubFunction = 0; return 2; } @@ -726,8 +726,8 @@ const eUds_com uds_com[256] = { {NULL, ""}, {NULL, ""}, {NULL, ""}, - {ReadDataByIdentifier_22, "ReadDataByIdentifier_22"}, {NULL, ""}, + {ReadDataByIdentifier_22, "ReadDataByIdentifier_22"}, {NULL, ""}, {NULL, ""}, {NULL, ""}, @@ -970,7 +970,7 @@ void CanUds(tCanUds *env) { if (response_size) { - sendLogCanUdsHex(env,env->dataResponse, response_size); + sendLogCanUdsHex(env, env->dataResponse, response_size); LoggerFormatInfo(LOGGER, LOG_SIGN, "< %s [%d] %s", uds_com[com].desc, response_size, env->hexString) CanSerialPortFrameTpTransmit(&env->canSerialPortFrameTp, env->dataResponse,