mirror of https://github.com/rusefi/bldc.git
Added function to unregister previously registered reply function
This commit is contained in:
parent
cf6723ba25
commit
40e9e29075
|
@ -165,6 +165,21 @@ void commands_send_packet_last_blocking(unsigned char *data, unsigned int len) {
|
|||
}
|
||||
}
|
||||
|
||||
void commands_unregister_reply_func(void(*reply_func)(unsigned char *data, unsigned int len)) {
|
||||
if (send_func == reply_func) {
|
||||
send_func = NULL;
|
||||
}
|
||||
if (send_func_blocking == reply_func) {
|
||||
send_func_blocking = NULL;
|
||||
}
|
||||
if (send_func_nrf == reply_func) {
|
||||
send_func_nrf = NULL;
|
||||
}
|
||||
if (send_func_can_fwd == reply_func) {
|
||||
send_func_can_fwd = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a received buffer with commands and data.
|
||||
*
|
||||
|
|
|
@ -29,6 +29,7 @@ void commands_send_packet(unsigned char *data, unsigned int len);
|
|||
void commands_send_packet_can_last(unsigned char *data, unsigned int len);
|
||||
void commands_send_packet_nrf(unsigned char *data, unsigned int len);
|
||||
void commands_send_packet_last_blocking(unsigned char *data, unsigned int len);
|
||||
void commands_unregister_reply_func(void(*reply_func)(unsigned char *data, unsigned int len));
|
||||
void commands_process_packet(unsigned char *data, unsigned int len,
|
||||
void(*reply_func)(unsigned char *data, unsigned int len));
|
||||
int commands_printf(const char* format, ...);
|
||||
|
|
|
@ -495,6 +495,9 @@ typedef struct {
|
|||
// System lock (with counting)
|
||||
void (*sys_lock)(void);
|
||||
void (*sys_unlock)(void);
|
||||
|
||||
// Unregister pointers to previously used reply function
|
||||
void (*commands_unregister_reply_func)(void(*reply_func)(unsigned char *data, unsigned int len));
|
||||
} vesc_c_if;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -780,6 +780,9 @@ lbm_value ext_load_native_lib(lbm_value *args, lbm_uint argn) {
|
|||
cif.cif.sys_lock = utils_sys_lock_cnt;
|
||||
cif.cif.sys_unlock = utils_sys_unlock_cnt;
|
||||
|
||||
// Unregister pointers to previously used reply function
|
||||
cif.cif.commands_unregister_reply_func = commands_unregister_reply_func;
|
||||
|
||||
lib_init_done = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue