Skip to content
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

Label header not working #14

Open
3 tasks done
per1234 opened this issue Sep 5, 2022 · 2 comments
Open
3 tasks done

Label header not working #14

per1234 opened this issue Sep 5, 2022 · 2 comments
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Sep 5, 2022

Describe the problem

The official Arduino Serial Plotter protocol specification documents two formats for labeling variables:

  • labeled data points (<label>:<value>)
  • header

🐛 Labels defined via a data set header are not recognized.

To reproduce

Equipment

  • Arduino board
    You can also send the equivalent data directly to the web app if that is more convenient to you.

Steps

  1. Upload the following sketch to your Arduino board:
    void setup() {
      Serial.begin(9600);
      while (!Serial) {}
      Serial.println("label0:\tlabel1:\tlabel2:");
    }
    void loop() {
      for (byte value = 0; value < 4; value++) {
        for (byte variableOffset = 0; variableOffset < 3; variableOffset++) {
          Serial.print(value + variableOffset);
          Serial.print('\t');
        }
        Serial.println();
      }
      delay(100);
    }
  2. Open "Serial Plotter"
  3. Select "9600 baud" from the dropdown baud rate menu at the bottom right corner of the "Serial Plotter" window.

🐛 The variables are not labeled:

image

Expected behavior

Support for label headers.

serial-plotter-label-header

OR

  • Clear documentation of breaking change
  • Comprehensive survey and repair of all important content broken by change

Version

eac6d39

Operating system

Windows

Operating system version

10

Additional context

The demo works as expected when using the Arduino IDE 1.8.19 Serial Plotter.


Examples of existing programs broken by this bug:


A label header is more efficient than printing labels redundantly for each data point.

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
@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Sep 5, 2022
@nmzaheer
Copy link
Contributor

nmzaheer commented Sep 7, 2022

I've been thinking about providing support for Label only message format. However, the following code snippet discards the first message sent to the plotter

// when the serial is real fast, the first line can be incomplete and contain incomplete messages
// so we need to discard it and start aggregating from the first encountered separator
let joinMessages = messages.join("");
if (discardFirstLine) {
const firstSeparatorIndex = joinMessages.indexOf(separator);
if (firstSeparatorIndex > -1) {
joinMessages = joinMessages.substring(
firstSeparatorIndex + separator.length
);

This code was introduced in PR #5 to cater for

when the plotter toggles between pause and unpaused, "dirty" messages can be received, which cannot be parsed correctly. for this reason is safer to discard such messages and wait for the first clean one

For the OP's example code, it would completely discard the labels that are being sent during setup(). This would prevent us from supporting Label only messages as specified in the SerialPlotter protocol.


Questions

  • What does "dirty" messages actually mean? Does it mean garbage characters in the message? or does it mean receiving partial messages i.e., getting only 3 values while 4 values were to be received? Is there any reproducible condition for generating such "dirty" messages?
  • Do we separate them into two scenarios in such a way that
    • First message during startup on the Plotter Window - Allowed
    • First message when plotting resumes - Disallowed
  • The legacy SerialPlotter does not discard the first message SerialPlotter.java . So, is this a scenario that was introduced in the new version or can we treat the messages the same way as being done in the legacy version?

@per1234
Copy link
Contributor Author

per1234 commented Sep 8, 2022

Unfortunately I don't know any details about why this is necessary.

is this a scenario that was introduced in the new version

There are definitely some regressions in the serial data handling of Arduino IDE 2.x compared to Arduino IDE 1.x

For example:
arduino/arduino-ide#927

I believe the "□" you see in that screenshot are not really characters, but instead the .notdef glyph used as a placeholder for Unicode characters that cannot be rendered by the font of Serial Monitor. So I'm not sure what the effect would be on the labels if the header started with an arbitrary number of these characters. But this bug is specific to Arduino IDE 2.x


I'll try to make some time later this week to do a bit of investigation into the subject to see if I can produce something that might match the description of this "dirty" message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

2 participants