Communicating with the Device

Communication with the test and measurement device is mostly done using setValue, query, and perform commands and functions. They provide basic SCPI communication to the device using a more readable and usable style than raw SCPI commands. In the case of setValue and query, they also simplify the use of channels and identifiers when the defaultChannel or defaultIdentifier is set.

Note: In SenseTalk, you can call most of the functions as either commands or functions. If you call query or queryData as a command, the returned value is stored in the variable it.

SCPI Commands and Functions

Command Parameters

SetValue, query, queryData, and perform all take a string parameter that contains the SCPI command. You can either write the command name portion of this string as:

  • A raw SCPI command conforming to SCPI syntax.
  • An English-like form that is converted to SCPI when it is sent to the device.

Command Strings

All the SCPI command strings allow you to use spaces between the words of the command rather than colons :, for greater readability. For example, you can write the SCPI command to measure voltage as "Measure voltage" instead of "MEAS:VOLT". The capitalization doesn’t matter.

Special Phrases

Your commands can also include these special phrases, which can appear in any order within the command string:

  • on channel <channel>: Sets the channel for the command to <channel>. This overrides the defaultChannel if one is set.
  • Example:

    "measure voltage on channel 3"

  • for <identifier>: Sets the identifier for the command to <identifier>. This overrides the defaultIdentifier if one is set.
  • Example:

    "power state for M1.DataOut1"

  • to <value>: Provides a parameter value, which is used before, and in addition to, any parameters that are given outside of the command string.
  • Example:

    "frequency center to 50mHz"

  • no overlap: Makes sure that the device completes the operation before the script proceeds. This overrides the AllowOverlappedCommands setting on the device.
  • Example:

    "Radio ARB trigger external delay state No overlap"

  • allow overlap: Allows the device to begin the operation, without necessarily completing it, before the script proceeds. This overrides the AllowOverlappedCommands setting on the device.
  • Example:

    "memory data PRAM allow overlap"

You can only use special phrases with the following commands:

  • perform
  • queryData
  • setValue
  • query.


setValue "output state for M1.DataOut1 to On" —> SCPI command generated: "OUTPUT:STATE 'M1.DataOut1', ON".

query "Measure Voltage on channel 2" —> SCPI command generated: "MEASURE:VOLTAGE? (@2)".

perform "initiate no overlap" —> SCPI command generated: "INITIATE;*OPC?".

Special phrases do not apply to ExecuteSCPI, which sends the command to the device exactly as given.


You can include one or more parameter values as:

  • Separate values after the command string.
  • A single parameter using the to <value> option within the string.


setValue "output state for M1.DataOut1 to On" —> SCPI command generated: "OUTPUT:STATE 'M1.DataOut1', ON".

setValue "voltage on channel 2", 170 millivolts // Sets the voltage on channel 2 to 170 millivolts.

setValue "calibrate state to on", password // Switches calibration on.

Using the Tell Command

Most of the example commands in this section use either:

  • A tell command to send a command message to the device.
  • Example:

    tell powerAnalyzer

  • Dot notation to send a function message.
  • Example:

    powerAnalyzer.query("measure voltage")

Another method, is to use a tell block. A tell block begins with a line like tell powerAnalyzer and ends with the line end tell. It directs all the relevant command and function calls within the block to the device. Using a tell block is generally the most convenient approach to use, as it avoids the need to specify the device with every command and function.

SetValue Command

Behavior: Sends a setting to the test and measurement device.

Parameters: Specific settings for the type of measurement device. You can also use this command without parameters, if required.


setValue scpiCommandOrPhrase {,value}

setValue scpiCommandOrPhrase

Examples with parameters:

tell powerAnalyzer to setValue "voltage", 3.5 // Sets the voltage to 3.5 on the device.

tell powerAnalyzer to setValue "output on channel 2", On // Turns on the power output on channel 2.

tell powerAnalyzer to setValue "voltage to 3.5v on channel 2" // Sets the voltage on channel 2 to 3.5 volts.

Example without parameters:

tell powerAnalyzer to setValue "initialize"

Query Function

Behavior: Requests information from the device for SCPI commands that end in "?", for example: "MEAS:VOLT?". The function supplies the "?" for you.

Parameters: Supported SCPI parameters.




put powerAnalyzer.query("measure voltage") into actualVoltage //Stores the measured voltage on the device in a variable.

QueryData Function

Behavior: Requests binary data from the device, such as a screen image or file contents.

Note: Unlike setValue and query, the queryData function does not automatically include the defaultChannel or defaultIdentifier.

Parameters: Supported SCPI parameters.



Returns: Binary data for the specific SCPI command.


put powerAnalyzer.queryData("HCopy SDump data") into screenDumpData // Stores screen dump data from the device to a variable.

Perform Command and Function

Behavior: Performs an action on the device and returns a value from that action.

Note: Unlike setValue and query, the perform command does not automatically include the defaultChannel or defaultIdentifier, and so is useful for commands where a channel or identifier is not required.

Parameters: Supported SCPI commands.

Command Syntax:

perform scpiCommandOrPhrase {,value}

Function Syntax:

perform(scpiCommandOrPhrase {,value})

{the} perform of scpiCommandOrPhrase


tell powerAnalyzer to perform "status preset" // Resets the device to the factory settings.

tell powerAnalyzer to perform "system date", "2021,04,03" // Sets the system date on the device.

put powerAnalyzer.perform("system error?") into lastErrorMsg // Stores system error text from the device to a variable.

Reset Command

Behavior: Resets the device, and puts it in a fresh, known state. For this reason, this command is often one of the first in a script.

Parameters: None.




tell powerAnalyzer to reset // Resets the device to a known, fresh state.

ExecuteSCPI Command and Function

Behavior: Sends raw SCPI commands to the device and returns a value from the specific command.

Note: When using this option, you must correctly format the SCPI command yourself, including:
  • Channel information
  • Identifiers
  • Parameters.

For this reason, we recommend that you use the setValue and query commands.

Parameters: Supported SCPI parameters.

Command Syntax:

executeSCPI scpiCommand

Function Syntax:


{the} executeSCPI of scpiCommand


tell powerAnalyzer to ExecuteSCPI myCommand // Sends your SCPI command to the device.

put powerAnalyzer.executeSCPI(myQueryCommand) into myVar // Returns a value for your SCPI command and stores it in a variable.


This topic was last updated on January 13, 2022, at 02:43:37 PM.

Eggplant icon | Documentation Home | User Forums | Support | Copyright © 2022 Eggplant