Skip to content

Commit

Permalink
send a complete message
Browse files Browse the repository at this point in the history
  • Loading branch information
jr1221 committed Sep 20, 2024
1 parent 9ade8e9 commit 218bdf0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Core/Inc/compute.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ void compute_send_cell_temp_message(acc_data_t *bmsdata);
void compute_send_segment_temp_message(acc_data_t *bmsdata);

void compute_send_fault_message(uint8_t status, int16_t curr, int16_t in_dcl);

void compute_send_debug_message(uint8_t debug0, uint8_t debug1, uint16_t debug2,
uint32_t debug3);

void compute_send_voltage_noise_message(acc_data_t *bmsdata);

#endif // COMPUTE_H
24 changes: 17 additions & 7 deletions Core/Src/compute.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,19 +670,29 @@ void compute_send_voltage_noise_message(acc_data_t *bmsdata)
can_send_msg(line, &acc_msg);
}

void compute_send_debug_message(uint8_t *data, uint8_t len)
void compute_send_debug_message(uint8_t debug0, uint8_t debug1, uint16_t debug2,
uint32_t debug3)
{
struct __attribute__((__packed__)) {
uint8_t debug0;
uint8_t debug1;
uint16_t debug2;
uint32_t debug3;
} debug_msg_data;

debug_msg_data.debug0 = debug0;
debug_msg_data.debug1 = debug1;
debug_msg_data.debug2 = debug2;
debug_msg_data.debug3 = debug3;

can_msg_t debug_msg;
debug_msg.id = 0x702;
debug_msg.len = 8; // yaml decodes this msg as 8 bytes

if (len > 8) {
len = 8;
}
endian_swap(&debug_msg_data.debug2, sizeof(debug_msg_data.debug2));
endian_swap(&debug_msg_data.debug3, sizeof(debug_msg_data.debug3));

memset(debug_msg.data, 0, 8);
memcpy(debug_msg.data, data, len);
endian_swap(debug_msg.data, 8);
memcpy(debug_msg.data, &debug_msg_data, 8);

#ifdef CHARGING_ENABLED
can_t *line = &can2;
Expand Down
2 changes: 1 addition & 1 deletion Core/Src/stateMachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void sm_handle_state(acc_data_t *bmsdata)
break;

case CAN_DEBUG:
compute_send_debug_message(&crc_error_check, 2);
compute_send_debug_message(0,0, crc_error_check, 0);

default:
break;
Expand Down

0 comments on commit 218bdf0

Please sign in to comment.