Skip to content

Commit 2d78e7e

Browse files
authored
Merge pull request #438 from CodeMan-P/patch-1
Fix the issue of abnormal modification of motion_downsample
2 parents 1d1d57c + 98d08e6 commit 2d78e7e

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
}
@@ -380,7 +380,8 @@ void Commander::motor(FOCMotor* motor, char* user_command) {
380380
void Commander::motion(FOCMotor* motor, char* user_cmd, char* separator){
381381
char cmd = user_cmd[0];
382382
char sub_cmd = user_cmd[1];
383-
bool GET = isSentinel(user_cmd[1]);
383+
int value_index = (sub_cmd == SCMD_DOWNSAMPLE) ? 2 : 1;
384+
bool GET = isSentinel(user_cmd[value_index]);
384385
float value = atof(&user_cmd[(sub_cmd >= 'A' && sub_cmd <= 'Z') ? 2 : 1]);
385386

386387
switch(cmd){

0 commit comments

Comments
 (0)