Skip to content

Commit 0db2f20

Browse files
committed
Updated some comments in commands to make it easier to follow
1 parent 9cbddf4 commit 0db2f20

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

commands.c

+10-7
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ static volatile unsigned int blocking_thread_cmd_len = 0;
5858
static volatile bool is_blocking = false;
5959
static void(* volatile send_func)(unsigned char *data, unsigned int len) = 0;
6060
static void(* volatile send_func_blocking)(unsigned char *data, unsigned int len) = 0;
61-
static void(* volatile appdata_func)(unsigned char *data, unsigned int len) = 0;
6261
static void(* volatile send_func_nrf)(unsigned char *data, unsigned int len) = 0;
62+
static void(* volatile appdata_func)(unsigned char *data, unsigned int len) = 0;
6363
static disp_pos_mode display_position_mode;
6464
static mutex_t print_mutex;
6565
static mutex_t send_buffer_mutex;
@@ -137,14 +137,17 @@ void commands_process_packet(unsigned char *data, unsigned int len,
137137
}
138138

139139
COMM_PACKET_ID packet_id;
140-
static mc_configuration mcconf; // Static to save some stack space
140+
141+
// Static to save some stack space
142+
static mc_configuration mcconf;
141143
static app_configuration appconf;
142144

143145
packet_id = data[0];
144146
data++;
145147
len--;
146148

147-
// These packets should not make the sender the default one.
149+
// The NRF51 ESB implementation is treated like it has its own
150+
// independent communication interface.
148151
if (packet_id == COMM_EXT_NRF_PRESENT ||
149152
packet_id == COMM_EXT_NRF_ESB_RX_DATA) {
150153
send_func_nrf = reply_func;
@@ -835,7 +838,9 @@ void commands_process_packet(unsigned char *data, unsigned int len,
835838
}
836839
} break;
837840

838-
// Blocking operations
841+
// Blocking commands. Only one of them runs at any given time, in their
842+
// own thread. If other blocking commands come before the previous one has
843+
// finished, they are discarded.
839844
case COMM_TERMINAL_CMD:
840845
case COMM_DETECT_MOTOR_PARAM:
841846
case COMM_DETECT_MOTOR_R_L:
@@ -845,7 +850,7 @@ void commands_process_packet(unsigned char *data, unsigned int len,
845850
case COMM_DETECT_MOTOR_FLUX_LINKAGE_OPENLOOP:
846851
case COMM_DETECT_APPLY_ALL_FOC:
847852
case COMM_PING_CAN:
848-
if (!is_blocking && len < sizeof(blocking_thread_cmd_buffer)) {
853+
if (!is_blocking) {
849854
memcpy(blocking_thread_cmd_buffer, data - 1, len + 1);
850855
blocking_thread_cmd_len = len;
851856
is_blocking = true;
@@ -1222,8 +1227,6 @@ static THD_FUNCTION(blocking_thread, arg) {
12221227

12231228
case COMM_PING_CAN: {
12241229
int32_t ind = 0;
1225-
// Send buffer cannot be used, as it might be altered while waiting
1226-
// for pings.
12271230
send_buffer[ind++] = COMM_PING_CAN;
12281231

12291232
for (uint8_t i = 0;i < 255;i++) {

0 commit comments

Comments
 (0)