Skip to content

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