Skip to content
This repository was archived by the owner on Mar 22, 2024. It is now read-only.

Added SERIALCOMMAND_ECHO macro to enable serial echo #11

Open
wants to merge 0 commits into
base: master
Choose a base branch
from

Conversation

b-
Copy link

@b- b- commented Sep 30, 2016

I didn't want to enable full on debug mode, but I want to be able to see my commands as I type them. So I added an "echo mode."

Copy link
Owner

@kroimon kroimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my comments on your code.
In general, I like the idea and will merge if you fix the small issues.

@@ -124,6 +124,11 @@ void SerialCommand::readSerial() {
#endif
}
}
else if (inChar == 127 || inChar == 8) {
bufPos--;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates a possible buffer-overflow when deleting more characters than there are in the buffer (i.e. bufPos rolls over from 0 to 255).

@@ -124,6 +124,11 @@ void SerialCommand::readSerial() {
#endif
}
}
else if (inChar == 127 || inChar == 8) {
bufPos--;
buffer[bufPos] = 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use '\0' here instead of 0 to make clear we're writing a character.

else if (inChar == 127 || inChar == 8) {
bufPos--;
buffer[bufPos] = 0;
Serial.print(" \b");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the space before the \b for?
Also: wrap in #if defined SERIALCOMMAND_DEBUG || defined SERIALCOMMAND_ECHO!

@@ -1,23 +1,23 @@
/**
* SerialCommand - A Wiring/Arduino library to tokenize and parse commands
* received over a serial port.
*
*
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove whitespace-only changes from your PR.

@b-
Copy link
Author

b- commented May 25, 2018 via email

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants