Per bytes error highlighting
authorJean THOMAS <git0@pub.jeanthomas.me>
Mon, 13 Jul 2020 13:20:49 +0000 (15:20 +0200)
committerJean THOMAS <git0@pub.jeanthomas.me>
Mon, 13 Jul 2020 13:20:49 +0000 (15:20 +0200)
examples/headless/main.c

index 0646f3b6ddfc2afe985c01c162834830e6796676..06b4ae339fd0d7944d7658bac27cce5012909b06 100644 (file)
@@ -133,10 +133,13 @@ int main(int argc, char *argv[]) {
 
                read_value = gram_read(&ctx, &(ddr[i]));
                expected_value = 0x12345678 + (1 << 10*i)%0x100000000;
-               if (read_value != expected_value) {
-                       printf("\033[0;31m%08x\033[0m", read_value);
-               } else {
-                       printf("\033[0;32m%08x\033[0m", read_value);
+
+               for (int j = 3; j >= 0; j--) {
+                       if (((uint8_t*)(&read_value))[j] != ((uint8_t*)(&expected_value))[j]) {
+                               printf("\033[0;31m%02x\033[0m", ((uint8_t*)(&read_value))[j]);
+                       } else {
+                               printf("\033[0;32m%02x\033[0m", ((uint8_t*)(&read_value))[j]);
+                       }
                }
                
                if ((i % kDumpWidth) == kDumpWidth-1) {