Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the issue of abnormal modification of motion_downsample #438

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/communication/Commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ void Commander::run(Stream& serial, char eol){
run(received_chars);

// reset the command buffer
received_chars[0] = 0;
memset(received_chars, 0, MAX_COMMAND_LENGTH);
rec_cnt=0;
}
if (rec_cnt>=MAX_COMMAND_LENGTH) { // prevent buffer overrun if message is too long
received_chars[0] = 0;
memset(received_chars, 0, MAX_COMMAND_LENGTH);
rec_cnt=0;
}
}
Expand Down Expand Up @@ -363,7 +363,8 @@ void Commander::motor(FOCMotor* motor, char* user_command) {
void Commander::motion(FOCMotor* motor, char* user_cmd, char* separator){
char cmd = user_cmd[0];
char sub_cmd = user_cmd[1];
bool GET = isSentinel(user_cmd[1]);
int value_index = (sub_cmd == SCMD_DOWNSAMPLE) ? 2 : 1;
bool GET = isSentinel(user_cmd[value_index]);
float value = atof(&user_cmd[(sub_cmd >= 'A' && sub_cmd <= 'Z') ? 2 : 1]);

switch(cmd){
Expand Down