Skip to content

Serial Plotter recovery from overload state #695

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 Dec 16, 2021 · 1 comment
Closed

Serial Plotter recovery from overload state #695

per1234 opened this issue Dec 16, 2021 · 1 comment
Assignees
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@per1234
Copy link
Contributor

per1234 commented Dec 16, 2021

Describe the current behavior

The Arduino IDE 2.x Serial Plotter has an undocumented maximum limit of 8 variables.

When this limit is exceeded, the plotter goes into an overload state (currently a blank window: #651).

The only way to recover from that overload state is to close and then reopen the Serial Plotter window.

To reproduce

  1. Upload a sketch that causes more than 8 variables to be plotted:
    byte variableCount = 9;
    void setup() {
      Serial.begin(9600);
    }
    void loop() {
      for (byte variableCounter = 0; variableCounter < variableCount; variableCounter++) {
        Serial.print(random(100));
        Serial.print('\t');
      }
      Serial.println();
      delay(500);
    }
  2. Select Tools > Serial Plotter from the Arduino IDE windows.
    Notice that the plotter goes into the overload state.
  3. Upload a sketch that causes 8 or less variables to be plotted:
    byte variableCount = 8;
    void setup() {
      Serial.begin(9600);
    }
    void loop() {
      for (byte variableCounter = 0; variableCounter < variableCount; variableCounter++) {
        Serial.print(random(100));
        Serial.print('\t');
      }
      Serial.println();
      delay(500);
    }
    🐛 Notice that the Serial Plotter remains in the overload state, despite the data no longer exceeding its limitations.
  4. Close the Serial Plotter window.
  5. Select Tools > Serial Plotter from the Arduino IDE windows.
    Notice that the plotter is now plotting the data as expected 🙂

Describe the request

Recover from the overloaded Serial Plotter state once the over limit data conditions no longer exist.

Desktop

  • OS: Windows 10
  • Version: 2.0.0-rc2-snapshot.8a3e9ea
    Date: 2021-12-14T17:05:02.907Z
    CLI Version: 0.20.2 [13783819]

Additional context

I chose to use the example of the user correcting the overload by uploading a new sketch that produces 8 or less plotted variables, since I think that would be the most common occurrence (and perhaps the easiest to recover from since the upload could be used as a trigger for a recovery attempt). However, it is also possible for the number of variables to drop below the limit at sketch run time.

That seems unlikely to occur in practice, but I have noticed that sometimes there are spurious extra plotted variables when the Serial Plotter starts, which I believe is caused either by parsing of the data starting in the middle of a set or else by the initial data being corrupted, as sometimes happens with serial data printed immediately on initialization.

If the number of legitimate variables is already close to the limit, these spurious variables might push the count over the limit, which would result in a confusing situation for the user. That would be mitigated by the ability to recover on the fly.

Here is a contrived demo of the variable count dropping below the limit at run time:

byte variableCount = 9;  // The first set will exceed the maximum count of 8 variables
void setup() {
  Serial.begin(9600);
  while (!Serial) {}
  delay(1000);  // Without a delay, sometimes SP/SM doesn't receive the first of the data
}
void loop() {
  for (byte variableCounter = 0; variableCounter < variableCount; variableCounter++) {
    Serial.print(random(100));
    Serial.print('\t');
  }
  Serial.println();
  delay(500);
  variableCount = 8;  // Subsequent sets will contain 8 variables
}
@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Dec 16, 2021
@per1234
Copy link
Contributor Author

per1234 commented Jan 12, 2022

Fixed by arduino/arduino-serial-plotter-webapp#5
This eliminates the issue entirely by plotting only up to the maximum number of variables, so there is never an overload state to recover from.
Even though that PR has not yet been merged, the fix there was already published to the npm registry and brought into Arduino IDE by #698

@per1234 per1234 closed this as completed Jan 12, 2022
@per1234 per1234 added the conclusion: resolved Issue was resolved label Jan 12, 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: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

2 participants