Share an NI-Digital Session Between Semiconductor Device Control and Python

Updated Oct 27, 2026

Reported In

Hardware

  • PXI Digital Pattern Instrument
  • PXIe-6570
  • PXIe-6571

Software

  • Semiconductor Device Control Add-On for InstrumentStudio

Issue Details

I am using the Semiconductor Device Control (SDC) add-on for NI InstrumentStudio™ to communicate with a DUT through an NI-Digital instrument using custom SDC protocols. Once the DUT has been configured, I would like to perform additional NI-Digital operations from a separate Python application while continuing to use the same NI-Digital session.

Solution

Starting with SDC 24.5, a Python application can attach to an existing SDC session and retrieve the NI-Digital gRPC session information required to connect to the associated named NI-Digital session. Therefore, upgrading to SDC 24.5 or later is required to use this workflow.
 
Once the appropriate version is installed, use the following workflow to access an NI-Digital instrument session that was started by SDC:
 
  1. Use attach_to_existing_session() to connect to the running SDC session.
  2. Use Get gRPC Session Options to obtain the NI-Digital gRPC session information.
  3. Use nidigital.SessionInitializationBehavior.ATTACH_TO_SERVER_SESSION to connect to the associated named NI-Digital session.
  4. Perform the required NI-Digital operations.
 
As a reference, the following Python example demonstrates this workflow for scenarios where the SDC session has already been created and started by another application, such as NI InstrumentStudio. The script assumes that an SDC session is already running and available for use. When using this example, keep the following considerations in mind:
 
  • INTERFACE_NAME must match the NI-Digital interface configured in SDC.
  • The application that created the SDC session must remain running while the Python application is using the session.
  • Do not call sdc.stop() or sdc.destroy() from an application that did not create the SDC session.
import nidigital
from nisdc.nisemidevicecontrol import SemiconductorDeviceControl

INTERFACE_NAME = "NI 657x"  # Replace with your SDC interface name.

sdc = SemiconductorDeviceControl().attach_to_existing_session()
options = sdc.get_session_options(INTERFACE_NAME)

try:
    grpc_options = nidigital.GrpcSessionOptions(
        grpc_channel=options.grpc_channel,
        session_name=options.session_name,
        initialization_behavior=(
            nidigital.SessionInitializationBehavior.ATTACH_TO_SERVER_SESSION
        ),
    )

    with nidigital.Session(
        resource_name=options.resource_name,
        grpc_options=grpc_options,
    ) as digital:
        # Perform the required NI-Digital operations using `digital`.
        pass
finally:
    options.grpc_channel.close()

Additional Information

The SDC Python API repository contains additional examples and documentation for working with SDC sessions. The example in this article demonstrates only how to access an existing NI-Digital session managed by SDC. Refer to the repository for additional SDC Python API capabilities and usage examples.