Protocol Decode¶
Serial protocol decoding (I2C, SPI, UART)
Protocol decode framework for analyzing digital communication protocols.
EventType
¶
Bases: Enum
Types of protocol events.
DecodedEvent
dataclass
¶
DecodedEvent(timestamp: float, event_type: EventType, data: Any, description: str, channel: str, valid: bool = True)
Represents a decoded protocol event.
Attributes:
| Name | Type | Description |
|---|---|---|
timestamp |
float
|
Event timestamp (seconds) |
event_type |
EventType
|
Type of event |
data |
Any
|
Event data (bytes, address, etc.) |
description |
str
|
Human-readable description |
channel |
str
|
Source channel(s) |
valid |
bool
|
Whether event is valid (no errors) |
ProtocolDecoder
¶
Bases: ABC
Abstract base class for protocol decoders.
All protocol decoders must inherit from this class and implement the decode() method.
Initialize protocol decoder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Decoder name |
required |
Source code in scpi_control/protocol_decode.py
decode
abstractmethod
¶
Decode protocol from waveforms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
waveforms
|
Dict[str, Any]
|
Dictionary of channel_name -> waveform_data |
required |
**params
|
Protocol-specific parameters |
{}
|
Returns:
| Type | Description |
|---|---|
List[DecodedEvent]
|
List of decoded events |
Source code in scpi_control/protocol_decode.py
get_required_channels
abstractmethod
¶
Get list of required channel names.
Returns:
| Type | Description |
|---|---|
List[str]
|
List of required channel names (e.g., ['SDA', 'SCL']) |
get_parameters
abstractmethod
¶
Get decoder parameters with default values.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary of parameter_name -> default_value |
clear_events
¶
export_events_csv
¶
Export events to CSV file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Output CSV filename |
required |
Source code in scpi_control/protocol_decode.py
get_event_summary
¶
Get summary of event counts by type.
Returns:
| Type | Description |
|---|---|
Dict[str, int]
|
Dictionary of event_type -> count |