Skip to content

IDN

Query a device's identity through the universal *IDN? SCPI command.Inputs ------ default: DataContainer Any DataContainer - likely connected to the output of the OPEN_SERIAL block.Params:connection : SerialThe open connection with the device receiving the *IDN? SCPI command.Returns:out : TextBlobThe result of the *IDN? SCPI command.
Python Code
import serial
from flojoy import flojoy, SerialConnection, TextBlob, DataContainer
from typing import cast, Optional


@flojoy(deps={"pyserial": "3.5"}, inject_connection=True)
def IDN(
    connection: SerialConnection, default: Optional[DataContainer] = None
) -> TextBlob:
    """Query a device's identity through the universal *IDN? SCPI command.

    Inputs
    ------
    default: DataContainer
        Any DataContainer - likely connected to the output of the OPEN_SERIAL block.

    Parameters
    ----------
    connection: Serial
        The open connection with the device receiving the *IDN? SCPI command.

    Returns
    -------
    TextBlob
        The result of the *IDN? SCPI command.
    """

    # Start serial communication with the instrument
    ser = cast(serial.Serial, connection.get_handle())

    if ser is None:
        raise ValueError("Serial communication is not open")

    ser.write("*IDN?\n".encode())

    return TextBlob(text_blob=ser.readline().decode())

Find this Flojoy Block on GitHub

Example

Having problems with this example app? Join our Discord community and we will help you out!
React Flow mini map

This app opens a serial connection with the OPEN_SERIAL node, then queries the identity of the device with the IDN node.