Skip to content

Commit b7dcd01

Browse files
committed
vcu emits current event
1 parent 69e68d6 commit b7dcd01

7 files changed

Lines changed: 33 additions & 3 deletions

File tree

VCU/firmware/Core/Src/app_freertos.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ void StartControlTask(void *argument) {
378378
vcu_can_set_model_inputs(&in);
379379
vcu_can_set_model_outputs(&out);
380380
vcu_can_set_steering_angle_deg(steering_angle_deg);
381+
vcu_can_set_event_mode(s_params.event_mode);
381382

382383

383384

VCU/firmware/vcu/vcu_can.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@ void vcu_can_set_steering_angle_deg(float steering_angle_deg) {
298298
steering_column_mailbox.steering_column_angle = steering_angle_deg;
299299
}
300300

301+
void vcu_can_set_event_mode(uint8_t event_mode) {
302+
vcu_state_mailbox.event_mode = event_mode;
303+
}
304+
301305
static float compute_brake_bias_pct(const vcu_outputs_t *out) {
302306
static float remembered_brake_bias = 0.0f;
303307
float total = out->bse1_psi + out->bse2_psi;

VCU/firmware/vcu/vcu_can.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ void vcu_can_read_contactor_status(void);
2828
void vcu_can_set_model_inputs(const vcu_inputs_t *in);
2929
void vcu_can_set_model_outputs(const vcu_outputs_t *out);
3030
void vcu_can_set_steering_angle_deg(float steering_angle_deg);
31+
void vcu_can_set_event_mode(uint8_t event_mode);
3132

3233
bool is_drive_switch_pressed(void);
3334

drivers/longhorn-lib/can.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3396,7 +3396,7 @@
33963396
"to": [
33973397
"Pi"
33983398
],
3399-
"data_length": 6,
3399+
"data_length": 7,
34003400
"frequency_ms": 3,
34013401
"frequency": 333.0,
34023402
"quantity": 1,
@@ -3471,6 +3471,20 @@
34713471
"repeated": false,
34723472
"field_index": null
34733473
}
3474+
},
3475+
{
3476+
"index": 5,
3477+
"start_byte": 6,
3478+
"name": "Event Mode",
3479+
"length": 1,
3480+
"conv_type": "uint8",
3481+
"precision": 1.0,
3482+
"protobuf": {
3483+
"type": "float",
3484+
"field": "event_mode",
3485+
"repeated": false,
3486+
"field_index": null
3487+
}
34743488
}
34753489
]
34763490
},

drivers/longhorn-lib/can_ids.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,6 +1842,9 @@ int pack_vcu_state(const msg_vcu_state_t* msg, uint8_t* tx_buf) {
18421842
// Pack: Line Lock Enabled
18431843
tx_buf[5] = (uint8_t)msg->line_lock_enabled;
18441844

1845+
// Pack: Event Mode
1846+
tx_buf[6] = (uint8_t)msg->event_mode;
1847+
18451848
return 0;
18461849
}
18471850

@@ -1864,6 +1867,9 @@ int unpack_vcu_state(const uint8_t* rx_buf, msg_vcu_state_t* msg) {
18641867
// Unpack: Line Lock Enabled
18651868
msg->line_lock_enabled = (uint8_t)rx_buf[5];
18661869

1870+
// Unpack: Event Mode
1871+
msg->event_mode = (uint8_t)rx_buf[6];
1872+
18671873
return 0;
18681874
}
18691875

drivers/longhorn-lib/can_ids.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ int unpack_steering_column(const uint8_t* rx_buf, msg_steering_column_t* msg);
14231423
// From: VCU
14241424
// To: Pi
14251425
#define VCU_STATE_ID 455
1426-
#define VCU_STATE_DLC 6
1426+
#define VCU_STATE_DLC 7
14271427
#define VCU_STATE_FREQ 3
14281428
#define VCU_STATE_TIMEOUT_MS 6
14291429

@@ -1433,6 +1433,7 @@ typedef struct {
14331433
uint8_t ready_to_drive_buzzer;
14341434
float state_of_charge_estimate;
14351435
uint8_t line_lock_enabled;
1436+
uint8_t event_mode;
14361437
} msg_vcu_state_t;
14371438

