Skip to content

Buffer pollution turns some get commands to set #511

@edco

Description

@edco

Issuing the following sequence of commands results in a motion downsampling query turning into a set:

  • MLC0.5
  • MCD

The issue is that once a sentinel character is found, the buffer is passed to run as-is:

// a string to hold incoming data
while (serial.available()) {
// get the new byte:
int ch = serial.read();
received_chars[rec_cnt++] = (char)ch;
// end of user input
if(echo)
print((char)ch);
if (isSentinel(ch)) {
// execute the user command
run(received_chars);

Later atof reads past the sentinel and picks up the trailing 5 in the buffer, and the downsampling is set to 5. The least invasive solution might be to null out the character after the sentinel (if we're not at the end of the buffer).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions