Обновление после командировки 29.06.2026
This commit is contained in:
parent
d5a8ab65d6
commit
9e472015db
|
|
@ -13,11 +13,9 @@
|
||||||
|
|
||||||
void CanSpamReceiver_Init(tCanSpamReceiver *env,
|
void CanSpamReceiver_Init(tCanSpamReceiver *env,
|
||||||
tSerialPortFrameIO *ioCanFrame,
|
tSerialPortFrameIO *ioCanFrame,
|
||||||
osMutexId_t modelTaskAccess,
|
|
||||||
tLoggerInterface *logger) {
|
tLoggerInterface *logger) {
|
||||||
|
|
||||||
env->ioCanFrame = ioCanFrame;
|
env->ioCanFrame = ioCanFrame;
|
||||||
env->modelTaskAccess = modelTaskAccess;
|
|
||||||
env->logger = logger;
|
env->logger = logger;
|
||||||
env->access = osMutexNew(NULL);
|
env->access = osMutexNew(NULL);
|
||||||
|
|
||||||
|
|
@ -27,11 +25,12 @@ void CanSpamReceiver_Init(tCanSpamReceiver *env,
|
||||||
|
|
||||||
static void ListenCanSpamReceiver(tCanSpamReceiver *env) {
|
static void ListenCanSpamReceiver(tCanSpamReceiver *env) {
|
||||||
|
|
||||||
uint16_t recv = env->ioCanFrame->receive(env->ioCanFrame->env, PROTOCOL_CAN_RAW, (uint8_t *) &env->canFrame, 1,
|
uint16_t recv = env->ioCanFrame->receive(env->ioCanFrame->env, PROTOCOL_CAN_RAW, (uint8_t * ) & env->canFrame, 1,
|
||||||
1000);
|
1000);
|
||||||
|
|
||||||
if (recv == 0)
|
if (recv == 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (osMutexAcquire(env->access, 5000) == osOK) {
|
if (osMutexAcquire(env->access, 5000) == osOK) {
|
||||||
|
|
||||||
|
|
@ -48,21 +47,26 @@ static void ListenCanSpamReceiver(tCanSpamReceiver *env) {
|
||||||
LoggerErrorStatic(LOGGER, LOG_SIGN, "Access error ListenCanSpamReceiver");
|
LoggerErrorStatic(LOGGER, LOG_SIGN, "Access error ListenCanSpamReceiver");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SystemDelayMs(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_CanSpamReceiver(tCanSpamReceiver *env) {
|
void get_CanSpamReceiver(tCanSpamReceiver *env) {
|
||||||
if (osMutexAcquire(env->access, 5000) == osOK) {
|
if (osMutexAcquire(env->access, 5000) == osOK) {
|
||||||
// memcpy(&rtDW.TM_CP_model, &ccu_candb_rx.TM_CP, sizeof(rtDW.TM_CP_model));
|
memcpy(&rtDW.TM_CP_model, &ccu_candb_rx.TM_CP, sizeof(rtDW.TM_CP_model));
|
||||||
memcpy(&rtDW.FIU_CCU1_MODEL, &ccu_candb_rx.FIU_CCU1, sizeof(rtDW.FIU_CCU1_MODEL));
|
memcpy(&rtDW.FIU_CCU1_MODEL, &ccu_candb_rx.FIU_CCU1, sizeof(rtDW.FIU_CCU1_MODEL));
|
||||||
memcpy(&rtDW.FIU_CCU2_MODEL, &ccu_candb_rx.FIU_CCU2, sizeof(rtDW.FIU_CCU2_MODEL));
|
memcpy(&rtDW.FIU_CCU2_MODEL, &ccu_candb_rx.FIU_CCU2, sizeof(rtDW.FIU_CCU2_MODEL));
|
||||||
// memcpy(&rtDW.FIU_CCU3_MODEL, &ccu_candb_rx.FIU_CCU3, sizeof(rtDW.FIU_CCU3_MODEL));
|
// memcpy(&rtDW.FIU_CCU3_MODEL, &ccu_candb_rx.FIU_CCU3, sizeof(rtDW.FIU_CCU3_MODEL));
|
||||||
|
|
||||||
memcpy(&rtDW.CCUCAN_BCM_Powertrain_model, &ccu_candb_rx.BCM_Powertrain, sizeof(rtDW.CCUCAN_BCM_Powertrain_model));
|
memcpy(&rtDW.CCUCAN_BCM_Powertrain_model, &ccu_candb_rx.BCM_Powertrain,
|
||||||
memcpy(&rtDW.CCUCAN_BCM_Climatic_model, &ccu_candb_rx.BCM_CLIMATIC_DATA, sizeof(rtDW.CCUCAN_BCM_Climatic_model));
|
sizeof(rtDW.CCUCAN_BCM_Powertrain_model));
|
||||||
|
memcpy(&rtDW.CCUCAN_BCM_Climatic_model, &ccu_candb_rx.BCM_CLIMATIC_DATA,
|
||||||
|
sizeof(rtDW.CCUCAN_BCM_Climatic_model));
|
||||||
memcpy(&rtDW.CCUCAN_EMS_Veh_model, &ccu_candb_rx.EMS_Veh, sizeof(rtDW.CCUCAN_EMS_Veh_model));
|
memcpy(&rtDW.CCUCAN_EMS_Veh_model, &ccu_candb_rx.EMS_Veh, sizeof(rtDW.CCUCAN_EMS_Veh_model));
|
||||||
memcpy(&rtDW.CCUCAN_ESC_04_model, &ccu_candb_rx.ESC_04, sizeof(rtDW.CCUCAN_ESC_04_model));
|
memcpy(&rtDW.CCUCAN_ESC_04_model, &ccu_candb_rx.ESC_04, sizeof(rtDW.CCUCAN_ESC_04_model));
|
||||||
memcpy(&rtDW.CCUCAN_BCM_VEH_STATE_model, &ccu_candb_rx.BCM_VEH_STATE, sizeof(rtDW.CCUCAN_BCM_VEH_STATE_model));
|
memcpy(&rtDW.CCUCAN_BCM_VEH_STATE_model, &ccu_candb_rx.BCM_VEH_STATE, sizeof(rtDW.CCUCAN_BCM_VEH_STATE_model));
|
||||||
memcpy(&rtDW.CCUCAN_EMS_HVC_REQ_MSG_MODEL, &ccu_candb_rx.EMS_HVC_Req_Msg, sizeof(rtDW.CCUCAN_EMS_HVC_REQ_MSG_MODEL));
|
memcpy(&rtDW.CCUCAN_EMS_HVC_REQ_MSG_MODEL, &ccu_candb_rx.EMS_HVC_Req_Msg,
|
||||||
|
sizeof(rtDW.CCUCAN_EMS_HVC_REQ_MSG_MODEL));
|
||||||
memcpy(&rtDW.HVC_ERR_STATUS_MSG_MODEL, &ccu_candb_rx.HVC_Err_Status_Msg, sizeof(rtDW.HVC_ERR_STATUS_MSG_MODEL));
|
memcpy(&rtDW.HVC_ERR_STATUS_MSG_MODEL, &ccu_candb_rx.HVC_Err_Status_Msg, sizeof(rtDW.HVC_ERR_STATUS_MSG_MODEL));
|
||||||
|
|
||||||
osMutexRelease(env->access);
|
osMutexRelease(env->access);
|
||||||
|
|
@ -74,7 +78,6 @@ void get_CanSpamReceiver(tCanSpamReceiver *env) {
|
||||||
static _Noreturn void CanSpamReceiver_Thread(tCanSpamReceiver *env) {
|
static _Noreturn void CanSpamReceiver_Thread(tCanSpamReceiver *env) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ListenCanSpamReceiver(env);
|
ListenCanSpamReceiver(env);
|
||||||
get_CanSpamReceiver(env);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ typedef struct {
|
||||||
can_rx_message_type canFrame;
|
can_rx_message_type canFrame;
|
||||||
|
|
||||||
tLoggerInterface *logger;
|
tLoggerInterface *logger;
|
||||||
osMutexId_t modelTaskAccess;
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
osThreadId_t id;
|
osThreadId_t id;
|
||||||
|
|
@ -29,7 +28,7 @@ typedef struct {
|
||||||
|
|
||||||
} tCanSpamReceiver;
|
} tCanSpamReceiver;
|
||||||
|
|
||||||
void CanSpamReceiver_Init(tCanSpamReceiver *env, tSerialPortFrameIO *ioCanFrame, osMutexId_t modelTaskAccess, tLoggerInterface *logger);
|
void CanSpamReceiver_Init(tCanSpamReceiver *env, tSerialPortFrameIO *ioCanFrame, tLoggerInterface *logger);
|
||||||
|
|
||||||
void CanSpamReceiver_StartThread(tCanSpamReceiver *env);
|
void CanSpamReceiver_StartThread(tCanSpamReceiver *env);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,20 +13,19 @@
|
||||||
|
|
||||||
void CanSpamTransmitter_Init(tCanSpamTransmitter *env,
|
void CanSpamTransmitter_Init(tCanSpamTransmitter *env,
|
||||||
tSerialPortFrameIO *ioCanFrame,
|
tSerialPortFrameIO *ioCanFrame,
|
||||||
osMutexId_t modelTaskAccess,
|
|
||||||
tLoggerInterface *logger) {
|
tLoggerInterface *logger) {
|
||||||
|
|
||||||
env->ioCanFrame = ioCanFrame;
|
env->ioCanFrame = ioCanFrame;
|
||||||
env->modelTaskAccess = modelTaskAccess;
|
|
||||||
env->logger = logger;
|
env->logger = logger;
|
||||||
env->access = osMutexNew(NULL);
|
env->access = osMutexNew(NULL);
|
||||||
|
|
||||||
|
env->queue_ccu_candb_tx = osMessageQueueNew(1, sizeof(ccu_candb_tx_t), NULL);
|
||||||
|
|
||||||
InitThreadAtrStatic(&env->thread.attr, "CanSpamTrans", env->thread.controlBlock, env->thread.stack,
|
InitThreadAtrStatic(&env->thread.attr, "CanSpamTrans", env->thread.controlBlock, env->thread.stack,
|
||||||
osPriorityNormal);
|
osPriorityNormal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void sendEventToCan(tCanSpamTransmitter *env) {
|
static void sendEventToCan(tCanSpamTransmitter *env) {
|
||||||
if (env->ide) {
|
if (env->ide) {
|
||||||
env->canFrame.id_type = FLEXCAN_ID_EXT;
|
env->canFrame.id_type = FLEXCAN_ID_EXT;
|
||||||
|
|
@ -36,9 +35,8 @@ static void sendEventToCan(tCanSpamTransmitter *env) {
|
||||||
env->canFrame.standard_id = env->can_id;
|
env->canFrame.standard_id = env->can_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
env->ioCanFrame->transmit(env->ioCanFrame->env, (uint8_t * ) & env->canFrame.data, env->canFrame.dlc,
|
env->ioCanFrame->transmit(env->ioCanFrame->env, (uint8_t *) &env->canFrame.data, env->canFrame.dlc,
|
||||||
env->can_id, env->canFrame.id_type, 100, SPAM_CAN_HANDLER);
|
env->can_id, env->canFrame.id_type, 50);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static eTimeEventTransmit isEventTransmitter(tCanSpamTransmitter *env) {
|
static eTimeEventTransmit isEventTransmitter(tCanSpamTransmitter *env) {
|
||||||
|
|
@ -74,7 +72,6 @@ static eTimeEventTransmit isEventTransmitter(tCanSpamTransmitter *env) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if (CCU_Errors_SEND == 1)
|
#if (CCU_Errors_SEND == 1)
|
||||||
if (env->time_CCU_Errors_CYC <= env->timeMs) {
|
if (env->time_CCU_Errors_CYC <= env->timeMs) {
|
||||||
env->time_CCU_Errors_CYC = env->timeMs + CCU_Errors_CYC;
|
env->time_CCU_Errors_CYC = env->timeMs + CCU_Errors_CYC;
|
||||||
|
|
@ -120,10 +117,10 @@ static eTimeEventTransmit isEventTransmitter(tCanSpamTransmitter *env) {
|
||||||
// Checksum computed as per XOR algorithm:
|
// Checksum computed as per XOR algorithm:
|
||||||
// Byte 1 XOR byte 2 .... XOR byte n-1. (n = packet length.)
|
// Byte 1 XOR byte 2 .... XOR byte n-1. (n = packet length.)
|
||||||
|
|
||||||
uint8_t d0 = (uint8_t)((ccu_candb_tx.CCU_HVC_Req_Msg.CCU_eCompSpeedReq_Val_ro & (0xFFU)));
|
uint8_t d0 = (uint8_t) ((ccu_candb_tx.CCU_HVC_Req_Msg.CCU_eCompSpeedReq_Val_ro & (0xFFU)));
|
||||||
uint8_t d1 = (uint8_t)((ccu_candb_tx.CCU_HVC_Req_Msg.CCU_eCompReq_Stat & (0x01U)) |
|
uint8_t d1 = (uint8_t) ((ccu_candb_tx.CCU_HVC_Req_Msg.CCU_eCompReq_Stat & (0x01U)) |
|
||||||
((ccu_candb_tx.CCU_HVC_Req_Msg.CCU_LowTempValve_Req & (0x03U)) << 1U) |
|
((ccu_candb_tx.CCU_HVC_Req_Msg.CCU_LowTempValve_Req & (0x03U)) << 1U) |
|
||||||
((ccu_candb_tx.CCU_HVC_Req_Msg.CCU_HVC_Req_RC & (0x0FU)) << 4U));
|
((ccu_candb_tx.CCU_HVC_Req_Msg.CCU_HVC_Req_RC & (0x0FU)) << 4U));
|
||||||
|
|
||||||
ccu_candb_tx.CCU_HVC_Req_Msg.CCU_HVC_Req_CS = d0 ^ d1;
|
ccu_candb_tx.CCU_HVC_Req_Msg.CCU_HVC_Req_CS = d0 ^ d1;
|
||||||
|
|
||||||
|
|
@ -220,7 +217,6 @@ static eTimeEventTransmit isEventTransmitter(tCanSpamTransmitter *env) {
|
||||||
// начало--------------------------------------0x501 CCU_Msg3-------------------------------------------------------
|
// начало--------------------------------------0x501 CCU_Msg3-------------------------------------------------------
|
||||||
// начало--------------------------------------0x501 CCU_Msg3-------------------------------------------------------
|
// начало--------------------------------------0x501 CCU_Msg3-------------------------------------------------------
|
||||||
// начало--------------------------------------0x501 CCU_Msg3-------------------------------------------------------
|
// начало--------------------------------------0x501 CCU_Msg3-------------------------------------------------------
|
||||||
|
|
||||||
#if (CCU_Msg3_SEND == 1)
|
#if (CCU_Msg3_SEND == 1)
|
||||||
if (env->time_CCU_Msg3 <= env->timeMs) {
|
if (env->time_CCU_Msg3 <= env->timeMs) {
|
||||||
env->time_CCU_Msg3 = env->timeMs + CCU_Msg3_CYC;
|
env->time_CCU_Msg3 = env->timeMs + CCU_Msg3_CYC;
|
||||||
|
|
@ -238,10 +234,10 @@ static eTimeEventTransmit isEventTransmitter(tCanSpamTransmitter *env) {
|
||||||
// Checksum computed as per XOR algorithm:
|
// Checksum computed as per XOR algorithm:
|
||||||
// Byte 1 XOR byte 2 .... XOR byte n-1. (n = packet length.)
|
// Byte 1 XOR byte 2 .... XOR byte n-1. (n = packet length.)
|
||||||
|
|
||||||
uint8_t d0 = (uint8_t)((ccu_candb_tx.CCU_Msg3.CCU_FAN_Req & (0x7FU)));
|
uint8_t d0 = (uint8_t) ((ccu_candb_tx.CCU_Msg3.CCU_FAN_Req & (0x7FU)));
|
||||||
uint8_t d1 = (uint8_t)((ccu_candb_tx.CCU_Msg3.CCU_RestMode_Stat & (0x03U)));
|
uint8_t d1 = (uint8_t) ((ccu_candb_tx.CCU_Msg3.CCU_RestMode_Stat & (0x03U)));
|
||||||
uint8_t d2 = (uint8_t)((ccu_candb_tx.CCU_Msg3.CCU_IncarTempSum_Val_ro & (0xFFU)));
|
uint8_t d2 = (uint8_t) ((ccu_candb_tx.CCU_Msg3.CCU_IncarTempSum_Val_ro & (0xFFU)));
|
||||||
uint8_t d3 = (uint8_t)((ccu_candb_tx.CCU_Msg3.CCU_MSG3_RC & (0x0FU)));
|
uint8_t d3 = (uint8_t) ((ccu_candb_tx.CCU_Msg3.CCU_MSG3_RC & (0x0FU)));
|
||||||
|
|
||||||
ccu_candb_tx.CCU_Msg3.CCU_MSG3_CS = d0 ^ d1 ^ d2 ^ d3;
|
ccu_candb_tx.CCU_Msg3.CCU_MSG3_CS = d0 ^ d1 ^ d2 ^ d3;
|
||||||
|
|
||||||
|
|
@ -251,7 +247,6 @@ static eTimeEventTransmit isEventTransmitter(tCanSpamTransmitter *env) {
|
||||||
return event_CCU_Msg3;
|
return event_CCU_Msg3;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// конец--------------------------------------0x501 CCU_Msg3-------------------------------------------------------
|
// конец--------------------------------------0x501 CCU_Msg3-------------------------------------------------------
|
||||||
// конец--------------------------------------0x501 CCU_Msg3-------------------------------------------------------
|
// конец--------------------------------------0x501 CCU_Msg3-------------------------------------------------------
|
||||||
// конец--------------------------------------0x501 CCU_Msg3-------------------------------------------------------
|
// конец--------------------------------------0x501 CCU_Msg3-------------------------------------------------------
|
||||||
|
|
@ -276,19 +271,14 @@ static eTimeEventTransmit isEventTransmitter(tCanSpamTransmitter *env) {
|
||||||
return event_CCU_none;
|
return event_CCU_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_CanSpamTransmitter(tCanSpamTransmitter *env) {
|
void set_CanSpamTransmitter(tCanSpamTransmitter *env, ccu_candb_tx_t *p_ccu_candb_tx) {
|
||||||
if (osMutexAcquire(env->access, 5000) == osOK) {
|
|
||||||
memcpy(&ccu_candb_tx.CCU_Errors, &rtY.CCU_Errors_model, sizeof(ccu_candb_tx.CCU_Errors));
|
|
||||||
memcpy(&ccu_candb_tx.CCU_Stat1, &rtY.CCU_Stat1_model, sizeof(ccu_candb_tx.CCU_Stat1));
|
|
||||||
memcpy(&ccu_candb_tx.CCU_Stat2, &rtY.CCU_Stat2_model, sizeof(ccu_candb_tx.CCU_Stat2));
|
|
||||||
memcpy(&ccu_candb_tx.CCU_HVC_Req_Msg, &rtY.CCUCAN_HVC_REQ_MSG_MODEL, sizeof(ccu_candb_tx.CCU_HVC_Req_Msg));
|
|
||||||
memcpy(&ccu_candb_tx.CCU_Msg3, &rtY.CCU_Msg3_model, sizeof(ccu_candb_tx.CCU_Msg3));
|
|
||||||
|
|
||||||
|
uint32_t countQueue_ccu_candb_tx = osMessageQueueGetSpace(env->queue_ccu_candb_tx);
|
||||||
|
|
||||||
osMutexRelease(env->access);
|
if (countQueue_ccu_candb_tx) {
|
||||||
} else {
|
osStatus_t status = osMessageQueuePut(env->queue_ccu_candb_tx, p_ccu_candb_tx, 0, 0U);
|
||||||
LoggerErrorStatic(LOGGER, LOG_SIGN, "Access error set_CanSpamTransmitter");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_CCU_Mute(tCanSpamTransmitter *env, bool mute) {
|
void set_CCU_Mute(tCanSpamTransmitter *env, bool mute) {
|
||||||
|
|
@ -305,6 +295,8 @@ static _Noreturn void CanSpamTransmitter_Thread(tCanSpamTransmitter *env) {
|
||||||
|
|
||||||
SystemDelayMs(100);
|
SystemDelayMs(100);
|
||||||
|
|
||||||
|
osStatus_t status = osMessageQueueGet(env->queue_ccu_candb_tx, &ccu_candb_tx, 0, 0);
|
||||||
|
|
||||||
if (env->isMute == false) {
|
if (env->isMute == false) {
|
||||||
|
|
||||||
if (osMutexAcquire(env->access, 5000) == osOK) {
|
if (osMutexAcquire(env->access, 5000) == osOK) {
|
||||||
|
|
@ -330,160 +322,3 @@ void CanSpamTransmitter_StartThread(tCanSpamTransmitter *env) {
|
||||||
env->thread.id = osThreadNew((osThreadFunc_t) (CanSpamTransmitter_Thread), (void *) (env), &env->thread.attr);
|
env->thread.id = osThreadNew((osThreadFunc_t) (CanSpamTransmitter_Thread), (void *) (env), &env->thread.attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------SLOW SLOW SLOW---------------------------------------------------------------------
|
|
||||||
//-----------------------------------SLOW SLOW SLOW---------------------------------------------------------------------
|
|
||||||
//-----------------------------------SLOW SLOW SLOW---------------------------------------------------------------------
|
|
||||||
//-----------------------------------SLOW SLOW SLOW---------------------------------------------------------------------
|
|
||||||
//-----------------------------------SLOW SLOW SLOW---------------------------------------------------------------------
|
|
||||||
//-----------------------------------SLOW SLOW SLOW---------------------------------------------------------------------
|
|
||||||
//-----------------------------------SLOW SLOW SLOW---------------------------------------------------------------------
|
|
||||||
//-----------------------------------SLOW SLOW SLOW---------------------------------------------------------------------
|
|
||||||
//-----------------------------------SLOW SLOW SLOW---------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
void CanSpamSlowTransmitter_Init(tCanSpamSlowTransmitter *env,
|
|
||||||
tSerialPortFrameIO *ioCanFrame,
|
|
||||||
osMutexId_t modelTaskAccess,
|
|
||||||
tLoggerInterface *logger) {
|
|
||||||
|
|
||||||
env->ioCanFrame = ioCanFrame;
|
|
||||||
env->modelTaskAccess = modelTaskAccess;
|
|
||||||
env->logger = logger;
|
|
||||||
env->access = osMutexNew(NULL);
|
|
||||||
|
|
||||||
InitThreadAtrStatic(&env->thread.attr, "CanSpamSlowTrans", env->thread.controlBlock, env->thread.stack,
|
|
||||||
osPriorityNormal);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void sendEventSlowToCan(tCanSpamSlowTransmitter *env) {
|
|
||||||
if (env->ide) {
|
|
||||||
env->canFrame.id_type = FLEXCAN_ID_EXT;
|
|
||||||
env->canFrame.extended_id = env->can_id;
|
|
||||||
} else {
|
|
||||||
env->canFrame.id_type = FLEXCAN_ID_STD;
|
|
||||||
env->canFrame.standard_id = env->can_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
env->ioCanFrame->transmit(env->ioCanFrame->env, (uint8_t * ) & env->canFrame.data, env->canFrame.dlc,
|
|
||||||
env->can_id, env->canFrame.id_type, 100, SPAM_SLOW_CAN_HANDLER);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_CanSpamSlowTransmitter(tCanSpamSlowTransmitter *env) {
|
|
||||||
if (osMutexAcquire(env->access, 5000) == osOK) {
|
|
||||||
memcpy(&ccu_candb_tx.CCU_Errors, &rtY.CCU_Errors_model, sizeof(ccu_candb_tx.CCU_Errors));
|
|
||||||
memcpy(&ccu_candb_tx.CCU_Msg3, &rtY.CCU_Msg3_model, sizeof(ccu_candb_tx.CCU_Msg3));
|
|
||||||
osMutexRelease(env->access);
|
|
||||||
} else {
|
|
||||||
LoggerErrorStatic(LOGGER, LOG_SIGN, "Access error set_CanSpamSlowTransmitter");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_CCU_Slow_Mute(tCanSpamSlowTransmitter *env, bool mute) {
|
|
||||||
if (osMutexAcquire(env->access, 5000) == osOK) {
|
|
||||||
env->isMute = mute;
|
|
||||||
osMutexRelease(env->access);
|
|
||||||
} else {
|
|
||||||
LoggerErrorStatic(LOGGER, LOG_SIGN, "Access error set_CCU_Slow_Mute");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static eTimeEventTransmit isEventSlowTransmitter(tCanSpamSlowTransmitter *env) {
|
|
||||||
|
|
||||||
#if (CCU_Errors_SEND == 1)
|
|
||||||
if (env->time_CCU_Errors_CYC <= env->timeMs) {
|
|
||||||
env->time_CCU_Errors_CYC = env->timeMs + CCU_Errors_CYC;
|
|
||||||
|
|
||||||
env->can_id = Pack_CCU_Errors_candb(&ccu_candb_tx.CCU_Errors, env->canFrame.data, &env->canFrame.dlc,
|
|
||||||
&env->ide);
|
|
||||||
|
|
||||||
|
|
||||||
return event_CCU_Errors_CYC;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// начало--------------------------------------0x501 CCU_Msg3-------------------------------------------------------
|
|
||||||
// начало--------------------------------------0x501 CCU_Msg3-------------------------------------------------------
|
|
||||||
// начало--------------------------------------0x501 CCU_Msg3-------------------------------------------------------
|
|
||||||
#if (CCU_Msg3_SEND == 1)
|
|
||||||
if (env->time_CCU_Msg3 <= env->timeMs) {
|
|
||||||
env->time_CCU_Msg3 = env->timeMs + CCU_Msg3_CYC;
|
|
||||||
|
|
||||||
// Rolling Counter [0 - 15]
|
|
||||||
if (env->CCU_Msg3_CCU_MSG3_RC >= 15) {
|
|
||||||
env->CCU_Msg3_CCU_MSG3_RC = 0;
|
|
||||||
} else {
|
|
||||||
++env->CCU_Msg3_CCU_MSG3_RC;
|
|
||||||
}
|
|
||||||
|
|
||||||
ccu_candb_tx.CCU_Msg3.CCU_MSG3_RC = env->CCU_Msg3_CCU_MSG3_RC;
|
|
||||||
|
|
||||||
// Checksum XOR8 of the data field this message
|
|
||||||
// Checksum computed as per XOR algorithm:
|
|
||||||
// Byte 1 XOR byte 2 .... XOR byte n-1. (n = packet length.)
|
|
||||||
|
|
||||||
uint8_t d0 = (uint8_t)((ccu_candb_tx.CCU_Msg3.CCU_FAN_Req & (0x7FU)));
|
|
||||||
uint8_t d1 = (uint8_t)((ccu_candb_tx.CCU_Msg3.CCU_RestMode_Stat & (0x03U)));
|
|
||||||
uint8_t d2 = (uint8_t)((ccu_candb_tx.CCU_Msg3.CCU_IncarTempSum_Val_ro & (0xFFU)));
|
|
||||||
uint8_t d3 = (uint8_t)((ccu_candb_tx.CCU_Msg3.CCU_MSG3_RC & (0x0FU)));
|
|
||||||
|
|
||||||
ccu_candb_tx.CCU_Msg3.CCU_MSG3_CS = d0 ^ d1 ^ d2 ^ d3;
|
|
||||||
|
|
||||||
|
|
||||||
env->can_id = Pack_CCU_Msg3_candb(&ccu_candb_tx.CCU_Msg3, env->canFrame.data, &env->canFrame.dlc, &env->ide);
|
|
||||||
|
|
||||||
return event_CCU_Msg3;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// конец--------------------------------------0x501 CCU_Msg3-------------------------------------------------------
|
|
||||||
// конец--------------------------------------0x501 CCU_Msg3-------------------------------------------------------
|
|
||||||
// конец--------------------------------------0x501 CCU_Msg3-------------------------------------------------------
|
|
||||||
|
|
||||||
return event_CCU_none;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static _Noreturn void CanSpamSlowTransmitter_Thread(tCanSpamSlowTransmitter *env) {
|
|
||||||
for (;;) {
|
|
||||||
|
|
||||||
SystemDelayMs(500);
|
|
||||||
|
|
||||||
if (env->isMute == false) {
|
|
||||||
|
|
||||||
if (osMutexAcquire(env->access, 5000) == osOK) {
|
|
||||||
|
|
||||||
env->timeMs += 500;
|
|
||||||
|
|
||||||
while (isEventSlowTransmitter(env) != event_CCU_none) {
|
|
||||||
sendEventSlowToCan(env);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
osMutexRelease(env->access);
|
|
||||||
} else {
|
|
||||||
LoggerErrorStatic(LOGGER, LOG_SIGN, "Access error CanSpamSlowTransmitter_Thread");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CanSpamSlowTransmitter_StartThread(tCanSpamSlowTransmitter *env) {
|
|
||||||
if (!env->thread.id) {
|
|
||||||
env->thread.id = osThreadNew((osThreadFunc_t) (CanSpamSlowTransmitter_Thread), (void *) (env), &env->thread.attr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,6 @@
|
||||||
#include "ccu_candb-binutil.h"
|
#include "ccu_candb-binutil.h"
|
||||||
#include "LoggerInterface.h"
|
#include "LoggerInterface.h"
|
||||||
|
|
||||||
#define SPAM_CAN_HANDLER 0
|
|
||||||
#define SPAM_SLOW_CAN_HANDLER 2
|
|
||||||
|
|
||||||
#define CCU_Stat1_SEND 1
|
#define CCU_Stat1_SEND 1
|
||||||
#define CCU_Stat2_SEND 1
|
#define CCU_Stat2_SEND 1
|
||||||
#define CCU_Stat3_SEND 0
|
#define CCU_Stat3_SEND 0
|
||||||
|
|
@ -20,12 +17,9 @@
|
||||||
|
|
||||||
#define CCU_Requests_SEND 0
|
#define CCU_Requests_SEND 0
|
||||||
#define CCU_HVC_Req_Msg_SEND 1
|
#define CCU_HVC_Req_Msg_SEND 1
|
||||||
|
|
||||||
#define CCU_VCU_Msg1_SEND 0
|
#define CCU_VCU_Msg1_SEND 0
|
||||||
#define CCU_VCU_Msg2_SEND 0
|
#define CCU_VCU_Msg2_SEND 0
|
||||||
#define CCU_Msg1_SEND 0
|
#define CCU_Msg1_SEND 1
|
||||||
|
|
||||||
|
|
||||||
#define CCU_Msg3_SEND 1
|
#define CCU_Msg3_SEND 1
|
||||||
#define CU_AC_Ctrl_SEND 0
|
#define CU_AC_Ctrl_SEND 0
|
||||||
|
|
||||||
|
|
@ -51,6 +45,8 @@ typedef struct {
|
||||||
osMutexId_t access;
|
osMutexId_t access;
|
||||||
can_rx_message_type canFrame;
|
can_rx_message_type canFrame;
|
||||||
|
|
||||||
|
osMessageQueueId_t queue_ccu_candb_tx;
|
||||||
|
|
||||||
uint32_t can_id;
|
uint32_t can_id;
|
||||||
uint32_t timeMs;
|
uint32_t timeMs;
|
||||||
uint8_t ide;
|
uint8_t ide;
|
||||||
|
|
@ -58,23 +54,21 @@ typedef struct {
|
||||||
uint32_t time_CCU_Stat1_CYC;
|
uint32_t time_CCU_Stat1_CYC;
|
||||||
uint32_t time_CCU_Stat2_CYC;
|
uint32_t time_CCU_Stat2_CYC;
|
||||||
uint32_t time_CCU_Stat3_CYC;
|
uint32_t time_CCU_Stat3_CYC;
|
||||||
uint32_t time_CCU_Errors_CYC; //
|
uint32_t time_CCU_Errors_CYC;
|
||||||
uint32_t time_CCU_Requests;
|
uint32_t time_CCU_Requests;
|
||||||
uint32_t time_CCU_HVC_Req_Msg;
|
uint32_t time_CCU_HVC_Req_Msg;
|
||||||
uint32_t time_CCU_VCU_Msg1;
|
uint32_t time_CCU_VCU_Msg1;
|
||||||
uint32_t time_CCU_VCU_Msg2;
|
uint32_t time_CCU_VCU_Msg2;
|
||||||
uint32_t time_CCU_Msg1;
|
uint32_t time_CCU_Msg1;
|
||||||
uint32_t time_CCU_Msg3; //
|
uint32_t time_CCU_Msg3;
|
||||||
uint32_t time_CCU_AC_Ctrl;
|
uint32_t time_CCU_AC_Ctrl;
|
||||||
|
|
||||||
uint8_t CCU_HVC_Req_Msg_CCU_HVC_Req_RC;
|
uint8_t CCU_HVC_Req_Msg_CCU_HVC_Req_RC;
|
||||||
uint8_t CCU_Msg1_CCU_MSG1_RC;
|
uint8_t CCU_Msg1_CCU_MSG1_RC;
|
||||||
uint8_t CCU_Msg3_CCU_MSG3_RC; //
|
uint8_t CCU_Msg3_CCU_MSG3_RC;
|
||||||
|
|
||||||
bool isMute;
|
bool isMute;
|
||||||
|
|
||||||
osMutexId_t modelTaskAccess;
|
|
||||||
|
|
||||||
tLoggerInterface *logger;
|
tLoggerInterface *logger;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -86,57 +80,14 @@ typedef struct {
|
||||||
|
|
||||||
} tCanSpamTransmitter;
|
} tCanSpamTransmitter;
|
||||||
|
|
||||||
void CanSpamTransmitter_Init(tCanSpamTransmitter *env, tSerialPortFrameIO *ioCanFrame, osMutexId_t modelTaskAccess,
|
void CanSpamTransmitter_Init(tCanSpamTransmitter *env, tSerialPortFrameIO *ioCanFrame, tLoggerInterface *logger);
|
||||||
tLoggerInterface *logger);
|
|
||||||
|
|
||||||
void CanSpamTransmitter_StartThread(tCanSpamTransmitter *env);
|
void CanSpamTransmitter_StartThread(tCanSpamTransmitter *env);
|
||||||
|
|
||||||
void set_CanSpamTransmitter(tCanSpamTransmitter *env);
|
|
||||||
|
|
||||||
void set_CCU_Mute(tCanSpamTransmitter *env, bool mute);
|
void set_CCU_Mute(tCanSpamTransmitter *env, bool mute);
|
||||||
|
|
||||||
|
void set_CanSpamTransmitter(tCanSpamTransmitter *env, ccu_candb_tx_t *p_ccu_candb_tx);
|
||||||
/*
|
|
||||||
typedef struct {
|
|
||||||
|
|
||||||
tSerialPortFrameIO *ioCanFrame;
|
|
||||||
osMutexId_t access;
|
|
||||||
can_rx_message_type canFrame;
|
|
||||||
|
|
||||||
uint32_t can_id;
|
|
||||||
uint32_t timeMs;
|
|
||||||
uint8_t ide;
|
|
||||||
|
|
||||||
|
|
||||||
uint32_t time_CCU_Errors_CYC;
|
|
||||||
uint32_t time_CCU_Msg3;
|
|
||||||
|
|
||||||
uint8_t CCU_Msg3_CCU_MSG3_RC;
|
|
||||||
|
|
||||||
bool isMute;
|
|
||||||
|
|
||||||
osMutexId_t modelTaskAccess;
|
|
||||||
|
|
||||||
tLoggerInterface *logger;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
osThreadId_t id;
|
|
||||||
uint32_t stack[384];
|
|
||||||
StaticTask_t controlBlock;
|
|
||||||
osThreadAttr_t attr;
|
|
||||||
} thread;
|
|
||||||
|
|
||||||
} tCanSpamSlowTransmitter;
|
|
||||||
|
|
||||||
|
|
||||||
void CanSpamSlowTransmitter_Init(tCanSpamSlowTransmitter *env, tSerialPortFrameIO *ioCanFrame, osMutexId_t modelTaskAccess,
|
|
||||||
tLoggerInterface *logger);
|
|
||||||
|
|
||||||
void CanSpamSlowTransmitter_StartThread(tCanSpamSlowTransmitter *env);
|
|
||||||
|
|
||||||
void set_CanSpamSlowTransmitter(tCanSpamSlowTransmitter *env);
|
|
||||||
|
|
||||||
void set_CCU_Slow_Mute(tCanSpamSlowTransmitter *env, bool mute);
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif //HVAC_M7_CANSPAMTRANSMITTER_H
|
#endif //HVAC_M7_CANSPAMTRANSMITTER_H
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue