Spectrum Analyzer · SCPI command reference

Keysight N9342C and N9344C SCPI commands

The Keysight N9342C and N9344C spectrum analyzer is controlled remotely with SCPI commands. TestFlow's instrument library holds 76 commands for it, 17 of them queries that read values or state, grouped below by subsystem with their arguments. It is the same library TestFlow's AI agent uses to drive the N9342C on a real bench.

Commands
76
Queries
17
Subsystems
14
Models covered
2

Run this on your bench

Describe the test; TestFlow's agent uses this command set to drive your Keysight N9342C or N9344C and writes the report from the measured results.

Get started

Control the Keysight N9342C from Python

With PyVISA, any VISA backend, and the instrument on USB, LAN or GPIB, this opens a session, identifies the instrument, sends one setting, and reads one value. Every command in it comes from the reference below. For a full walkthrough, see the PyVISA tutorial and the SCPI command cheat sheet.

import pyvisa

rm = pyvisa.ResourceManager()
print(rm.list_resources())  # find the Keysight N9342C's VISA address

# Paste the address of your Keysight N9342C (USB, LAN or GPIB).
inst = rm.open_resource("PASTE_VISA_ADDRESS_HERE")
inst.timeout = 5000  # ms

print(inst.query("*IDN?"))  # identify the instrument
inst.write(":SENSe:FREQuency:SPAN:FULL")  # Set Full Span
print(inst.query(":MEASure:CHPower?"))  # Read Channel Power

inst.close()

Run this on your bench

Describe the test; TestFlow's agent uses this command set to drive your Keysight N9342C or N9344C and writes the report from the measured results.

Get started

Run a N9342C test without writing code

Describe the test in a sentence, for example “set full span on the N9342C, then read channel power and log it against a limit”. TestFlow's agent builds the steps from this command library, runs them on your bench through the TestFlow desktop app, and writes the report from the measured values. See AI test automation for lab instruments for how that works and where it stops.

Get started

SCPI command reference

76 commands in 14 groups. A ? marks a query that returns a value. Placeholders in angle brackets take the listed values. The N9342C and N9344C share this command set in TestFlow's library.

Sense (SENSe) (37)

CommandWhat it doesArguments
:SENSe:FREQuency:CENTer <Frequency>Set Center Freq. Sets the center frequency of the displayed span in Hz.Number
:SENSe:FREQuency:CENTer?Get Center Freq. Queries the current center frequency in Hz.None
:SENSe:FREQuency:STARt <Frequency>Set Start Freq. Sets the start (left edge) frequency of the sweep in Hz.Number
:SENSe:FREQuency:STARt?Get Start Freq. Queries the start frequency in Hz.None
:SENSe:FREQuency:STOP <Frequency>Set Stop Freq. Sets the stop (right edge) frequency of the sweep in Hz.Number
:SENSe:FREQuency:STOP?Get Stop Freq. Queries the stop frequency in Hz.None
:SENSe:FREQuency:SPAN <Span>Set Span. Sets the frequency span of the sweep in Hz.Number
:SENSe:FREQuency:SPAN?Get Span. Queries the current frequency span in Hz.None
:SENSe:FREQuency:SPAN:FULLSet Full Span. Sets the span to the full frequency range of the analyzer.None
:SENSe:FREQuency:SPAN 0Set Zero Span. Sets the analyzer to zero span (time-domain at the center frequency).None
:SENSe:FREQuency:OFFSet <Offset>Set Freq Offset. Sets a frequency offset added to all displayed frequency readouts in Hz.Number
:SENSe:POWer:RF:ATTenuation:AUTO ONSet Atten Auto On. Enables automatic input attenuation coupling to the reference level.None
:SENSe:POWer:RF:ATTenuation:AUTO OFFSet Atten Auto Off. Disables automatic attenuation so the manual attenuation value is used.None
:SENSe:POWer:RF:ATTenuation <Atten>Set Attenuation. Sets the input RF attenuation in dB (manual mode).Number
:SENSe:POWer:RF:ATTenuation?Get Attenuation. Queries the current input RF attenuation in dB.None
:SENSe:POWer:RF:GAIN:STATe ONPreamp On. Turns the internal RF preamplifier on.None
:SENSe:POWer:RF:GAIN:STATe OFFPreamp Off. Turns the internal RF preamplifier off.None
:SENSe:BANDwidth:RESolution:AUTO ONSet RBW Auto On. Enables automatic coupling of resolution bandwidth to span.None
:SENSe:BANDwidth:RESolution:AUTO OFFSet RBW Auto Off. Disables automatic RBW so the manual value is used.None
:SENSe:BANDwidth:RESolution <RBW>Set RBW. Sets the resolution bandwidth (RBW) in Hz.Number
:SENSe:BANDwidth:RESolution?Get RBW. Queries the current resolution bandwidth in Hz.None
:SENSe:BANDwidth:VIDeo:AUTO ONSet VBW Auto On. Enables automatic coupling of video bandwidth to RBW.None
:SENSe:BANDwidth:VIDeo:AUTO OFFSet VBW Auto Off. Disables automatic VBW so the manual value is used.None
:SENSe:BANDwidth:VIDeo <VBW>Set VBW. Sets the video bandwidth (VBW) in Hz.Number
:SENSe:BANDwidth:VIDeo?Get VBW. Queries the current video bandwidth in Hz.None
:SENSe:SWEep:TIME:AUTO ONSet Sweep Time Auto On. Enables automatic sweep time coupling to span and bandwidth.None
:SENSe:SWEep:TIME:AUTO OFFSet Sweep Time Auto Off. Disables automatic sweep time so the manual value is used.None
:SENSe:SWEep:TIME <Time>Set Sweep Time. Sets the sweep time in seconds.Number
:SENSe:SWEep:TIME?Get Sweep Time. Queries the current sweep time in seconds.None
:SENSe:DETector:TRACe <Detector>Set Detector. Sets the detector type used to reduce sweep data to trace points.Text: NORMal,AVERage,POSitive,NEGative,SAMPle
:SENSe:AVERage:TRACe<TraceNum>:STATe ONSet Average On. Turns trace averaging on.Number: 1-4
:SENSe:AVERage:TRACe<TraceNum>:STATe OFFSet Average Off. Turns trace averaging off.Number: 1-4
:SENSe:AVERage:TRACe<TraceNum>:COUNt <Count>Set Average Count. Sets the number of averages to accumulate.Number: 1-4; Number: 1-8192
:SENSe:AVERage:TYPE <AvgType>Set Average Type. Sets the averaging type (power/RMS, log-power, or voltage/scalar).Text: LOGPower,POWer,VOLTage
:SENSe:CHPower:BANDwidth:INTegration <IBW>Set CHP Integ BW. Sets the integration bandwidth used by the channel power measurement in Hz.Number
:SENSe:OBW:PERCent <Percent>Set OBW Percent. Sets the percent of total power used to define occupied bandwidth (typically 99).Number: 10-99
:SENSe:CORRection:IMPedance:INPut:MAGNitude <Impedance>Set Input Impedance. Sets the input impedance reference (50 or 75 ohms) for amplitude correction.Text: OHM50,OHM75

Calculate (CALCulate) (14)

CommandWhat it doesArguments
:CALCulate:MARKer<MkrNum>:STATe ONMarker On. Turns on the specified marker.Number: 1-6
:CALCulate:MARKer<MkrNum>:STATe OFFMarker Off. Turns off the specified marker.Number: 1-6
:CALCulate:MARKer<MkrNum>:X <Position>Set Marker X. Sets the X-axis (frequency or time) position of the specified marker.Number: 1-6; Number
:CALCulate:MARKer<MkrNum>:X?Get Marker X. Queries the X-axis position (frequency/time) of the specified marker.Number: 1-6
:CALCulate:MARKer<MkrNum>:Y?Get Marker Y. Queries the Y-axis amplitude value at the specified marker.Number: 1-6
:CALCulate:MARKer<MkrNum>:MAXimumMarker Peak Search. Moves the specified marker to the highest peak on the trace.Number: 1-6
:CALCulate:MARKer<MkrNum>:MAXimum:NEXTMarker Peak Next. Moves the specified marker to the next-highest peak.Number: 1-6
:CALCulate:MARKer<MkrNum>:MAXimum:LEFTMarker Peak Left. Moves the specified marker to the next peak to the left.Number: 1-6
:CALCulate:MARKer<MkrNum>:MAXimum:RIGHtMarker Peak Right. Moves the specified marker to the next peak to the right.Number: 1-6
:CALCulate:MARKer<MkrNum>:SET:CENTerMarker To Center. Sets the center frequency to the marker's current frequency.Number: 1-6
:CALCulate:MARKer<MkrNum>:MODE <Mode>Set Marker Mode. Sets the marker mode (normal position/delta/fixed/off).Number: 1-6; Text: POSition,DELTa,OFF
:CALCulate:MARKer<MkrNum>:FUNCtion <Function>Set Marker Function. Sets a marker function such as noise marker or band/interval power.Number: 1-6; Text: FCOunt,NOISe,OFF
:CALCulate:MARKer:PEAK:THReshold <Threshold>Set Peak Threshold. Sets the amplitude threshold above which peaks are recognized by peak search.Number
:CALCulate:MARKer:PEAK:EXCursion <Excursion>Set Peak Excursion. Sets the peak excursion (in dB) a signal must rise and fall to qualify as a peak.Number

Display (DISPlay) (3)

