Added some flags to hex storage command

Hi, today I’ve added some flags to the hex storage command: -d to show address offset, -a to dump in ascii and -s to set the line size (i.e. 8 or 16, etc)

If this could be useful I can send a pull request.
PS: also yesterday I sent a micro-pull request to fix a small typo in the hex dump (it was dumping in decimal instead of hex)

Sorry, I forgot that github adds same branch commits to an existing pull request, so the yesterday small pull request has been updated to include also the new code shown here. Sorry for the noise. Ignore the pull request or cherry pick only the needed parts :slight_smile:

This is awesome!

I’ll accept your requests. I’m sorry, I no longer have access to the email for our github so I don’t see notifications (it’s a long story involving national firewalls and load bearing laptops).

I did not yet update the help and translations because I didn’t know if you prefer do it yourself or if I can do it directly. If you want I can update the help and English strings and put them in the same pull request.

I would appreciate any help! Feel like I’m drowning at the moment :slight_smile: For the translations: you just alter the us-en.h, then run the json2h.py script and it will update all the translations and the main header file. I’m realizing now this isn’t in the docs yet, I’ll add it.

I’ll update as soon as i can.
PS: Thanks for all the incredible work you are putting into this project

I added some info on adding translation strings to the docs.

Flags and translation stings added, see pull req #18

Thank you much. Merged.

I was thinking about adding pagenation and x to exit to the HEX viewer. I sometimes need to check a very long file and it’s unpleasant being stuck through a 8mb dump.

Do you have any thoughts or other suggestions?

1 Like

I could move the hex dump code from disk_hex_handler into its own function and add two new parameters: start dump offset and dump bytes len.
I can also return true if there are more data, and false if EOF.

The disk_hex_handler should be modified to repeatedly call the new hex_dump function until there are new data available.

Something like this:

bool hex_dump(uint32_t offset, uint32_t size, uint8_t row_size, uint8_t flags)
{ ... }

void disk_hex_handler(struct command_result *res){
    // CURRENT CODE
    // ...
    uint8_t lines_per_page = GET_LINES_PER_PAGE();
    uint8_t size = lines_per_page * row_size;
    while (true) {
        if (!hex_dump(off, size, row_size, flags)
            break;
        KEY = WAIT_FOR_KEY_PRESSED();
        if (KEY == KEY_EXIT)
             break;
    }
}

2 Likes

I think that’s really nice. I currently have several different “any key to continue, x to exit” functions floating around, i will consolidate that into something more universal.