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

Add hh (byte) format for printf and scanf #6896

Merged
merged 3 commits into from
Dec 10, 2019
Merged

Conversation

earlephilhower
Copy link
Collaborator

@earlephilhower earlephilhower commented Dec 10, 2019

Fixes #4660

Add in support for byte-wide scanf and printf (%hh..) in printf and
scanf. Allows reading into a byte array one byte at a time.

Simple test:

void setup() {
  Serial.begin(115200);
  Serial.printf("%hhx\n", 123+256);
  char b[4];
  int i=999;
  int r= sscanf("1 2 3 4 5", "%hhd %hhd %hhd %hhd %d", b,b+1,b+2,b+3, &i);
  Serial.printf("r=%d  %d %d %d %d %d\n", r, b[0], b[1], b[2], b[3], i);
}

void loop() {
}

Gives expected output

7b
r=5  1 2 3 4 5

earlephilhower and others added 3 commits December 9, 2019 21:03
Fixes esp8266#4660

Add in support for byte-wide scanf and printf (%hh..) in printf and
scanf.  Allows reading into a byte array one byte at a time.
@d-a-v d-a-v merged commit d012adc into esp8266:master Dec 10, 2019
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.

scanf / printf : Enabling 8-bit types
2 participants