CommandWhat it doesArguments
:DISPlay:WINDow:TRACe:Y:SCALe:RLEVel <Level>Set Ref Level. Sets the reference level (top of the display grid) in the current Y units.Number
:DISPlay:WINDow:TRACe:Y:SCALe:RLEVel?Get Ref Level. Queries the current reference level.None
:DISPlay:WINDow:TRACe:Y:SCALe:PDIVision <ScalePerDiv>Set Y Scale Div. Sets the vertical scale per division (dB/div in log mode).Text: DIV1,DIV2,DIV5,DIV10

Initiate (INITiate) (3)

CommandWhat it doesArguments
:INITiate:CONTinuous ONContinuous Sweep On. Sets the analyzer to continuous (free-run) sweep mode.None
:INITiate:CONTinuous OFFContinuous Sweep Off. Sets the analyzer to single-sweep mode.None
:INITiate:IMMediateInitiate Sweep. Triggers a new sweep/measurement (single-shot when not continuous).None

Instrument (INSTrument) (2)

CommandWhat it doesArguments
:INSTrument:SELect SASelect SA Mode. Selects the Spectrum Analyzer (Swept SA) measurement mode.None
:INSTrument:SELect <Mode>Select Mode. Selects the active measurement mode/application on the analyzer.Text: SA,TGENerator,POWermeter

Trigger (TRIGger) (2)

CommandWhat it doesArguments
:TRIGger:SEQuence:SOURce <Source>Set Trigger Source. Selects the sweep trigger source.Text: IMMediate,VIDeo,EXTernal
:TRIGger:VIDeo:LEVel <Level>Set Trigger Level. Sets the video trigger level in the current amplitude units.Number

Measurement (MEASure) (2)

CommandWhat it doesArguments
:MEASure:CHPower?Read Channel Power. Initiates and reads the channel power and power-spectral-density result.None
:MEASure:OBW?Read OBW. Initiates and reads the occupied bandwidth result.None

UNIT subsystem (1)

CommandWhat it doesArguments
:UNIT:POWer <Units>Set Y Units. Sets the amplitude (Y-axis) units for power readouts.Text: DBM,DBMV,DBMVEMF,DBUV,DBUVEMF,V,W,VEMF

Trace (TRACe) (1)

CommandWhat it doesArguments
:TRACe:DATA? <TraceName>Read Trace Data. Reads back the amplitude data points of the specified trace.Text: TRACe1,TRACe2,TRACe3,TRACe4

FORM subsystem (1)

CommandWhat it doesArguments
:FORMat:TRACe:DATA <Format>Set Trace Format. Sets the numeric data format used when transferring trace data.Text: ASCii,REAL

Other subsystem (1)

CommandWhat it doesArguments
<Output Variable>=<Equation>Math. Variable equals an equation like (${Var_name}= ${Var_name}/2)Number; Text

WAIT subsystem (1)

CommandWhat it doesArguments
wait(<ms>)Wait. Waits for number of millisecondsNumber

SAVE subsystem (1)

CommandWhat it doesArguments
save2var <Variable_name>Save2Variable. Saves last measurement to a variableText

IEEE 488.2 common commands (7)

CommandWhat it doesArguments
*IDN?Identify. Returns the instrument identification string (manufacturer, model, serial, firmware).None
*RSTReset. Resets the instrument to its default state.None
*CLSClear Status. Clears all event registers and the error queue.None
*TST?Self Test. Runs the self-test and returns 0 for pass or 1 for failure.None
*OPC?Operation Complete. Returns 1 when all pending operations are complete.None
*WAIWait To Continue. Waits until all pending operations are complete before continuing.None
*TRGTrigger Bus. Generates a bus trigger when the instrument is in wait-for-trigger state.None

Where these commands come from

This reference is generated from TestFlow's instrument library, which is drafted from Keysight's programming documentation for the N9342C and N9344C and checked when the agent runs it. Ranges, timing, and option-dependent commands are defined by Keysight's programming manual: check it before you rely on an edge case. Last updated November 17, 2026.

Frequently asked questions

Does the Keysight N9342C support SCPI remote control?

Yes. The Keysight N9342C accepts SCPI commands over its remote interfaces. TestFlow's instrument library holds 76 SCPI commands for it: 17 queries that read values or state, and 59 settings and actions.

How do I control the Keysight N9342C from Python?

Install PyVISA and a VISA backend, find the instrument's address with ResourceManager().list_resources(), open it, then send commands with write() and read values with query(). The example on this page sends *IDN?, :SENSe:FREQuency:SPAN:FULL and :MEASure:CHPower?.

Which command reads a value from the Keysight N9342C?

:MEASure:CHPower? (read channel power). Initiates and reads the channel power and power-spectral-density result. The full list of queries is in the command reference on this page, grouped by subsystem.

Can I automate the Keysight N9342C without writing code?

Yes. TestFlow is an AI agent for electronics testing: you describe the test, and it builds the automation from this command library, runs it on the Keysight N9342C through the TestFlow desktop app, and writes the report from the measured results.

Your next test, automated today

Describe the test. TestFlow builds the workflow, runs it on your instruments, and writes the report. See it on a bench like yours.