Skip to content

Block Development Tools

Block development tools are loaded dynamically via enable_block_dev_mode(). They provide code generation, validation, protocol analysis, signal analysis, and OOT module export.

Mode Control

get_block_dev_mode

Check whether block development mode is enabled.

Returns: BlockDevModeStatus with enabled, tools_registered

enable_block_dev_mode

Enable block development tools. Registers ~15 tools and 5 prompt resources.

Returns: BlockDevModeStatus with list of registered tools

disable_block_dev_mode

Disable block development tools, removing them from the tool list.

Returns: BlockDevModeStatus


Block Generation

generate_sync_block

Generate a gr.sync_block from a natural language description. The 1:1 input-to-output ratio makes this the most common block type.

ParameterTypeRequiredDescription
namestringYesBlock name (e.g., "configurable_gain")
descriptionstringYesNatural language description of block behavior
input_signaturelistYesInput port specs: [{"dtype": "float", "vlen": 1}]
output_signaturelistYesOutput port specs
parameterslistNoConstructor params: [{"name": "gain", "dtype": "float", "default": 1.0}]
work_logicstringNoDescription of the work function logic

Returns: GeneratedBlockCode with source_code, is_valid, validation_errors

generate_basic_block

Generate a gr.basic_block with custom forecast() and general_work(). Use this when input/output rates differ in non-trivial ways.

ParameterTypeRequiredDescription
namestringYesBlock name
descriptionstringYesBlock behavior description
input_signaturelistYesInput port specs
output_signaturelistYesOutput port specs
parameterslistNoConstructor parameters
forecast_logicstringNoHow to predict input requirements
work_logicstringNoProcessing logic description

Returns: GeneratedBlockCode

generate_interp_block

Generate an interpolation block (gr.interp_block) that produces more output samples than input samples.

ParameterTypeRequiredDescription
namestringYesBlock name
descriptionstringYesBlock behavior description
interpolationintYesInterpolation factor
input_signaturelistYesInput port specs
output_signaturelistYesOutput port specs
parameterslistNoConstructor parameters

Returns: GeneratedBlockCode

generate_decim_block

Generate a decimation block (gr.decim_block) that produces fewer output samples than input samples.

ParameterTypeRequiredDescription
namestringYesBlock name
descriptionstringYesBlock behavior description
decimationintYesDecimation factor
input_signaturelistYesInput port specs
output_signaturelistYesOutput port specs
parameterslistNoConstructor parameters

Returns: GeneratedBlockCode


Validation

validate_block_code

Validate generated block code without execution. Checks syntax (ast.parse), required imports, class hierarchy, work() method signature, and I/O signature consistency.

ParameterTypeRequiredDescription
source_codestringYesPython source code to validate

Returns: ValidationResult with is_valid, errors, warnings

parse_block_prompt

Parse a natural language description into a structured block specification. Useful for multi-step workflows where you want to review the spec before generating code.

ParameterTypeRequiredDescription
promptstringYesNatural language block description

Returns: Structured block specification with inferred name, I/O, parameters


Block Testing

test_block_in_docker

Test a generated block in an isolated Docker container. Creates a test harness flowgraph with vector_source → block → vector_sink, runs it, and collects output.

ParameterTypeRequiredDescription
source_codestringYesBlock source code
test_inputlistNoInput samples (e.g., [1.0, 2.0, 3.0])
parametersdictNoConstructor args (e.g., {"gain": 2.0})
timeoutintNoMax execution time in seconds (default: 30)

Returns: DockerTestResult with success, output_data, errors, duration


Protocol Analysis

parse_protocol_spec

Parse a protocol description (natural language or structured) into a ProtocolModel. Identifies modulation scheme, framing, encoding, and relevant parameters.

ParameterTypeRequiredDescription
specstringYesProtocol description or specification

Returns: ProtocolModel with modulation, framing, encoding details

generate_decoder_chain

Generate a complete multi-block decoder pipeline from a protocol specification. Selects existing GNU Radio blocks where possible, generates custom blocks for gaps.

ParameterTypeRequiredDescription
protocolstringYesProtocol name or specification
sample_ratefloatNoTarget sample rate
center_freqfloatNoCenter frequency

Returns: DecoderPipelineModel with blocks, connections, and required OOT modules

get_missing_oot_modules

Identify which OOT modules are needed for a protocol but aren’t installed. Cross-references the protocol’s block requirements against the OOT catalog.

ParameterTypeRequiredDescription
protocolstringYesProtocol name

Returns: List of missing module names with install instructions


Signal Analysis

analyze_iq_file

Analyze a captured IQ file to determine signal characteristics. Performs FFT analysis, estimates bandwidth, detects signal presence, and estimates modulation parameters.

ParameterTypeRequiredDescription
file_pathstringYesPath to IQ capture file
sample_ratefloatYesSample rate of the capture
dtypestringNoData type (default: "complex64")

Returns: Analysis results including bandwidth, center frequency offset, SNR estimate


OOT Export

generate_grc_yaml

Generate a GRC block definition (.block.yml) file for a block. This is required for blocks to appear in GNU Radio Companion’s graphical editor.

ParameterTypeRequiredDescription
source_codestringYesBlock Python source code
block_namestringYesBlock name
module_namestringNoModule prefix (default: "custom")
inputslistNoInput port specs
outputslistNoOutput port specs
parameterslistNoBlock parameters with types and defaults
categorystringNoGRC palette category

Returns: GrcYamlResult with yaml_content, filename, block_id, notes

generate_oot_skeleton

Generate a gr_modtool-compatible Out-of-Tree module skeleton with CMakeLists.txt, Python package structure, and grc/ directory.

ParameterTypeRequiredDescription
module_namestringYesModule name (e.g., "custom", not "gr-custom")
output_dirstringYesWhere to create the module directory
authorstringNoModule author name

Returns: OOTSkeletonResult with success, module_name, path

export_block_to_oot

Export a generated block into a full OOT module structure. Creates the Python source file, GRC YAML block definition, and updates __init__.py. Creates the OOT skeleton if it doesn’t exist.

ParameterTypeRequiredDescription
source_codestringYesBlock source code
block_namestringYesBlock name
module_namestringYesTarget OOT module name
output_dirstringYesOOT module root directory

Returns: ExportResult with success, file paths created

export_from_flowgraph

Export an embedded Python block from the current flowgraph into an OOT module. Extracts the block’s source code and metadata, then calls export_block_to_oot.

ParameterTypeRequiredDescription
block_idstringYesBlock ID in the flowgraph (e.g., "epy_block_0")
module_namestringYesTarget OOT module name
output_dirstringYesOOT module root directory

Returns: ExportResult