miguelbalboa / rfid

Arduino RFID Library for MFRC522
The Unlicense
2.73k stars 1.42k forks source link

printDec() helper function cut and paste error #584

Closed bhelterline closed 2 years ago

bhelterline commented 2 years ago

Step 1: Describe your environment

Step 2: Describe the problem

The helper function printDec() in the NUID.ino example file has a cut and paste error from the HEX version. You don't want a leading zero if the value is above 0x10. /**

Affected file(s) or example(s):

Steps to reproduce:




Observed Results:

if the uid happens to be 9, 15, 16, 240, you get the output " 09 015 16 240"

Expected Results:

I would expect a 3 digit value for each byte 000 to 255 or at least consistent leading white space " 009 015 016 240" or " 9 15 16 240"

Relevant Code:

 * Helper routine to dump a byte array as dec values to Serial.
 */
void printDec(byte *buffer, byte bufferSize) {
  for (byte i = 0; i < bufferSize; i++) {
    Serial.print(buffer[i] < 0x10 ? " 0" : " ");
    Serial.print(buffer[i], DEC);
  }
}
Rotzbua commented 2 years ago

@bhelterline Will you create a pull request?

bhelterline commented 2 years ago

done!