HLA result_types format template string

Hi!

Is there public documentation about the template strings and how they work/ what they allow?

I’ve used

'format': '0x{{data.mosi}} / 0x{{data.miso}}'

for my HLA which takes in SPI - Frame Format - Frame Type: “result”.

The type of both properties mosi and miso is bytes. However, my bit width is the typical 8 bits. So there’s usually only a single byte to be displayed.

So for an input of 0xA0 and 0x00 I get “0x[A0] / 0x[00]”.

How can I access the first byte only? I tried by putting {{data.miso[0]}} there but that gives a template error.

Or simply put: how do I get rid of the square brackets?

I still wonder this myself, having struggled with a different issue (since fixed) with HLA formatting:

I’m still guessing that it’s Handlebars JS template engine (or a compatible/similar syntax), which internally formats the HLA python data for GUI display. I understand the Logic 2 program itself is based on the Electron framework – which uses the chromium display engine for the GUI (typically implemented using Node.js and other JavaScript).

Meanwhile, if you want more control of the display text, you might try converting python type from bytes to a more compatible data type in the HLA python code before returning the value vs. directly returning a bytes typed object (which isn’t as cleanly passed between python and JavaScript)?

Finally, perhaps Saleae could confirm what specific syntax the HLA format string is using?

Thank you for the background information and your presumptions on the internals.

As a temporary solution, I can shift the problem to the data generation side, i.e. where the AnalyzerFrames are emitted:

                    return AnalyzerFrame('result', frame.start_time, frame.end_time, {
                        'mosi': frame.data['mosi'][0], 'miso': frame.data['miso'][0]
                    })

However, this will display single digit HEX numbers as such and not in :02X format. I can either deal with it or need to emit the formatted strings directly (for now), I guess.

And

                return AnalyzerFrame('result', frame.start_time, frame.end_time, {
                    'mosi': f"{frame.data['mosi'][0]:02X}", 'miso': f"{frame.data['miso'][0]:02X}"
                })

works for me.

Stacking HLAs is currently not supported, I guess. So it probably really does not matter for now. Just thinking about export and post-processing.. but there’s probably also everything just a text string.

Still interested in template details, though. :wink: