Order of HLA data items/columns in analyzer output

Hi,
I’ve just written my first “HLA” (based on the RFM69 example – thanks to Alex M.!!) for decoding SPI protocol to one of our ASICs, works really great!!

the AnalyzerFrame output has 3 items “rw”, “reg” and “value” which I’d like to see in this order in the analzyer output and the exported data files.
but by default the seem to get sorted alphabetically and do not show up in the order of the data={} set.
how can I explicitly force the order of those data columns to what I’d like to expect ?

right now I use “1rw” “2reg” and “3value” – which is ugly but seems to work:

    result_types = {
        "r":       {"format": "{{data.1rw}} {{data.2reg}} {{data.3value}}"},
        "w":       {"format": "{{data.1rw}} {{data.2reg}} {{data.3value}}"},
    }

            return AnalyzerFrame(
                self._rw[0],
                start_time=frame.start_time,
                end_time=frame.end_time,
                data={
                    "1rw": self._rw,
                    "2reg": get_reg_name(self._address),
                    "3value": f"0x{self._val:04X}",
                },
            )

is there a better way without using numeric prefixes in the keys for sorting of those data elements ?

thanks,
Harald

@harald.koenig2 Sorry about that. I wanted to ask a follow up question from your statement below:

the AnalyzerFrame output has 3 items “rw”, “reg” and “value” which I’d like to see in this order in the analzyer output and the exported data files.

The order of the items in the analyzer bubble can be re-ordered via the entries here. I created a copy of the RFM69 Decoder as per the image below while changing the order of the entries in the decoded bubble.

    result_types = {
        "address": {"format": "{{data.reg}} {{data.rw}}"},
        "read": {"format": "{{data.value}} {{data.rw}} {{data.reg}}"},
        "write": {"format": "{{data.value}} {{data.rw}} {{data.reg}}"},
    }

As for the data table, the column headers are unfortunately locked to alphabetical order as far as I know, but I can double check with the team here to see if there is a workaround.

You’re right, at the moment we don’t offer any way to control that. We actually tried briefly to support re-ordering the columns in the UI but postponed it, that might be a reasonable solution if we also use that order for export.

In the meantime, you might try an experiment.

For the very first input frame to your HLA, try producing 4 frames instead of just one. Then on every other input frame proceed normally.

My theory is that the order of the columns depends on when the column is first seen, but all keys present in a single data frame will be sorted alphabetically.

This is a shorthand pseudocode, but something like this might work:

if first_frame:
  return [
  AnalyzerFrame(..., data={'rw':...}),
  AnalyzerFrame(..., data={'reg':...}),
  AnalyzerFrame(..., data={'value':...}),
  AnalyzerFrame(..., data={'rw': ..., 'reg': ..., 'value':...}),
  ]

This will pollute the first 3 rows of the table, but, it might get the order you want. I don’t recall exactly how the columns get inserted, or if they are always sorted.

This is the exact sort of thing we would like to solve by adding optional schema to HLAs.

For example, you might want to specify how many bits are in a given integer, you might want to specify if the number is unsigned or not, you might want to customize the column label, and in this case, it would be great to specify the order.

1 Like