changed ford empf3 message structure, also created the states and cases for 700h rx. Implemented immobilizer's smoke and mirrors, pump does not block but eps 815 should read it and _unlock_ it correctly. Testing required

This commit is contained in:
2026-04-13 23:07:43 +02:00
parent 7582df66fe
commit 2f906373b7
6 changed files with 111 additions and 20 deletions

View File

@@ -187,8 +187,10 @@ const size_t CAN_ANSWERS_COUNT = sizeof(CAN_ANSWERS)/sizeof(CAN_ANSWERS[0]);
//static const uint8_t STARTUP_PAYLOAD_2[8] = {0x81, 0x7F, 0x5D, 0x1C, 0xE6, 0x7B, 0x9D, 0xD8}; //0xD8 bit immo 0
#if defined(T06301)
static const uint8_t STARTUP_PAYLOAD[8] = {0x07, 0x05, 0x1C, 0x38, 0x1C, 0xFC, 0xF5, 0x71}; //0x75 immo 1 0x71 immo 0
/*static const uint8_t STARTUP_PAYLOAD[8] = {0x07, 0x05, 0x1C, 0x38, 0x1C, 0xFC, 0xF5, 0x71}; //0x75 immo 1 0x71 immo 0
static const uint8_t STARTUP_PAYLOAD_2[8] = {0x81, 0x7F, 0x1C, 0x38, 0x1C, 0xFC, 0xF5, 0x71};
static const uint8_t EPS_0024_PAYLOAD[8] = {0x64, 0x01, 0x01, 0x00, 0x00, 0x00, 0x5B, 0x37}; //0x75 immo 1 0x71 immo 0
static const uint8_t EPS_00B2_PAYLOAD[8] = {0x64, 0x01, 0x01, 0x00, 0x00, 0x21, 0x5B, 0x37};*/
#elif defined(T06211)
static const uint8_t STARTUP_PAYLOAD[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; //0x75 immo 1 0x71 immo 0
@@ -200,6 +202,12 @@ static const uint8_t STARTUP_PAYLOAD[8] = {0x00, 0x00, 0x21, 0xD7, 0x46, 0xBA, 0
uint8_t pepe = 1;
/* ===== TX: ID 0x312 EMPF4 ===== */
#if defined(T06301)
static CanSymbolDef SYM_ID_EMPF3[] = {
{ "FIEONA-TRANS0", 0, 16, CAN_ENDIAN_INTEL, CAN_SYM_UX, 0,0, &FIEONA_TRANS0, NULL, CAN_STORE_U16},
{ "FIEONA-TRANS1", 16, 16, CAN_ENDIAN_INTEL, CAN_SYM_UX, 0,0, &FIEONA_TRANS1, NULL, CAN_STORE_U16},
{ "FIEONA-TRANS2", 32, 16, CAN_ENDIAN_INTEL, CAN_SYM_UX, 0,0, &FIEONA_TRANS2, NULL, CAN_STORE_U16},
{ "FIEONA-TRANS3", 48, 16, CAN_ENDIAN_INTEL, CAN_SYM_UX, 0,0, &FIEONA_TRANS3, NULL, CAN_STORE_U16},
};
static CanSymbolDef SYM_ID_EMPF4[] = {
{ "FIEONA-PER0", 0, 16, CAN_ENDIAN_INTEL, CAN_SYM_UX, 0,0, &FIEONA_FIRSTWORD, NULL, CAN_STORE_U16},
{ "FIEONA-PER1", 16, 16, CAN_ENDIAN_INTEL, CAN_SYM_UX, 0,0, &FIEONA_SECONDWORD, NULL, CAN_STORE_U16},
@@ -240,26 +248,14 @@ const CanMessageDef MSG_ID_EMPF3 =
.dir = CAN_DIR_TX,
.dlc = 8,
.name = "BOOT_TEMPLATE",
.symbols = NULL,
.symbol_count = 0,
.tx_template = STARTUP_PAYLOAD,
.symbols = SYM_ID_EMPF3,
.symbol_count = (uint8_t)(sizeof(SYM_ID_EMPF3)/sizeof(SYM_ID_EMPF3[0])),
.tx_template = NULL,
.send_on_boot = 0,
.rx_handler = NULL
};
#if defined(T06301)
const CanMessageDef MSG_ID_EMPF3_MOD =
{
.can_id = ID_EMPF3, // you set 0x714
.dir = CAN_DIR_TX,
.dlc = 8,
.name = "BOOT_TEMPLATE",
.symbols = NULL,
.symbol_count = 0,
.tx_template = STARTUP_PAYLOAD_2,
.send_on_boot = 0,
.rx_handler = NULL
};
const CanMessageDef MSG_ID_EMPF4 = {
.can_id = ID_EMPF4,
@@ -390,7 +386,7 @@ static const CanMessageDef* const CAN_DB[] = {
&MSG_ID_SEND2,
&MSG_ID_SEND3,
#if defined(T06301)
&MSG_ID_EMPF3_MOD,
//&MSG_ID_EMPF3_MOD,
&MSG_ID_EMPF4,
&MSG_ID_SEND4,
#endif

View File

@@ -149,14 +149,14 @@ uint8_t startup_sent_count = 0;
#else
#endif
extern int watchdog_active;
extern int watchdog_started;
void can_manager_rx_boot_reply_always(const CanMessageDef *msg, const uint8_t in[8], CanTxFn tx)
{
(void)msg; (void)in;
if (!tx || !s_startup_reply_msg) return;
#if defined(T06301)
if(!watchdog_active){return;}
if(!watchdog_started){return;}
if(count < 2){
count++;
@@ -165,6 +165,8 @@ void can_manager_rx_boot_reply_always(const CanMessageDef *msg, const uint8_t in
startup = 0;
startup_count = 0;
Timeout_ResetByIndex(18, TIM16->CNT); // first callback in 40 ms
Fieona_SEND3_Handler(in);
Timeout_StopByIndex(21); // first callback in 40 ms
if(count > 1){
Timeout_StartIfStopped(20, TIM16->CNT - 500);

View File

@@ -6,6 +6,7 @@
*/
#include "ford_immo.h"
#include "timeouts.h"
#include "can_port.h"
uint16_t FIEONA_FIRSTWORD = 0x2001;
@@ -75,6 +76,82 @@ void Fieona_SEND4_Handler(
_rx_fresh = 1;
}
uint16_t FIEONA_TRANS0 = 0x0507;
uint16_t FIEONA_TRANS1 = 0x381C;
uint16_t FIEONA_TRANS2 = 0xFC1C;
uint16_t FIEONA_TRANS3 = 0x71F5;
uint8_t eps_fieona_override = 0;
#define FIEONA_UNLOCK_MS 600000
uint32_t fieona_unlock_end = 0;
uint8_t fieona_unlocked = 0;
void Fieona_SEND3_Handler(const uint8_t in_data[8]){
uint16_t rx_word = (uint16_t)in_data[0] | ((uint16_t)in_data[1] << 8);
if(fieona_unlocked){ //si recibo un 700, despues de que este bloqueada, y no es 23 o 24, no contestamos
if(rx_word == 0x0023){
FIEONA_TRANS0 = 0xAA63;
FIEONA_TRANS2 = 0x0001;
FIEONA_TRANS2 = 0x2100;
eps_fieona_override = 1;
}else if(rx_word == 0x0024){
FIEONA_TRANS0 = 0x0164;
FIEONA_TRANS2 = 0x0001;
FIEONA_TRANS2 = 0;
eps_fieona_override = 1;
}else{
Timeout_StopByIndex(18);
}
}else{ //si no esta bloqueado
if(rx_word == 0x0024){ //y es 24 -> envio como desinmovilizando pero sin 2100
FIEONA_TRANS0 = 0x0164;
FIEONA_TRANS1 = 0x0001;
FIEONA_TRANS2 = 0;
if(!fieona_unlocked){
fieona_unlock_end = 0; //si estaba desbloqueando fuck you (creo que deberia ir a si...
}
eps_fieona_override = 1;
}else if(rx_word == 0x00B2){ //y es b2 -> envio desinmovilizando con 2100
FIEONA_TRANS0 = 0x0164;
FIEONA_TRANS1 = 0x0001;
FIEONA_TRANS2 = 0x2100;
eps_fieona_override = 1;
if(!fieona_unlock_end){ //si no habia empezado a desinmovilizar empiezo
fieona_unlock_end = HAL_GetTick() + FIEONA_UNLOCK_MS; //roll over is 50 days with 32bit hal tick
}else{ //si habia empezado, chekiamos si ya acabo.
if(HAL_GetTick() > fieona_unlock_end){
fieona_unlocked = 1;
fieona_unlock_end = 0;
}
}
}else{ //si envio cualquier otra cosa dejo de desinmovilizar y no overrideo na.
//fieona_unlocked = 0; //aqui creo que deberia volver a bloquearla, pero no voy a tocar na por ahora.
fieona_unlock_end = 0;
eps_fieona_override = 0;
}
}
}
void Fieona_SEND3_set_init(uint8_t i){
if(i){
FIEONA_TRANS0 = 0x0507;
}else{
FIEONA_TRANS0 = 0x7F81;
}
FIEONA_TRANS1 = 0x381C;
FIEONA_TRANS2 = 0xFC1C;
FIEONA_TRANS3 = 0x71F5;
}
void FIEONA_Poll(){
if(last_send4_tick){
uint16_t newtick = last_send4_tick - 250;

View File

@@ -17,4 +17,9 @@ extern uint16_t FIEONA_advance();
extern void Fieona_SEND4_Handler();
void FIEONA_Poll(void);
extern uint16_t FIEONA_TRANS0;
extern uint16_t FIEONA_TRANS1;
extern uint16_t FIEONA_TRANS2;
extern uint16_t FIEONA_TRANS3;
#endif /* IMMOBILISERS_FORD_IMMO_H_ */

View File

@@ -3,6 +3,7 @@
#include "id.h"
extern TIM_HandleTypeDef htim8;
volatile int watchdog_active = 0;
volatile int watchdog_started = 0;
volatile int request_syncout_activation = 0;
@@ -227,6 +228,7 @@ void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)
{
if (!watchdog_active){
watchdog_active = 1; // ✅ Pulse finished
watchdog_started = 1;
can_port_send_msg_def(&MSG_ID_EMPF4);
Timeout_StartIfStopped(20, TIM16->CNT); // deberia mejorarlo bastante esto, en vez de
FIEONA_advance();

View File

@@ -176,6 +176,8 @@ extern uint8_t startup_finished;
extern uint8_t count;
extern uint8_t startup_count;
extern uint8_t startup_sent_count;
extern uint8_t eps_fieona_override;
extern void Fieona_SEND3_set_init(uint8_t u);
void Handle_Boot_EMPF3_Timeout(void)
{
#if defined(T06301)
@@ -183,6 +185,9 @@ void Handle_Boot_EMPF3_Timeout(void)
Set_Timeout_Period_ByIndex(18, 400);
/* FOR THE FORD CAN IMMO*/
if(!eps_fieona_override){
Fieona_SEND3_set_init(1);
}
can_port_send_msg_def(&MSG_ID_EMPF3);
/* END FORD IMMO*/
if(startup_count){
@@ -193,7 +198,11 @@ void Handle_Boot_EMPF3_Timeout(void)
}
}else{
can_port_send_msg_def(&MSG_ID_EMPF3_MOD);
if(!eps_fieona_override){
Fieona_SEND3_set_init(0);
}
can_port_send_msg_def(&MSG_ID_EMPF3);
Timeout_StopByIndex(18); // done
}
#else