# Is there any way to store data in the MLA between frames?

**URL:** <https://discuss.saleae.com/t/is-there-any-way-to-store-data-in-the-mla-between-frames/1382>\
**Category:** Extensions\
**Created:** [January 23, 2022, 8:41pm UTC](https://discuss.saleae.com/t/is-there-any-way-to-store-data-in-the-mla-between-frames/1382 "2022-01-23T20:41:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukebchrd](https://avatars.discourse-cdn.com/v4/letter/l/a87d85/32.png) [@lukebchrd](https://discuss.saleae.com/u/lukebchrd)\
**Post date:** [January 23, 2022, 8:41pm UTC](https://discuss.saleae.com/t/is-there-any-way-to-store-data-in-the-mla-between-frames/1382/1 "2022-01-23T20:41:23Z")

</div>

Is there any way to store data in the MLA between frames?

I’d like to be able to treat the first data byte of an I2C bus specially, and I do not mean the address byte. I use the first data byte to specify the context of later bytes and would like to use a lookup table to define what should be displayed instead of the numerical data itself. My first thought was to just use a bool and change it after it is first accessed, then set it again on the next address frame, but this variable seems to just get deleted after each frame.

```auto
# High Level Analyzer
# For more information and documentation, please go to https://support.saleae.com/extensions/high-level-analyzer-extensions

from saleae.analyzers import HighLevelAnalyzer, AnalyzerFrame, StringSetting, NumberSetting, ChoicesSetting

# High level analyzers must subclass the HighLevelAnalyzer class.
class Hla(HighLevelAnalyzer):
    
    START = 0
    # An optional list of types this analyzer produces, providing a way to customize the way frames are displayed in Logic 2.
    result_types = {
        'i2c-address': {
            'format': '{{data.description}}'
        },
        'i2c-data': {
            'format': '{{data.description}}'
        }
    }

    

    def __init__ (self):
        pass

    def decode(self, frame: AnalyzerFrame):
        if frame.type == 'address':
            direction = 'Read' if frame.data['read'] else 'Write'
            address = (frame.data['address'][0] << 1) | (1 if frame.data['read'] else 0)
            ack = frame.data['ack']
            START = 1
            return AnalyzerFrame('i2c-address', frame.start_time, frame.end_time, {
                'description': 'Setup {} to {} + {}'.format(direction, 'ALL' if (address == 0) else address, 'ACK' if ack else 'NAK')
            })
        elif frame.type == 'data':
            data = frame.data['data'][0]
            ack = frame.data['ack']
            if START:
                START = 0
                if data == 126:
                    DataText = 'ADDR CHANGE'
                elif data == 5:
                    DataText = 'G1'
                elif data == 9:
                    DataText = 'G6'
                elif data == 4:
                    DataText = 'G92'
                elif data == 6:
                    DataText = 'M202'
                elif data == 8:
                    DataText = 'M204'
                elif data == 7:
                    DataText = 'M205'
                return AnalyzerFrame('i2c-data', frame.start_time, frame.end_time, {'description': '{} + {}'.format(DataText, 'ACK' if ack else 'NAK')})
            else:
                return AnalyzerFrame('i2c-data', frame.start_time, frame.end_time, {'description': '0x{:02X} + {}'.format(data, 'ACK' if ack else 'NAK')})

```

---

<div class="post-metadata">

**Author:** ![P.Jaquiery](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.saleae.com/p.jaquiery/32/289_2.png) [@P.Jaquiery](https://discuss.saleae.com/u/P.Jaquiery)\
**Post date:** [January 24, 2022, 8:15pm UTC](https://discuss.saleae.com/t/is-there-any-way-to-store-data-in-the-mla-between-frames/1382/2 "2022-01-24T20:15:56Z")

</div>

> [@lukebchrd](#):
>
> ```auto
> def __init__ (self):
> pass
> 
> ```

Use your class ` __init__ ` to set up member variables. I set up result\_types as you have done, but I’d make START a member variable and set it initially in ` __init__ ` with

```auto
    self.start = 0

```

then where you use it in your member functions (`decode(self, ...)` for example) use it the the same way (`self.start`).
