@@ -58,8 +58,8 @@ static volatile unsigned int blocking_thread_cmd_len = 0;
58
58
static volatile bool is_blocking = false;
59
59
static void (* volatile send_func )(unsigned char * data , unsigned int len ) = 0 ;
60
60
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 ;
62
61
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 ;
63
63
static disp_pos_mode display_position_mode ;
64
64
static mutex_t print_mutex ;
65
65
static mutex_t send_buffer_mutex ;
@@ -137,14 +137,17 @@ void commands_process_packet(unsigned char *data, unsigned int len,
137
137
}
138
138
139
139
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 ;
141
143
static app_configuration appconf ;
142
144
143
145
packet_id = data [0 ];
144
146
data ++ ;
145
147
len -- ;
146
148
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.
148
151
if (packet_id == COMM_EXT_NRF_PRESENT ||
149
152
packet_id == COMM_EXT_NRF_ESB_RX_DATA ) {
150
153
send_func_nrf = reply_func ;
@@ -835,7 +838,9 @@ void commands_process_packet(unsigned char *data, unsigned int len,
835
838
}
836
839
} break ;
837
840
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.
839
844
case COMM_TERMINAL_CMD :
840
845
case COMM_DETECT_MOTOR_PARAM :
841
846
case COMM_DETECT_MOTOR_R_L :
@@ -845,7 +850,7 @@ void commands_process_packet(unsigned char *data, unsigned int len,
845
850
case COMM_DETECT_MOTOR_FLUX_LINKAGE_OPENLOOP :
846
851
case COMM_DETECT_APPLY_ALL_FOC :
847
852
case COMM_PING_CAN :
848
- if (!is_blocking && len < sizeof ( blocking_thread_cmd_buffer ) ) {
853
+ if (!is_blocking ) {
849
854
memcpy (blocking_thread_cmd_buffer , data - 1 , len + 1 );
850
855
blocking_thread_cmd_len = len ;
851
856
is_blocking = true;
@@ -1222,8 +1227,6 @@ static THD_FUNCTION(blocking_thread, arg) {
1222
1227
1223
1228
case COMM_PING_CAN : {
1224
1229
int32_t ind = 0 ;
1225
- // Send buffer cannot be used, as it might be altered while waiting
1226
- // for pings.
1227
1230
send_buffer [ind ++ ] = COMM_PING_CAN ;
1228
1231
1229
1232
for (uint8_t i = 0 ;i < 255 ;i ++ ) {
0 commit comments