Skip to content

Serial Plotter requires \r\n line endings #1360

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
3 tasks done
sellensr opened this issue Aug 26, 2022 · 3 comments · Fixed by #1516
Closed
3 tasks done

Serial Plotter requires \r\n line endings #1360

sellensr opened this issue Aug 26, 2022 · 3 comments · Fixed by #1516
Assignees
Labels
conclusion: resolved Issue was resolved topic: infrastructure Related to project infrastructure type: imperfection Perceived defect in any part of project

Comments

@sellensr
Copy link

sellensr commented Aug 26, 2022

Describe the problem

Plotter appears to ignore lines that don't end with both \r and \n in that order. Previous versions worked with lines ending in \n, as does the serial monitor.

I'm not sure if this is an intended behaviour. It isn't mentioned in the tutorial at https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-serial-plotter

To reproduce

Serial.printf("A:%d,Var2:%d\n",random_variable,static_variable);

and look for output on Serial Plotter. Then change to

Serial.printf("A:%d,Var2:%d\r\n",random_variable,static_variable);

Expected behavior

I would expect the plotter to function with any permutation of line endings, e.g. detect \r or \n as an ending, then discard any additional \r or \n until new line begins.

Arduino IDE version

IDE 2.0 rc9.2

Operating system

macOS

Operating system version

12.5.1

Additional context

No response

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details
@sellensr sellensr added the type: imperfection Perceived defect in any part of project label Aug 26, 2022
@per1234
Copy link
Contributor

per1234 commented Aug 26, 2022

Thanks for your report @sellensr. This bug is being tracked in the repository that hosts the Serial Plotter codebase: arduino/arduino-serial-plotter-webapp#8

Even though this is a duplicate of that one, I will leave it open for now because I think it will serve as a more effective way of documenting this defect, since users are less likely to be aware of the existence of the arduino/arduino-serial-plotter-webapp repository.

@per1234 per1234 self-assigned this Aug 26, 2022
@davegarthsimpson davegarthsimpson self-assigned this Aug 29, 2022
@davegarthsimpson davegarthsimpson added criticality: low Of low impact priority: low Resolution is a low priority labels Aug 29, 2022
@per1234 per1234 added priority: high Resolution is a high priority criticality: high Of high impact and removed priority: low Resolution is a low priority criticality: low Of low impact labels Sep 3, 2022
@nmzaheer
Copy link
Contributor

nmzaheer commented Sep 5, 2022

@per1234 arduino/arduino-serial-plotter-webapp#8 is closed now, can we consider this as closed or is there some testing that needs to be done?

Further, the OP has written that the Serial Plotter should handle all kinds of linebreaks, whereas the Serial Plotter protocol recognises LF "\n" as the only allowed linebreak character.

Should this be captured somewhere in the documentation for users? It is unlikely that users will look at the protocol for their answer.

@per1234
Copy link
Contributor

per1234 commented Sep 5, 2022

can we consider this as closed

Even though it is resolved, the reason I left this issue open despite there being another in the plotter's repository was with the idea of documenting the bug for Arduino IDE users.

Those users will still be affected until there is a release of the arduino-serial-plotter-webapp package and this project's dependency bumped to the version with the fix.

testing that needs to be done?

Testing is always welcome. I did some today, but it is possible others might catch something I missed.

OP has written that the Serial Plotter should handle all kinds of linebreaks, whereas the Serial Plotter protocol recognises LF "\n" as the only allowed linebreak character.

Even though not mentioned explicitly in the current documentation, \r\n is also supported in Serial Plotter due to this:

https://github.com/arduino/arduino-serial-plotter-webapp/blob/eac6d39f3f5156390bc4f9e09cafcccc121248c9/src/msgAggregatorWorker.ts#L97

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat#description

If parseFloat encounters a character other than a plus sign (+), minus sign (- U+002D HYPHEN-MINUS), numeral (09), decimal point (.), or exponent (e or E), it returns the value up to that character, ignoring the invalid character and characters following it.

This is also the case in the Arduino IDE 1.x Serial Plotter, and in fact the example code in the "SerialPlotter protocol" document relies on that support (Serial.println() uses \r\n line ending)

So the only line ending not supported is \r alone, as is the case in Arduino IDE 1.x Serial Plotter.

Should this be captured somewhere in the documentation for users? It is unlikely that users will look at the protocol for their answer.

Excellent point! This important information is not at all easy for the users to find.

I think the correct place to document it here:

https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-serial-plotter

The source of that content is hosted here:

https://github.com/arduino/docs-content/blob/main/content/software/ide-v2/tutorials/ide-v2-serial-plotter/ide-v2-serial-plotter.md

You are welcome to submit an issue to the arduino/docs-content repository requesting the documentation, or better yet to submit a pull request contributing the changes to the file directly.

@per1234 per1234 added the topic: infrastructure Related to project infrastructure label Oct 3, 2022
@per1234 per1234 added conclusion: resolved Issue was resolved and removed priority: high Resolution is a high priority criticality: high Of high impact labels Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: infrastructure Related to project infrastructure type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants