Returning with an array of frames in the HLA decode?

By working on a python HLA protocol analyzer I hit one limitation which lead me asking for here frist before trying to workaround: would it be possible to modify the HLA API to being able to return with an array of frames from the decode not just a simple frame.

There are some badly designed protocols in the wild where some parts of a packet (what is practically to represent as a separate frame in the analyzer) only can be decided at the end of the packet processing.

What do you think about this?

That’s already possible in 2.2.11. You can either return a dict to represent one frame, None to represent no data, or a list of dicts to represent multiple frames.

1 Like

@jonathan.gjertsen many thanks for your reply! That’s great, in this case just the documentation needs some upgrade.

1 Like

Which documentation are you referring to? https://github.com/saleae/logic2-extensions says

def decode(self, data) : is called once for every frame passed to the HLA from the attached analyzer. It can return nothing, a single frame, or an array of frames.

2 Likes

Ah, sorry my bad.

That’s great, in this case just the documentation needs some upgrade

We’ll update the inline documentation as well

Hmm, I’m trying to take advantage of the multiple frames to nicely organize my HLA by returning 1 frame each for MOSI and MISO sides of my SPI transactions in decode().

def decode(self, frame: AnalyzerFrame):
    '''
    Process a frame from the input analyzer, and optionally return a single `AnalyzerFrame` or a list of `AnalyzerFrame`s.

    The type and data values in `frame` will depend on the input analyzer.
    '''
    if frame.type == 'enable':
        self.log('Trace', 'CS_L enabled at {0}'.format(frame.start_time))

        self.mosi_data.reset()
        self.miso_data.reset()

        self.mosi_data.set_time(True, frame.start_time)
        self.miso_data.set_time(True, frame.start_time)

    elif frame.type == 'result':
        self.log('Trace', 'Result frame: {0}'.format(frame.data))
        self.mosi_data.add_raw_bytes(list(frame.data['mosi']))
        self.miso_data.add_raw_bytes(list(frame.data['miso']))

    elif frame.type == 'error':
        self.log('Error', 'Clock in wrong state when CS_L enabled')

    elif frame.type == 'disable':
        self.log('Trace', 'CS_L disabled at {0}'.format(frame.end_time))

        self.mosi_data.set_time(False, frame.end_time)
        self.miso_data.set_time(False, frame.end_time)

        frames = []

        if self.mosi_data.parse():
            self.log('Debug', 'SPI MOSI frame @ {0}\n\t{1}'.format(self.mosi_data.get_time_string(True), self.mosi_data.to_string()))
            frames.append(AnalyzerFrame(SPIFrame', self.mosi_data.start_time, self.mosi_data.end_time,  { 'type': 'MOSI', 'time': self.mosi_data.get_time_string(True), 'data': self.mosi_data.to_string() }))
        else:
            self.log('Debug', 'Unknown MOSI frame @ {0}\n\t{1}'.format(self.mosi_data.get_time_string(True), self.mosi_data.raw_bytes_to_string(self.mosi_data.raw_bytes)))
            frames.append(AnalyzerFrame('Unknown', self.mosi_data.start_time, self.mosi_data.end_time, { 'time': self.mosi_data.get_time_string(True) }))

        if self.miso_data.parse():
            self.log('Debug', 'SPI MISO frame @ {0}\n\t{1}'.format(self.miso_data.get_time_string(True), self.miso_data.to_string()))
            frames.append(AnalyzerFrame('SPIFrame', self.miso_data.start_time, self.miso_data.end_time,  { 'type': 'MISO', 'time': self.miso_data.get_time_string(True), 'data': self.miso_data.to_string() }))
        else:
            self.log('Debug', 'Unknown MISO frame @ {0}\n\t{1}'.format(self.miso_data.get_time_string(True), self.miso_data.raw_bytes_to_string(self.miso_data.raw_bytes)))
            frames.append(AnalyzerFrame('Unknown', self.miso_data.start_time, self.miso_data.end_time, { 'time': self.miso_data.get_time_string(True) }))

        return frames

The HLA runs great in Logic2 v2.3.1 and I get no errors or warnings, but I only see bubbles for MISO, the 2nd item in the list I returned in decode(), in the analyzer line of the capture. Am I doing something wrong or are there some UI constraints I may be encountering?

I’m able to workaround this by creating a single “super frame” that contains data for both MOSI and MISO, but it would be nicer to see 2 frames instead (1 stacked vertically above the other would be great, so I don’t lose valuable horizontal space when displaying multiple!)

Thanks for all the hard work you guys are putting into this software! It’s already light years better than Logic1 (in my opinion)! Keep up the good work!

1 Like

We currently don’t support multiple frame outputs for the same time frame, it’s on our roadmap!
You can create a single “super frame” or 2 identical HLAs, and in the settings define if you want the MISO or the MOSI. Not very elegant though…

Thanks for all the hard work you guys are putting into this software! It’s already light years better than Logic1

Thanks! :slight_smile:

Thanks @rani, 2 HLAs is actually a pretty nice idea as it would line up nicely with the raw SPI data and make the HLA implementation less complex.

1 Like