Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can USBHost::print_hexbytes() be moved under public to be used as a debug print? #83

Open
liudr opened this issue Mar 8, 2022 · 1 comment

Comments

@liudr
Copy link

liudr commented Mar 8, 2022

#ifdef USBHOST_PRINT_DEBUG

Suggest redefining USBHost::print_hexbytes() as USBHost::prn_hex() and just #define print_hexbytes() either as prn_hex() or as nothing. This way we can use the static function USBHost::prn_hex() to do hex dump while all the debug print lines in the existing code are still controlled by USBHOST_PRINT_DEBUG.

@KurtE
Copy link
Contributor

KurtE commented Mar 20, 2022

Note: @PaulStoffregen has the final say on some of these api changes...

But I don't think you want to blindly make the hex debug code built in there dump all of the time without that define, unless we instead have the dump code maybe public an the current hex dump dump call, only call it when in that state, otherwise we will suddenly have a lot more debug printing when we are not configured for debug...

Just an FYI, there are lots of hex dump functions, out there, but I have one that I hacked up that I use for debugging.
https://github.com/KurtE/MemoryHexDump

Nothing very special, but does have hacks in it that if it finds lots of rows would be duplicated, it can optionally remove those lines.

Example from sketch I am playing with now:

...
 memset(buffer, 0, sizeof(buffer));
    const InfoToParseDXLPacket_t* pinfo_parse = dxl.rxStatusPacket(buffer, sizeof(buffer), 250);
    if (pinfo_parse) {
      DEBUG_SERIAL.printf("FastSyncRead time %u\n", micros() - start_time);
      
      DEBUG_SERIAL.printf("InfoToParse: id:%u prot:%u err:%u Packet len:%u param len:%u\n", pinfo_parse->id,
        pinfo_parse->protocol_ver, pinfo_parse->err_idx, pinfo_parse->packet_len, pinfo_parse->recv_param_len);
      MemoryHexDump(DEBUG_SERIAL, buffer, sizeof(buffer), true);
...

Output:

=======================================================
Try Fast SyncRead
FastSyncRead time 1909
InfoToParse: id:254 prot:2 err:0 Packet len:49 param len:45
20004DE0 - 13 03 08 00 00 97 B4 00  03 06 08 00 00 DD E9 00  : ........ ........
20004DF0 - 05 01 08 00 00 C9 E2 00  02 02 08 00 00 16 B1 00  : ........ ........
20004E00 - 04 FA 07 00 00 39 17 00  06 FC 07 00 00 00 00 00  : .....9.. ........
20004E10 - 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  : ........ ........
...	 27 duplicate line(s) removed.
20004FD0 - 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  : ........ ........

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

No branches or pull requests

2 participants