Skip to content

Commit 98d08e6

Browse files
authored
Fix the issue of abnormal modification of motion_rownsample
Fix the issue of abnormal modification of motion_rownsample Problem reproduction command sequence: send: MMS1111111\n MMS0\n MCD\n rcv: Motion: downsample: 11111
1 parent add1f42 commit 98d08e6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/communication/Commander.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ void Commander::run(Stream& serial, char eol){
4343
run(received_chars);
4444

4545
// reset the command buffer
46-
received_chars[0] = 0;
46+
memset(received_chars, 0, MAX_COMMAND_LENGTH);
4747
rec_cnt=0;
4848
}
4949
if (rec_cnt>=MAX_COMMAND_LENGTH) { // prevent buffer overrun if message is too long
50-
received_chars[0] = 0;
50+
memset(received_chars, 0, MAX_COMMAND_LENGTH);
5151
rec_cnt=0;
5252
}
5353
}
@@ -363,7 +363,8 @@ void Commander::motor(FOCMotor* motor, char* user_command) {
363363
void Commander::motion(FOCMotor* motor, char* user_cmd, char* separator){
364364
char cmd = user_cmd[0];
365365
char sub_cmd = user_cmd[1];
366-
bool GET = isSentinel(user_cmd[1]);
366+
int value_index = (sub_cmd == SCMD_DOWNSAMPLE) ? 2 : 1;
367+
bool GET = isSentinel(user_cmd[value_index]);
367368
float value = atof(&user_cmd[(sub_cmd >= 'A' && sub_cmd <= 'Z') ? 2 : 1]);
368369

369370
switch(cmd){

0 commit comments

Comments
 (0)