diff --git a/comm/commands.c b/comm/commands.c index f2eff861..907e88e6 100644 --- a/comm/commands.c +++ b/comm/commands.c @@ -2229,7 +2229,7 @@ static THD_FUNCTION(blocking_thread, arg) { float sl_erpm = buffer_get_float32(data, 1e3, &ind); int res = conf_general_detect_apply_all_foc_can(detect_can, max_power_loss, - min_current_in, max_current_in, openloop_rpm, sl_erpm); + min_current_in, max_current_in, openloop_rpm, sl_erpm, send_func_blocking); ind = 0; send_buffer[ind++] = COMM_DETECT_APPLY_ALL_FOC; diff --git a/conf_general.c b/conf_general.c index ab73414d..3a35f24e 100644 --- a/conf_general.c +++ b/conf_general.c @@ -2002,13 +2002,19 @@ int conf_general_detect_apply_all_foc(float max_power_loss, * @param sl_erpm * FOC ERPM above which sensorless should be used in sensored modes. 0 means leave it unchanged. * + * @param reply_func + * Send the motor and app config using this function pointer. If it is null the last function + * from commands will be used. + * * @return * Same as conf_general_detect_apply_all_foc, and * -50: CAN detection timed out * -51: CAN detection failed */ int conf_general_detect_apply_all_foc_can(bool detect_can, float max_power_loss, - float min_current_in, float max_current_in, float openloop_rpm, float sl_erpm) { + float min_current_in, float max_current_in, + float openloop_rpm, float sl_erpm, + void(*reply_func)(unsigned char* data, unsigned int len)) { int motor_last = mc_interface_get_motor_thread(); mc_interface_select_motor_thread(1); @@ -2126,7 +2132,7 @@ int conf_general_detect_apply_all_foc_can(bool detect_can, float max_power_loss, appconf->can_status_msgs_r1 = 0b00001111; conf_general_store_app_configuration(appconf); app_set_configuration(appconf); - commands_send_appconf(COMM_GET_APPCONF, appconf, 0); + commands_send_appconf(COMM_GET_APPCONF, appconf, reply_func); chThdSleepMilliseconds(1000); } @@ -2139,7 +2145,7 @@ int conf_general_detect_apply_all_foc_can(bool detect_can, float max_power_loss, mc_interface_select_motor_thread(1); *mcconf = *mc_interface_get_configuration(); #endif - commands_send_mcconf(COMM_GET_MCCONF, mcconf, 0); + commands_send_mcconf(COMM_GET_MCCONF, mcconf, reply_func); chThdSleepMilliseconds(1000); } diff --git a/conf_general.h b/conf_general.h index 4e57b093..ea700080 100755 --- a/conf_general.h +++ b/conf_general.h @@ -24,7 +24,7 @@ #define FW_VERSION_MAJOR 6 #define FW_VERSION_MINOR 00 // Set to 0 for building a release and iterate during beta test builds -#define FW_TEST_VERSION_NUMBER 81 +#define FW_TEST_VERSION_NUMBER 82 #include "datatypes.h" @@ -189,7 +189,9 @@ void conf_general_calc_apply_foc_cc_kp_ki_gain(mc_configuration *mcconf, float t int conf_general_detect_apply_all_foc(float max_power_loss, bool store_mcconf_on_success, bool send_mcconf_on_success); int conf_general_detect_apply_all_foc_can(bool detect_can, float max_power_loss, - float min_current_in, float max_current_in, float openloop_rpm, float sl_erpm); + float min_current_in, float max_current_in, + float openloop_rpm, float sl_erpm, + void(*reply_func)(unsigned char* data, unsigned int len)); #endif /* CONF_GENERAL_H_ */ diff --git a/lispBM/lispif_vesc_extensions.c b/lispBM/lispif_vesc_extensions.c index 72dad7f7..1a3609ea 100644 --- a/lispBM/lispif_vesc_extensions.c +++ b/lispBM/lispif_vesc_extensions.c @@ -3399,7 +3399,7 @@ typedef struct { static void detect_task(void *arg) { detect_args *a = (detect_args*)arg; int res = conf_general_detect_apply_all_foc_can(a->detect_can, a->max_power_loss, - a->min_current_in, a->max_current_in, a->openloop_rpm, a->sl_erpm); + a->min_current_in, a->max_current_in, a->openloop_rpm, a->sl_erpm, NULL); lbm_unblock_ctx(a->id, lbm_enc_i(res)); } diff --git a/terminal.c b/terminal.c index 5660d4f1..9e76e7ef 100644 --- a/terminal.c +++ b/terminal.c @@ -879,7 +879,7 @@ void terminal_process_string(char *str) { commands_printf("Running detection..."); if (max_power_loss > 0.0) { - int res = conf_general_detect_apply_all_foc_can(true, max_power_loss, 0.0, 0.0, 0.0, 0.0); + int res = conf_general_detect_apply_all_foc_can(true, max_power_loss, 0.0, 0.0, 0.0, 0.0, NULL); commands_printf("Res: %d", res);