14381439
// Signal: PRNDL State
@@ -1450,6 +1451,9 @@ typedef struct {
14501451
// Signal: Line Lock Enabled
14511452
#define VCU_STATE_LINE_LOCK_ENABLED_PREC 1.0f
14521453

1454+
// Signal: Event Mode
1455+
#define VCU_STATE_EVENT_MODE_PREC 1.0f
1456+
14531457
int pack_vcu_state(const msg_vcu_state_t* msg, uint8_t* tx_buf);
14541458
int unpack_vcu_state(const uint8_t* rx_buf, msg_vcu_state_t* msg);
14551459

drivers/longhorn-lib/config/can_packets.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ CAN ID,CAN ID Binary,From,To,Packet Info,Frequency (Hz),Data Length Code (DLC),Q
4343
0x1C4,111000100,VCU,Pi,BSE Voltages,333,6,1,"BSE Front Voltage (uint16, 0.0001 V); bse1_v (float) #16",,"BSE Rear Voltage (uint16, 0.0001 V); bse2_v (float) #17",,"BSE Line Lock Voltage (uint16, 0.0001 V); bse3_v (float) #18",,unused,unused,Critical,,
4444
0x1C5,111000101,VCU,Pi,Brakes,333,8,1,"Brake Pressure Front (uint16, 0.05 psi); brake_pressure_f (float) #13",,"Brake Pressure Rear Pre Lock (uint16, 0.05 psi); brake_pressure_rbll (float) #15",,"Brake Pressure Rear Post Lock (uint16, 0.05 psi); brake_pressure_rall (float) #14",,"Brake Bias (uint8, 0.01 %); brake_bias (float) #11","BSE Faults (bitfield, bse_faults)",Critical,,
4545
0x1C6,111000110,VCU,Pi,Steering Column,333,2,1,"Steering Column Angle (int16, 0.004º); steer_col_angle (float) #13",,unused,unused,unused,unused,unused,unused,Critical,,
46-
0x1C7,111000111,VCU,Pi,VCU State,333,6,1,"PRNDL State (uint8); prndl_state (float) #1","STOMP Fault (uint8, bool); stomp_fault (bool) #33","Ready To Drive Buzzer (uint8, bool); r2d_buzzer (bool) #27","State of Charge Estimate (uint16, 0.1 %); soc_estimate (float) #3",,"Line Lock Enabled (uint8, bool); line_lock_enabled (bool) #28",unused,unused,Critical,,
46+
0x1C7,111000111,VCU,Pi,VCU State,333,7,1,"PRNDL State (uint8); prndl_state (float) #1","STOMP Fault (uint8, bool); stomp_fault (bool) #33","Ready To Drive Buzzer (uint8, bool); r2d_buzzer (bool) #27","State of Charge Estimate (uint16, 0.1 %); soc_estimate (float) #3",,"Line Lock Enabled (uint8, bool); line_lock_enabled (bool) #28","Event Mode (uint8); event_mode (float) #39",unused,Critical,,
4747
0x402,10000000010,USM,Pi,Acceleration Vector Unsprung + Wheel Speed FL,333,8,1,"X (int16, 0.001 m/s^2); fl_unsprung_accel[0] (float) #6",,"Y (int16, 0.001 m/s^2); fl_unsprung_accel[1] (float) #6",,"Z (int16, 0.001 m/s^2); fl_unsprung_accel[2] (float) #6",,"Wheel Speed (int16, 0.01 rad/s); fl_wheel_speed (float) #11",,Data Acq,,
4848
0x403,10000000011,USM,Pi,Acceleration Vector Unsprung + Wheel Speed FR,333,8,1,"X (int16, 0.001 m/s^2); fr_unsprung_accel[0] (float) #7",,"Y (int16, 0.001 m/s^2); fr_unsprung_accel[1] (float) #7",,"Z (int16, 0.001 m/s^2); fr_unsprung_accel[2] (float) #7",,"Wheel Speed (int16, 0.01 rad/s); fr_wheel_speed (float) #12",,Data Acq,,
4949
0x404,10000000100,USM,Pi,Acceleration Vector Unsprung + Wheel Speed RL,333,8,1,"X (int16, 0.001 m/s^2); bl_unsprung_accel[0] (float) #4",,"Y (int16, 0.001 m/s^2); bl_unsprung_accel[1] (float) #4",,"Z (int16, 0.001 m/s^2); bl_unsprung_accel[2] (float) #4",,"Wheel Speed (int16, 0.01 rad/s); bl_wheel_speed (float) #9",,Data Acq,,

0 commit comments

Comments
 (0)