Skip to content

Commit e5c5b3e

Browse files
committed
Fixed CAN reply mapping problem
1 parent 3322c29 commit e5c5b3e

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

comm_can.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ static void decode_msg(uint32_t eid, uint8_t *data8, int len, bool is_replaced)
12301230
commands_process_packet(rx_buffer, rxbuf_len, send_packet_wrapper);
12311231
break;
12321232
case 1:
1233-
commands_send_packet(rx_buffer, rxbuf_len);
1233+
commands_send_packet_can_last(rx_buffer, rxbuf_len);
12341234
break;
12351235
case 2:
12361236
commands_process_packet(rx_buffer, rxbuf_len, 0);
@@ -1261,7 +1261,7 @@ static void decode_msg(uint32_t eid, uint8_t *data8, int len, bool is_replaced)
12611261
commands_process_packet(data8 + ind, len - ind, send_packet_wrapper);
12621262
break;
12631263
case 1:
1264-
commands_send_packet(data8 + ind, len - ind);
1264+
commands_send_packet_can_last(data8 + ind, len - ind);
12651265
break;
12661266
case 2:
12671267
commands_process_packet(data8 + ind, len - ind, 0);

commands.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ static volatile int blocking_thread_motor = 1;
6868
static void(* volatile send_func)(unsigned char *data, unsigned int len) = 0;
6969
static void(* volatile send_func_blocking)(unsigned char *data, unsigned int len) = 0;
7070
static void(* volatile send_func_nrf)(unsigned char *data, unsigned int len) = 0;
71+
static void(* volatile send_func_can_fwd)(unsigned char *data, unsigned int len) = 0;
7172
static void(* volatile appdata_func)(unsigned char *data, unsigned int len) = 0;
7273
static disp_pos_mode display_position_mode;
7374
static mutex_t print_mutex;
@@ -97,6 +98,21 @@ void commands_send_packet(unsigned char *data, unsigned int len) {
9798
}
9899
}
99100

101+
/**
102+
* Send a packet using the last can fwd function.
103+
*
104+
* @param data
105+
* The packet data.
106+
*
107+
* @param len
108+
* The data length.
109+
*/
110+
void commands_send_packet_can_last(unsigned char *data, unsigned int len) {
111+
if (send_func_can_fwd) {
112+
send_func_can_fwd(data, len);
113+
}
114+
}
115+
100116
/**
101117
* Send a packet using the set NRF51 send function. The NRF51 send function
102118
* is set when the COMM_EXT_NRF_PRESENT and COMM_EXT_NRF_ESB_RX_DATA commands
@@ -602,6 +618,8 @@ void commands_process_packet(unsigned char *data, unsigned int len,
602618
} break;
603619

604620
case COMM_FORWARD_CAN: {
621+
send_func_can_fwd = reply_func;
622+
605623
#ifdef HW_HAS_DUAL_MOTORS
606624
if (data[0] == utils_second_motor_id()) {
607625
mc_interface_select_motor_thread(2);

commands.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
// Functions
2626
void commands_init(void);
2727
void commands_send_packet(unsigned char *data, unsigned int len);
28+
void commands_send_packet_can_last(unsigned char *data, unsigned int len);
2829
void commands_send_packet_nrf(unsigned char *data, unsigned int len);
2930
void commands_send_packet_last_blocking(unsigned char *data, unsigned int len);
3031
void commands_process_packet(unsigned char *data, unsigned int len,

0 commit comments

Comments
 (0)