mirror of https://github.com/rusefi/bldc.git
Pass reply_func to sample_send_thread
When data is being sampled another command can be received on a different port and cause the sampled data to be sent to the wrong port. This change saves the reply_func for the requester so other commands can be processed on other ports without issue.
This commit is contained in:
parent
8cb88245bb
commit
16f3e5b627
|
@ -640,7 +640,7 @@ void commands_process_packet(unsigned char *data, unsigned int len,
|
|||
raw = data[ind++];
|
||||
}
|
||||
|
||||
mc_interface_sample_print_data(mode, sample_len, decimation, raw);
|
||||
mc_interface_sample_print_data(mode, sample_len, decimation, raw, send_func);
|
||||
} break;
|
||||
|
||||
case COMM_REBOOT:
|
||||
|
|
|
@ -130,6 +130,7 @@ static volatile motor_if_state_t *motor_now(void);
|
|||
|
||||
// Function pointers
|
||||
static void(*pwn_done_func)(void) = 0;
|
||||
static void(* volatile send_func_sample)(unsigned char *data, unsigned int len) = 0;
|
||||
|
||||
// Threads
|
||||
static THD_WORKING_AREA(timer_thread_wa, 512);
|
||||
|
@ -1371,7 +1372,9 @@ float mc_interface_get_last_sample_adc_isr_duration(void) {
|
|||
return m_last_adc_duration_sample;
|
||||
}
|
||||
|
||||
void mc_interface_sample_print_data(debug_sampling_mode mode, uint16_t len, uint8_t decimation, bool raw) {
|
||||
void mc_interface_sample_print_data(debug_sampling_mode mode, uint16_t len, uint8_t decimation, bool raw,
|
||||
void(*reply_func)(unsigned char *data, unsigned int len)) {
|
||||
|
||||
if (len > ADC_SAMPLE_MAX_LEN) {
|
||||
len = ADC_SAMPLE_MAX_LEN;
|
||||
}
|
||||
|
@ -1385,6 +1388,7 @@ void mc_interface_sample_print_data(debug_sampling_mode mode, uint16_t len, uint
|
|||
m_sample_int = decimation;
|
||||
m_sample_mode = mode;
|
||||
m_sample_raw = raw;
|
||||
send_func_sample = reply_func;
|
||||
#ifdef HW_HAS_DUAL_MOTORS
|
||||
m_sample_is_second_motor = motor_now() == &m_motor_2;
|
||||
#endif
|
||||
|
@ -2672,7 +2676,7 @@ static THD_FUNCTION(sample_send_thread, arg) {
|
|||
buffer[index++] = m_status_samples[ind_samp];
|
||||
buffer[index++] = m_phase_samples[ind_samp];
|
||||
|
||||
commands_send_packet(buffer, index);
|
||||
send_func_sample(buffer, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,8 @@ float mc_interface_get_pid_pos_set(void);
|
|||
float mc_interface_get_pid_pos_now(void);
|
||||
void mc_interface_update_pid_pos_offset(float angle_now, bool store);
|
||||
float mc_interface_get_last_sample_adc_isr_duration(void);
|
||||
void mc_interface_sample_print_data(debug_sampling_mode mode, uint16_t len, uint8_t decimation, bool raw);
|
||||
void mc_interface_sample_print_data(debug_sampling_mode mode, uint16_t len, uint8_t decimation, bool raw,
|
||||
void(*reply_func)(unsigned char *data, unsigned int len));
|
||||
float mc_interface_temp_fet_filtered(void);
|
||||
float mc_interface_temp_motor_filtered(void);
|
||||
float mc_interface_get_battery_level(float *wh_left);
|
||||
|
|
Loading…
Reference in New Issue