Skip to content

Commit 5770bc7

Browse files
committed
checked uart_tx_cb null or not
1 parent 880736b commit 5770bc7

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

cubemx/UserLib/machine/Src/machine.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,12 @@ error_code machine_start (struct command_machine* self)
100100

101101
else
102102
{
103-
self -> uart_tx_cb ((uint8_t *)self -> current_command_window -> command_table[self -> command_index] -> command_name,
104-
strlen(self -> current_command_window -> command_table[self -> command_index] -> command_name));
105-
}
103+
if (self -> uart_tx_cb != NULL)
104+
{
105+
self -> uart_tx_cb ((uint8_t *)self -> current_command_window -> command_table[self -> command_index] -> command_name,
106+
strlen(self -> current_command_window -> command_table[self -> command_index] -> command_name));
107+
}
108+
}
106109

107110
self -> timer = 1;
108111

@@ -260,8 +263,12 @@ error_code machine_loop (struct command_machine* self)
260263

261264
else
262265
{
263-
self -> uart_tx_cb((uint8_t *)self -> current_command_window -> command_table[self -> command_index] -> command_name,
264-
strlen(self -> current_command_window -> command_table[self -> command_index] -> command_name));
266+
if (self -> uart_tx_cb != NULL)
267+
{
268+
self -> uart_tx_cb((uint8_t *)self -> current_command_window -> command_table[self -> command_index] -> command_name,
269+
strlen(self -> current_command_window -> command_table[self -> command_index] -> command_name));
270+
}
271+
265272
}
266273

267274
self -> is_state_transition_available = 0;

0 commit comments

Comments
 (0)