mirror of https://github.com/rusefi/bldc.git
Merge pull request #493 from avlasic/get_config_fix
Send back app and mc config to requester port
This commit is contained in:
commit
558ccafdbe
20
commands.c
20
commands.c
|
@ -573,7 +573,7 @@ void commands_process_packet(unsigned char *data, unsigned int len,
|
|||
mcconf->foc_offsets_voltage_undriven[2] = mcconf_now->foc_offsets_voltage_undriven[2];
|
||||
}
|
||||
|
||||
commands_send_mcconf(packet_id, mcconf);
|
||||
commands_send_mcconf(packet_id, mcconf, reply_func);
|
||||
mempools_free_mcconf(mcconf);
|
||||
} break;
|
||||
|
||||
|
@ -623,7 +623,7 @@ void commands_process_packet(unsigned char *data, unsigned int len,
|
|||
}
|
||||
#endif
|
||||
|
||||
commands_send_appconf(packet_id, appconf);
|
||||
commands_send_appconf(packet_id, appconf, reply_func);
|
||||
|
||||
mempools_free_appconf(appconf);
|
||||
} break;
|
||||
|
@ -1748,19 +1748,27 @@ void commands_send_gpd_buffer_notify(void) {
|
|||
commands_send_packet(buffer, index);
|
||||
}
|
||||
|
||||
void commands_send_mcconf(COMM_PACKET_ID packet_id, mc_configuration *mcconf) {
|
||||
void commands_send_mcconf(COMM_PACKET_ID packet_id, mc_configuration* mcconf, void(*reply_func)(unsigned char* data, unsigned int len)) {
|
||||
chMtxLock(&send_buffer_mutex);
|
||||
send_buffer_global[0] = packet_id;
|
||||
int32_t len = confgenerator_serialize_mcconf(send_buffer_global + 1, mcconf);
|
||||
commands_send_packet(send_buffer_global, len + 1);
|
||||
if (reply_func) {
|
||||
reply_func(send_buffer_global, len + 1);
|
||||
} else {
|
||||
commands_send_packet(send_buffer_global, len + 1);
|
||||
}
|
||||
chMtxUnlock(&send_buffer_mutex);
|
||||
}
|
||||
|
||||
void commands_send_appconf(COMM_PACKET_ID packet_id, app_configuration *appconf) {
|
||||
void commands_send_appconf(COMM_PACKET_ID packet_id, app_configuration *appconf, void(*reply_func)(unsigned char* data, unsigned int len)) {
|
||||
chMtxLock(&send_buffer_mutex);
|
||||
send_buffer_global[0] = packet_id;
|
||||
int32_t len = confgenerator_serialize_appconf(send_buffer_global + 1, appconf);
|
||||
commands_send_packet(send_buffer_global, len + 1);
|
||||
if (reply_func) {
|
||||
reply_func(send_buffer_global, len + 1);
|
||||
} else {
|
||||
commands_send_packet(send_buffer_global, len + 1);
|
||||
}
|
||||
chMtxUnlock(&send_buffer_mutex);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,8 +46,10 @@ void commands_set_hw_data_handler(void(*func)(unsigned char *data, unsigned int
|
|||
void commands_send_app_data(unsigned char *data, unsigned int len);
|
||||
void commands_send_hw_data(unsigned char *data, unsigned int len);
|
||||
void commands_send_gpd_buffer_notify(void);
|
||||
void commands_send_mcconf(COMM_PACKET_ID packet_id, mc_configuration *mcconf);
|
||||
void commands_send_appconf(COMM_PACKET_ID packet_id, app_configuration *appconf);
|
||||
void commands_send_mcconf(COMM_PACKET_ID packet_id, mc_configuration* mcconf,
|
||||
void(*reply_func)(unsigned char* data, unsigned int len));
|
||||
void commands_send_appconf(COMM_PACKET_ID packet_id, app_configuration* appconf,
|
||||
void(*reply_func)(unsigned char* data, unsigned int len));
|
||||
void commands_apply_mcconf_hw_limits(mc_configuration *mcconf);
|
||||
void commands_init_plot(char *namex, char *namey);
|
||||
void commands_plot_add_graph(char *name);
|
||||
|
|
|
@ -1314,7 +1314,7 @@ int conf_general_autodetect_apply_sensors_foc(float current,
|
|||
}
|
||||
|
||||
if (send_mcconf_on_success) {
|
||||
commands_send_mcconf(COMM_GET_MCCONF, mcconf_old);
|
||||
commands_send_mcconf(COMM_GET_MCCONF, mcconf_old, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1959,7 +1959,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);
|
||||
commands_send_appconf(COMM_GET_APPCONF, appconf, 0);
|
||||
chThdSleepMilliseconds(1000);
|
||||
}
|
||||
|
||||
|
@ -1972,7 +1972,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);
|
||||
commands_send_mcconf(COMM_GET_MCCONF, mcconf, 0);
|
||||
chThdSleepMilliseconds(1000);
|
||||
}
|
||||
|
||||
|
|
|
@ -499,7 +499,7 @@ void nrf_driver_process_packet(unsigned char *buf, unsigned char len) {
|
|||
conf_general_store_app_configuration(&appconf);
|
||||
app_set_configuration(&appconf);
|
||||
|
||||
commands_send_appconf(COMM_GET_APPCONF, &appconf);
|
||||
commands_send_appconf(COMM_GET_APPCONF, &appconf, 0);
|
||||
|
||||
unsigned char data[2];
|
||||
data[0] = COMM_NRF_START_PAIRING;
|
||||
|
|
Loading…
Reference in New Issue