Skip to content

Migrate Stream search internals from char to uint8_t#274

Open
asumo-1xts wants to merge 3 commits into
arduino:masterfrom
asumo-1xts:issue#119
Open

Migrate Stream search internals from char to uint8_t#274
asumo-1xts wants to merge 3 commits into
arduino:masterfrom
asumo-1xts:issue#119

Conversation

@asumo-1xts

@asumo-1xts asumo-1xts commented Jun 7, 2026

Copy link
Copy Markdown

(I'm still new to contributing to OSS, so please let me know if there's anything I need to correct!)

Overview

This PR is regarding issue #119.

In the current code, Stream::find() cannot find values above 0x7f because it treats the target string as char.
This PR fixes the issue by changing the target string type from char to uint8_t.

Verification on an actual device

I confirmed with an Arduino UNO R3 clone that the sketch below does not blink the built-in LED with the current code, but it does blink with the fixed code.

Note

It performs serial communication from its own TX to its own RX.
Please make sure to connect the TX and RX pins after uploading the sketch.

Note

To build the sketch correctly, you may need to rewrite the header-include in Stream.cpp:
Common.h -> Arduino.h

// It performs serial communication from its own TX to its own RX.
// Please make sure to connect the TX and RX pins after uploading the sketch.

#include <Arduino.h>

const uint8_t TEST_NUMBER = 0x80; // above 0x7f

void setup() {
  Serial.begin(115200);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  Serial.write(TEST_NUMBER);
  delay(1000);

  if (Serial.available()) {
    if (Serial.find(TEST_NUMBER)) {
      digitalWrite(LED_BUILTIN, HIGH);
      delay(500);
      digitalWrite(LED_BUILTIN, LOW);
      delay(500);
    }
  }
}

@CLAassistant

CLAassistant commented Jun 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@per1234 per1234 linked an issue Jun 8, 2026 that may be closed by this pull request
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

Successfully merging this pull request may close these issues.

Stream::find() not working for values above 0x7F

2 participants