Обновление
This commit is contained in:
parent
dee734d1da
commit
6602dfafca
35
CanUds.c
35
CanUds.c
|
|
@ -42,6 +42,14 @@ void ReceivedTP_func(void *arg, tCanTP_data *data) {
|
|||
|
||||
}
|
||||
|
||||
uint8_t setResponseError(tCanUds *env, eUdsServices service, eUdsResponseError error) {
|
||||
env->dataResponse[0] = 0x7F;
|
||||
env->dataResponse[1] = service;
|
||||
env->dataResponse[2] = error;
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
// начало ----------------------------- Сессия -------------------------------------------------------------
|
||||
// начало ----------------------------- Сессия -------------------------------------------------------------
|
||||
// начало ----------------------------- Сессия -------------------------------------------------------------
|
||||
|
|
@ -68,32 +76,45 @@ static uint8_t DiagnosticSessionControl_10(tCanUds *env) {
|
|||
// начало --------------------------- Чтение ---------------------------------------------------------
|
||||
static uint8_t ReadDataByIdentifier_22(tCanUds *env) {
|
||||
|
||||
if (env->data.len != 3) {
|
||||
return setResponseError(env, UDS_ReadDataByIdentifier, UDS_error_incorrectMessageLengthOrInvalidFormat);
|
||||
}
|
||||
|
||||
uint8_t dataIdentifier_hi = env->data.data[1];
|
||||
uint8_t dataIdentifier_lo = env->data.data[2];
|
||||
uint16_t dataIdentifier = (dataIdentifier_hi << 8) | dataIdentifier_lo;
|
||||
// uint16_t dataIdentifier = (dataIdentifier_hi << 8) | dataIdentifier_lo;
|
||||
|
||||
if (dataIdentifier_hi == 0xCF) {
|
||||
|
||||
if (uds_ReadDataByIdentifier_22_com[dataIdentifier_lo].data != NULL) {
|
||||
uint8_t response_size = uds_ReadDataByIdentifier_22_com[dataIdentifier_lo].size;
|
||||
if (uds_ReadDataByIdentifier_22_com_CF[dataIdentifier_lo].data != NULL) {
|
||||
uint8_t response_size = uds_ReadDataByIdentifier_22_com_CF[dataIdentifier_lo].size;
|
||||
|
||||
env->dataResponse[0] = env->data.data[0] | 0b1000000;
|
||||
env->dataResponse[1] = dataIdentifier_hi;
|
||||
env->dataResponse[2] = dataIdentifier_lo;
|
||||
memcpy(&env->dataResponse[3], uds_ReadDataByIdentifier_22_com[dataIdentifier_lo].data, response_size);
|
||||
memcpy(&env->dataResponse[3], uds_ReadDataByIdentifier_22_com_CF[dataIdentifier_lo].data, response_size);
|
||||
|
||||
return response_size;
|
||||
}
|
||||
|
||||
if (dataIdentifier_lo == 0xFF) {
|
||||
}
|
||||
|
||||
if (dataIdentifier_hi == 0xF1) {
|
||||
|
||||
if (uds_ReadDataByIdentifier_22_com_F1[dataIdentifier_lo].data != NULL) {
|
||||
uint8_t response_size = uds_ReadDataByIdentifier_22_com_CF[dataIdentifier_lo].size;
|
||||
|
||||
env->dataResponse[0] = env->data.data[0] | 0b1000000;
|
||||
env->dataResponse[1] = dataIdentifier_hi;
|
||||
env->dataResponse[2] = dataIdentifier_lo;
|
||||
memcpy(&env->dataResponse[3], uds_ReadDataByIdentifier_22_com[dataIdentifier_lo].data, response_size);
|
||||
memcpy(&env->dataResponse[3], uds_ReadDataByIdentifier_22_com_CF[dataIdentifier_lo].data, response_size);
|
||||
|
||||
return response_size;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return setResponseError(env, UDS_ReadDataByIdentifier, UDS_error_requestOutOfRange);
|
||||
}
|
||||
// конец --------------------------- Чтение ---------------------------------------------------------
|
||||
// конец --------------------------- Чтение ---------------------------------------------------------
|
||||
|
|
@ -411,10 +432,12 @@ void CanSerialPortCanUds_Start(tCanUds *env) {
|
|||
void CanUds_Init(
|
||||
tCanUds *env,
|
||||
tSerialPortFrameIO *CanIO,
|
||||
tDeviceStorage *deviceStorage,
|
||||
tLoggerInterface *logger) {
|
||||
|
||||
env->logger = logger;
|
||||
env->CanIO = CanIO;
|
||||
env->deviceStorage = deviceStorage;
|
||||
env->filterIdCount = 0;
|
||||
|
||||
env->queue = osMessageQueueNew(CAN_US_QUEUE_SIZE, sizeof(tCanTP_data), NULL);
|
||||
|
|
|
|||
11
CanUds.h
11
CanUds.h
|
|
@ -6,6 +6,7 @@
|
|||
#define HVAC_M7_CANUDS_H
|
||||
|
||||
#include "CanSerialPortFrameTP.h"
|
||||
#include "DeviceStorage.h"
|
||||
|
||||
#define CAN_US_QUEUE_SIZE 3
|
||||
|
||||
|
|
@ -21,10 +22,19 @@ typedef enum {
|
|||
UDS_SecurityAccess = 0x27
|
||||
} eUdsServices;
|
||||
|
||||
typedef enum {
|
||||
UDS_error_incorrectMessageLengthOrInvalidFormat = 0x13,
|
||||
UDS_error_responseTooLong= 0x14,
|
||||
UDS_error_requestOutOfRange= 0x31,
|
||||
UDS_error_securityAccessDenied= 0x33
|
||||
} eUdsResponseError;
|
||||
|
||||
|
||||
typedef struct {
|
||||
tCanSerialPortFrameTp canSerialPortFrameTp;
|
||||
tLoggerInterface *logger;
|
||||
tSerialPortFrameIO *CanIO;
|
||||
tDeviceStorage *deviceStorage;
|
||||
|
||||
tCanTP_Ext_data canTP_Ext_data;
|
||||
|
||||
|
|
@ -51,6 +61,7 @@ typedef struct {
|
|||
void CanUds_Init(
|
||||
tCanUds *env,
|
||||
tSerialPortFrameIO *CanIO,
|
||||
tDeviceStorage *deviceStorage,
|
||||
tLoggerInterface *logger);
|
||||
|
||||
void CanSerialPortCanUds_Start(tCanUds *env);
|
||||
|
|
|
|||
Loading…
Reference in New Issue