Hello Bartosz,
The script for a filter to do what you want is very simple. First, you deduce the state of the CS line (from the I2cSpiTapLogRecordCode.SpiStart and SpiStop
log records); then, you use this state to either hide or show the MOSI/MISO data (the log.StdRecordCode.TxRx
log records).
The source code for such a filter might look something like this:
import "doc_Layer.jnc"
import "I2cSpiTap/I2cSpiTapLogRecordCode.jnc"
class SpiCsFilterLayer:
doc.Layer,
log.Filter
{
protected:
ui.EnumProperty* m_csFilterProp; // a property to choose the filtering strategy
int m_cs; // the state of the CS line
public:
construct(doc.PluginHost* pluginHost);
override bool filter(
uint64_t timestamp,
uint64_t recordCode,
void const* p,
size_t size
);
}
SpiCsFilterLayer.construct(doc.PluginHost* pluginHost)
{
basetype.construct(pluginHost);
ui.EnumPropertyOption csFilterOptions[] = {
{ "Show always", -1 },
{ "Show when CS low", 0 },
{ "Show when CS high", 1 },
}
m_csFilterProp = m_pluginHost.m_propertyGrid.createEnumProperty(
"MOSI/MISO filter",
"Show MOSI/MISO filtering criteria",
csFilterOptions,
countof(csFilterOptions)
);
m_cs = -1; // -1 means unknown
pluginHost.m_log.addFilter(this);
}
bool SpiCsFilterLayer.filter(
uint64_t timestamp,
uint64_t recordCode,
void const* p,
size_t size
)
{
bool isVisible = true;
switch (recordCode)
{
case log.StdRecordCode.SessionStarted:
m_cs = -1; // reset to unknown
break;
case I2cSpiTapLogRecordCode.SpiStart:
m_cs = 0;
break;
case I2cSpiTapLogRecordCode.SpiStop:
m_cs = 1;
break;
case log.StdRecordCode.TxRx:
isVisible =
m_csFilterProp.m_value == -1 || // show always
m_csFilterProp.m_value == m_cs; // matches the current state of CS
break;
}
return isVisible;
}
An archive with the complete filter plugin is attached (SpiCsFilter.7z)
Usage:
- Start I2C/SPI session
- Open the
SpiCsFilter.njplg
file to attach this filter
- Go to "Settings"
- Select the appropriate filtering criteria
- Hit "Apply and rebuild log" to apply the filter to the whole log (clicking "Apply" or "OK" will apply the filter "from now on" (i.e., to the follow-up log records only)