Skip to content

motor.command() and CRLF #46

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

Closed
owennewo opened this issue Jan 2, 2021 · 5 comments
Closed

motor.command() and CRLF #46

owennewo opened this issue Jan 2, 2021 · 5 comments

Comments

@owennewo
Copy link
Member

owennewo commented Jan 2, 2021

This confused me - so I'm raising an issue for discussion.

motor.command(String) doesn't work well with Serial set to eol=CRLF (i.e. \r\n)

With CRLF all commands are 'sets' e.g. P will set the P term to zero.

A fix for this is to either configure your serial terminal to LF (\n)
e.g. platformio (which defaults to CRLF) you could set the following in you platformio.ini

monitor_flags =
  --eol
    LF

If we wanted to be more 'tolerant' we could change the code e.g. to be:

  char GET = user_command.charAt(1) == '\n' || user_command.charAt(1) == '\r';
@askuric
Copy link
Member

askuric commented Jan 27, 2021

@askuric askuric closed this as completed May 9, 2021
@askuric askuric reopened this May 9, 2021
@maxlem
Copy link
Contributor

maxlem commented May 9, 2021

Just to mention that I just spent at least an hour trying to figure out with commander wasn't accepting my input
I'm using screen under linux, it's a very, very common way to interface with serial devices under linux.
so I went on and adde ddebug printouts until I found out that you were listening for a trailing \n.

ended up with this
int ch = serial.read(); received_chars[rec_cnt++] = (char)ch; // end of user input if (ch == '\n' || ch == '\r') [...]

I really think it should be patched asap, no matter what happens next with the commander interface?

Do you want a pull request?

@askuric
Copy link
Member

askuric commented May 10, 2021

You're right. If you have time go for it. :)

@askuric
Copy link
Member

askuric commented May 10, 2021

maxlem pushed a commit to maxlem/Arduino-FOC that referenced this issue May 10, 2021
The eol character is now configurable
The user can now actuvate echo feedback to see what he is typing
I also removed a duplication in two run() overload, while fixing what I think was a mistake by enforcing the use of the provided argument Stream& even if the ctor one is not null.
Lastly, I warn the user if \n is configured but \r is detected (only in user friendly mode)
All the past code should work as before (no API change required)
@maxlem
Copy link
Contributor

maxlem commented May 10, 2021

see #75

Thank you!

maxlem pushed a commit to maxlem/Arduino-FOC that referenced this issue May 10, 2021
askuric added a commit that referenced this issue May 13, 2021
Issue #46: motor.command() and CRLF
@askuric askuric closed this as completed May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants