Skip to content

Dev #77

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

Merged
merged 3 commits into from
May 13, 2021
Merged

Dev #77

Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions src/communication/Commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ void Commander::run(Stream& serial, char eol){
received_chars[0] = 0;
rec_cnt=0;
}
if (rec_cnt>=MAX_COMMAND_LENGTH) { // prevent buffer overrun if message is too long
received_chars[0] = 0;
rec_cnt=0;
}
}

com_port = tmp; // reset the instance to the internal value
Expand Down
6 changes: 5 additions & 1 deletion src/communication/Commander.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include "../common/lowpass_filter.h"
#include "commands.h"


#define MAX_COMMAND_LENGTH 20


// Commander verbose display to the user type
enum VerboseMode{
nothing = 0, // display nothing - good for monitoring
Expand Down Expand Up @@ -178,7 +182,7 @@ class Commander
int call_count = 0;//!< number callbacks that are subscribed

// helping variable for serial communication reading
char received_chars[20] = {0}; //!< so far received user message - waiting for newline
char received_chars[MAX_COMMAND_LENGTH] = {0}; //!< so far received user message - waiting for newline
int rec_cnt = 0; //!< number of characters receives

// serial printing functions
Expand Down