Skip to content

Add support for LF line breaks on records #8

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
per1234 opened this issue Jan 19, 2022 · 2 comments · Fixed by #12
Closed

Add support for LF line breaks on records #8

per1234 opened this issue Jan 19, 2022 · 2 comments · Fixed by #12
Assignees
Labels
conclusion: resolved Issue was resolved criticality: high Of high impact priority: high Resolution is a high priority topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@per1234
Copy link
Contributor

per1234 commented Jan 19, 2022

Describe the current behavior

The Arduino IDE Serial Plotter accepts data in a delimiter-separated format. Each record is terminated by a line break.

Currently, the only line break recognized by the Arduino IDE 2.x Serial Plotter is CRLF (\r\n).

The LF line ending is supported and officially specified as the line break character for the classic Arduino IDE Serial Plotter protocol:

https://github.com/arduino/Arduino/blob/master/build/shared/ArduinoSerialPlotterProtocol.md#serialplotter-protocol

End of message symbol \n

To reproduce

  1. Upload the following sketch to an Arduino board
    void setup() {
      Serial.begin(9600);
    }
    void loop() {
      Serial.print(random(10));
      Serial.print('\n');
    }
  2. Open the Arduino IDE 2.x Serial Plotter.
  3. Select "9600 baud" from the dropdown baud rate menu at the bottom right corner of the "Serial Plotter" window.
    😢 the data are not plotted.
    image
  4. Close the Arduino IDE 2.x Serial Plotter.
  5. Open the classic Arduino IDE Serial Plotter.
  6. Select "9600 baud" from the dropdown baud rate menu at the bottom left corner of the "Serial Plotter" window.
    🙂 the data are plotted.
    image

Describe the request

Support LF in addition to CRLF line breaks in data sent to Serial Plotter.

Desktop

  • OS: Windows 10
  • Arduino IDE Version: 2.0.0-rc3-snapshot.35e5da5
    Date: 2022-01-13T17:15:54.562Z
    CLI Version: 0.20.2 [13783819]

Additional context

In addition to providing compatibility with the original protocol, there are several other reasons for supporting LF line breaks:

  • "New Line" is the default line ending setting in the Arduino IDE Serial Monitor and Serial Plotter.
  • A single character line break is more efficient, which can be an important consideration for resource constrained microcontrollers.
  • Users may find LF line endings most intuitive since this is the standard line ending on both Linux and macOS, and even increasingly prevalent in code applications on Windows.
@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Jan 19, 2022
@nmzaheer
Copy link
Contributor

nmzaheer commented Sep 3, 2022

I think the separator in the classic Serial Plotter code is given as
int linebreak = messageBuffer.indexOf("\n"); Link

whereas in the Serial Plotter webapp is given as
const separator = "\r\n"; Link

This makes it clear that the webapp is handling it differently from the classic Serial Plotter.

Can a PR be submitted changing this? or am I missing something?

@per1234 per1234 added priority: high Resolution is a high priority criticality: high Of high impact labels Sep 3, 2022
@per1234
Copy link
Contributor Author

per1234 commented Sep 3, 2022

Hi @nmzaheer. Yes, please do submit a pull request. I'll be happy to review and merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved criticality: high Of high impact priority: high Resolution is a high priority topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants