- for (int j = 0; j < n; j += 8) {
- PrintAndLog("%02x %02x %02x %02x %02x %02x %02x %02x",
- sample_buf[j+0],
- sample_buf[j+1],
- sample_buf[j+2],
- sample_buf[j+3],
- sample_buf[j+4],
- sample_buf[j+5],
- sample_buf[j+6],
- sample_buf[j+7]
- );
- delivered += 8;
- if (delivered >= requested)
- break;
+ i = 0;
+ for (j = 0; j < requested; j++) {
+ i++;
+ string_ptr += sprintf(string_ptr, "%02x ", got[j]);
+ if (i == 8) {
+ *(string_ptr - 1) = '\0'; // remove the trailing space
+ PrintAndLog("%s", string_buf);
+ string_buf[0] = '\0';
+ string_ptr = string_buf;
+ i = 0;
+ }
+ if (j == requested - 1 && string_buf[0] != '\0') { // print any remaining bytes
+ *(string_ptr - 1) = '\0';
+ PrintAndLog("%s", string_buf);
+ string_buf[0] = '\0';
+ }