Team Walter / Mbed OS NonPingPong_PICO_LoRa

Dependencies:   SX1276GenericLib USBDevice

Fork of NonPingPong_PICO_LoRa by Walter Luu

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers utils.cpp Source File

utils.cpp

00001 void dump(const char *title, const void *data, int len, bool dwords)
00002 {
00003 //    dprintf("dump(\"%s\", 0x%x, %d bytes)", title, data, len);
00004 //    pc.printf("dump(\"%s\", 0x%x, %d bytes)", title, data, len);
00005 
00006     int i, j, cnt;
00007     unsigned char *u;
00008     const int width = 16;
00009     const int seppos = 7;
00010 
00011     cnt = 0;
00012     u = (unsigned char *)data;
00013     while (len > 0) {
00014 //        rprintf("%08x: ", (unsigned int)data + cnt);
00015 //        pc.printf("%08x: ", (unsigned int)data + cnt);          //comment out
00016         if (dwords) {
00017             unsigned int *ip = ( unsigned int *)u;
00018 //            rprintf(" 0x%08x\r\n", *ip);
00019 //            pc.printf(" 0x%08x\r\n", *ip);                         //comment out
00020             u+= 4;
00021             len -= 4;
00022             cnt += 4;
00023             continue;
00024         }
00025         cnt += width;
00026         j = len < width ? len : width;
00027         for (i = 0; i < j; i++) {
00028 //            rprintf("%2.2x ", *(u + i));
00029 //            pc.printf("%2.2x ", *(u + i));           //comment out
00030 //            if (i == seppos)
00031 //                rprintf(" ");
00032 //                pc.printf(" ");                        //comment out
00033         }
00034 //        rprintf(" ");
00035 //        pc.printf(" ");                                 //comment out
00036         if (j < width) {
00037             i = width - j;
00038 //            if (i > seppos + 1)
00039 //                rprintf(" ");
00040 //                pc.printf(" ");                           //comment out
00041             while (i--) {
00042 //                rprintf("%s", "   ");
00043 //                pc.printf("%s", "   ");                      //comment out
00044             }
00045         }
00046         for (i = 0; i < j; i++) {
00047             int c = *(u + i);
00048 //            if (c >= ' ' && c <= '~')
00049 //                rprintf("%c", c);
00050 //                pc.printf("%c", c);                              //comment out
00051 //            else
00052 //                rprintf(".");
00053 //                pc.printf(".");                              //comment out
00054 //            if (i == seppos)
00055 //                rprintf(" ");
00056 //                pc.printf(" ");                                 //comment out             
00057         }
00058         len -= width;
00059         u += width;
00060 //        rprintf("\r\n");
00061 //        pc.printf("\r\n");                                       //comment out
00062     }
00063 //    rprintf("--\r\n");
00064 //    pc.printf("--\r\n");                                         //comment out
00065 }