fixed error on can parsing

This commit is contained in:
2024-05-28 04:55:31 +02:00
parent eb5733da97
commit 452246951b
3 changed files with 26 additions and 9 deletions

View File

@@ -31,7 +31,7 @@ void Vehicle_Setup_CAN() {
}
static void rx_unlock(uint8_t * RxData ) {
static void rx_unlock_key(uint8_t * RxData ) {
if (RxData[1] == 0x04)
{
// car was unlocked
@@ -47,6 +47,20 @@ static void rx_unlock(uint8_t * RxData ) {
}
static void rx_unlock_secure(uint8_t * RxData ) {
if ((RxData[0] & 0x0F) == 0x01) {
// car was unlocked
last_unlock_message_time = osKernelGetTickCount();
} else if ((RxData[0] & 0x0F) == 0x02) {
// car was locked
if (!BSP_GPIO_K15isSet()) {
NVIC_SystemReset();
}
}
}
static void rx_speed(uint8_t * RxData) {
// speed signal
@@ -70,11 +84,11 @@ static void rx_brightness(uint8_t* RxData) {
void Vehicle_Receive_CAN( FDCAN_RxHeaderTypeDef RxHeader, uint8_t* RxData) {
if(RxHeader.Identifier == 0x391) {
rx_unlock(RxData);
rx_unlock_key(RxData);
}
if (RxHeader.Identifier == 0x395) {
rx_unlock(RxData);
rx_unlock_secure(RxData);
}