\documentclass[a4paper,11pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} % LY1 also works
\usepackage[margin=1in]{geometry}

%% Font settings suggested by fbb documentation.
\usepackage{textcomp} % to get the right copyright, etc.
\usepackage[lining,tabular]{fbb} % so math uses tabular lining figures
\usepackage[scaled=.95,type1]{cabin} % sans serif in style of Gill Sans
\usepackage[varqu,varl]{zi4}% inconsolata typewriter
\useosf % change normal text to use proportional oldstyle figures
%\usetosf would provide tabular oldstyle figures in text

\usepackage{microtype}
\usepackage{siunitx}
\DeclareSIUnit{\belmilliwatt}{Bm}
\DeclareSIUnit{\dBm}{\deci\belmilliwatt}
\sisetup{range-phrase=--, range-units=single, binary-units = true}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{svg}
%\usepackage{hyperref}
\usetikzlibrary{arrows, shadows}
\tikzset{%
  cascaded/.style = {%
    general shadow = {%
      shadow scale = 1,
      shadow xshift = -1ex,
      shadow yshift = 1ex,
      draw,
      thick,
      fill = white},
    general shadow = {%
      shadow scale = 1,
      shadow xshift = -.5ex,
      shadow yshift = .5ex,
      draw,
      thick,
      fill = white},
    fill = white, 
    draw,
    thick,
    minimum width = 1.5cm,
    minimum height = 2cm}}
    
\usepackage{enumitem}
\usepackage{longtable}
\setitemize{noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt}
\setlist{leftmargin=*}
\usepackage{listings}
\definecolor{darkgreen}{RGB}{0,140,0}
\lstset{
	basicstyle=\ttfamily,
	frame=single,
	breaklines=true,
	morecomment=[l][\color{darkgreen}]{\#},
}
\lstnewenvironment{example}{\lstset{
    ,frame=single
    ,xleftmargin=2em
    ,xrightmargin=2em
   % ,backgroundcolor=\color{lightgray}
    ,title=Example
}}{}
\usepackage[os=win]{menukeys}
\renewmenumacro{\keys}[+]{shadowedroundedkeys}

\usepackage{booktabs,caption}
\usepackage[flushleft]{threeparttable}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\usepackage{tabularx} 

\usepackage{stackengine}
\usepackage{scalerel}
\usepackage{xcolor,mdframed}
\newcommand\danger[1][5ex]{%
  \renewcommand\stacktype{L}%
  \scaleto{\stackon[1.3pt]{\color{red}$\triangle$}{\tiny !}}{#1}%
}

\newenvironment{important}[1][]{%
   \begin{mdframed}[%
      backgroundcolor={red!15}, hidealllines=true,
      skipabove=0.7\baselineskip, skipbelow=0.7\baselineskip,
      splitbottomskip=2pt, splittopskip=4pt, #1]%
   \makebox[0pt]{% ignore the withd of !
      \smash{% ignor the height of !
         %\fontsize{32pt}{32pt}\selectfont% make the ! bigger
         \hspace*{-45pt}% move ! to the left
         \raisebox{-5pt}{% move ! up a little
            {\danger}% type the bold red !
         }%
      }%
   }%
}{\end{mdframed}}

\newcommand\info[1][5ex]{%
  \renewcommand\stacktype{L}%
  \scaleto{\stackon[1.2pt]{\color{blue}$\bigcirc$}{\raisebox{-1.5pt}{\small i}}}{#1}%
}

\newenvironment{information}[1][]{%
   \begin{mdframed}[%
      backgroundcolor={blue!15}, hidealllines=true,
      skipabove=0.7\baselineskip, skipbelow=0.7\baselineskip,
      splitbottomskip=2pt, splittopskip=4pt, #1]%
   \makebox[0pt]{% ignore the withd of !
      \smash{% ignor the height of !
         %\fontsize{32pt}{32pt}\selectfont% make the ! bigger
         \hspace*{-45pt}% move ! to the left
         \raisebox{-5pt}{% move ! up a little
            {\info}% type the bold red !
         }%
      }%
   }%
}{\end{mdframed}}

\usepackage{makecell}
\usepackage{hyperref}
\usepackage{xifthen}
\newcommand{\vna}{LibreVNA}
\newcommand{\gui}{\vna{}-GUI}
\newcommand{\subsubsubsection}[1]{\paragraph{#1}\mbox{}\\\\}

\newcommand{\screenshot}[2]{\begin{center}
\includegraphics[width=#1\textwidth]{Screenshots/#2}
\end{center}}


\newcommand{\event}[3]{
\noindent\textbf{Event:}
\begin{longtable}{p{.15\textwidth} | p{.80\textwidth} } 
\hline
\textbf{Effect:} & #1 \\ \hline
\textbf{Syntax:} & #2 \\ \hline 
\textbf{Parameters:} & \makecell[Xl]{#3} \\ \hline
\end{longtable}
}
\newcommand{\query}[4]{
\noindent\textbf{Query:}
\begin{longtable}{p{.15\textwidth} | p{.80\textwidth} } 
\hline
\textbf{Effect:} & #1 \\ \hline
\textbf{Syntax:} & #2 \\ \hline 
\textbf{Parameters:} & \makecell[tl]{#3} \\ \hline
\textbf{Return value:} & \makecell[tl]{#4} \\ \hline
\end{longtable}
}

\title{\vna{} SCPI Programming Guide}
\begin{document}
\maketitle

\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
\tableofcontents

\clearpage

\section{Introduction}
The \gui{} contains a TCP server that can be used to control the \vna{} with SCPI commands.
\section{SCPI Server Configuration}
The server is configurable in the preferences: \menu[,]{Window,Preferences,General}
\screenshot{0.3}{serverconfig.png}
If enabled, it will accept any TCP connection at the configured port. Once the connection is established, it can be used to send SCPI commands and receive replies. Only one connection at a time is possible, if a second connection is created, the first one will be closed by the \gui{}. Alternatively, a port can be manually configured by setting the ``port'' argument:
\begin{lstlisting}
./LibreVNA-GUI --port 1234
\end{lstlisting}
This enables the SCPI server at the specified port, regardless of what is configured in the preferences (useful for starting multiple instances at different ports at the same time). If no graphical user interface is required, the \gui{} can be hidden:
\begin{lstlisting}
./LibreVNA-GUI --port 1234 --no-gui
\end{lstlisting}
\section{General Syntax}
The syntax follows the usual SCPI rules:
\begin{itemize}
\item All commands are case insensitive (implicitly converted to uppercase before evaluated)
\item The command tree is organized in branches, separated by a colon:
\begin{lstlisting}
VNA:TRACE:LIST?
\end{lstlisting}
\item Multiple commands can be concatenated in one line using a semicolon:
\begin{lstlisting}
DEVice:CONNECT;:DEVice:INFo:FWRevision?
\end{lstlisting}
\item If a subsequent command starts with a colon it is evaluated from the root branch, otherwise the last used branch is assumed:
\begin{lstlisting}
VNA:FREQuency:START 1000000;STOP 2000000 #No colon, VNA:FREQuency branch was used before
\end{lstlisting}
\item Branches and commands can be abbreviated by using only the uppercase part of their name, the following commands are identical:
\begin{lstlisting}
DEVice:INFo:LIMits:MINFrequency?
DEV:INF:LIM:MINF?
\end{lstlisting}
\item Every query generates a response, terminated with a newline character (exceptions exist for a few queries which return more than one line)
\item Some commands require additional arguments that have to be passed after the command (separated by spaces):
\begin{lstlisting}
DEV:REF:OUT 10
\end{lstlisting}
\item Two types of commands are available:
\begin{itemize}
\item \textbf{Events} change a setting or trigger an action. They have no response
\item \textbf{Queries} request information. They end with a question mark.
\end{itemize}
Some commands are both events and queries, depending on whether the question mark is present:
\begin{lstlisting}
VNA:FREQ:SPAN 50000000 # Set the span
VNA:FREQ:SPAN? # Read the current span
\end{lstlisting}
\end{itemize}
\section{Commands}
\subsection{General Commands}
\subsubsection{*IDN}
\query{Returns the identifications string}{*IDN?}{None}{LibreVNA,LibreVNA-GUI,<serial>,<software version>}
\begin{itemize}
\item The serial number is the serial number from the connected LibreVNA. If none is connected, it will be set to ``Not connected''
\item The software version is the version of the \gui{}, not the firmware version of the connected \vna{}
\end{itemize}
\subsubsection{*RST}
\event{Resets the GUI (and any connected device) to the default state}{*RST}{None}
\subsubsection{*CLS}
\event{Clears the event status register}{*CLI}{None}
\subsubsection{*ESE}
\event{Configures the event status enable register}{*ESE}{<enabled\_bits\_decimal>}
\query{Returns the event status enable register}{*ESE?}{None}{<enabled\_bits\_decimal>}
\subsubsection{*ESR}
\query{Returns the event status register}{*ESR?}{None}{<set\_bits\_decimal>}
The bits are used according to IEEE 488:
\begin{longtable}{p{.1\textwidth} | p{.1\textwidth} | p{.4\textwidth} }
\textbf{Bitvalue} & \textbf{Name} & \textbf{Meaning}\\
\hline
1 & OPC & Operation complete\\
2 & RQC & Request control (not used)\\
4 & QYE & Query error (not used)\\
8 & DDE & Device dependent error (not used)\\
16 & EXE & Execution error (not used)\\
32 & CME & Command error\\
64 & URQ & User request (not used)\\
128 & PON & Power on (not used)\\
\end{longtable}
\subsubsection{*OPC}
\event{Sets the OPC bit in the event status register after all operations are complete}{*OPC}{None}
\query{Returns a 1 after every active operation has completed}{*OPC?}{None}{1}
\subsubsection{*WAI}
\event{Blocks further command parsing until all active operations are complete}{*WAI}{None}
\subsubsection{*LST}
\query{Lists all available commands}{*LST?}{None}{List of commands, separated by newline}
\subsection{Device Commands}
This section contains general device commands, available regardless of the current mode.
\subsubsection{DEVice:DISConnect}
\event{Disconnects from the device}{DEVice:DISConnect}{None}

\subsubsection{DEVice:CONNect}
\event{Connects to a device. If no serialnumber is specified, the connection is made with the first device found}{DEVice:CONNect [<serialnumber>]}{<serialnumber> Serialnumber of the device that should be connected}
\begin{example}
:DEV:CONN 206039903350
\end{example}
\query{Queries the serial number of the connected device}{DEVice:CONNect?}{None}{<serialnumber> or ``Not connected''}
\begin{example}
:DEV:CONN?
206039903350
\end{example}

\subsubsection{DEVice:LIST}
\query{Lists all available devices by their serial numbers}{DEVice:LIST?}{None}{List of serialnumbers}
\begin{example}
:DEV:LIST?
206039903350,208939A23350
\end{example}

\subsubsection{DEVice:PREFerences}
This command provides read/write access to the preferences. The recommended way is usually to change the preferences manually in the GUI. But if for some reason that is not an option, this is also possible through the SCPI server. There is no complete documentation for all available preferences, refer to the source code.

\event{Set a preferences entry}{DEVice:PREFerences <name> <value>}{<name> Name of the preferences entry\\ <value> New value for the preferences entry}
\begin{example}
:DEV:PREF Startup.ConnectToFirstDevice false
\end{example}
Most settings take effect immediately but some (such as changing the port for the SCPI server) are only applied when the preferences are saved. Also see command~\ref{DEV:APPLYPREF}.

\query{Returns a preferences entry}{DEVice:PREFerences? <name>}{<name> Name of the preferences entry}{Current value of the preferences entry}

\subsubsection{DEVice:APPLYPREFerences}
\label{DEV:APPLYPREF}
\event{Permanently stores the preferences after a setting has been changed}{DEVice:APPLYPREFerences}{None}

\subsubsection{DEVice:MODE}
\event{Switches the device to the specified mode}{DEVice:MODE <mode>}{<mode>:\\ \hspace{1cm} VNA: set to vector analyzer\\ \hspace{1cm} GEN: set to signal generator\\ \hspace{1cm} SA: set to spectrum analyzer}
\begin{example}
:DEV:MODE VNA
\end{example}
\query{Queries the currently active mode}{DEVice:MODE?}{None}{<mode>:\\ \hspace{1cm} VNA: set to vector analyzer\\ \hspace{1cm} GEN: set to signal generator\\ \hspace{1cm} SA: set to spectrum analyzer}
\begin{example}
:DEV:MODE?
VNA
\end{example}

\subsubsection{DEVice:SETUP:SAVE}
\event{Saves the GUI setup to a file}{DEVice:SETUP:SAVE}{<filename>}
Important points when saving/loading setup files through SCPI commands:
\begin{itemize}
\item Filenames must be either absolute or relative to the location of the GUI application.
\item If the LibreVNA-GUI (and thus also the SCPI server) is running on a different machine than the SCPI client, the setup files will be saved/loaded from the machine that runs the GUI.
\item If no (or a wrong) file ending is specified, ``.setup'' is automatically added to the filename.
\end{itemize}

\subsubsection{DEVice:SETUP:LOAD}
\query{Loads a setup file}{DEVice:SETUP:LOAD?}{<filename>}{TRUE or FALSE}
\begin{itemize}
\item Filenames must be either absolute or relative to the location of the GUI application.
\item The filename must include the file ending ``.setup''.
\end{itemize}

\subsubsection{DEVice:REFerence:OUT}
\event{Sets the reference output frequency}{DEVice:REFerence:OUT <freq>}{<freq> in MHz, either 0 (disabled), 10 or 100}
\query{Queries the reference output frequency}{DEVice:REFerence:OUT?}{None}{Output frequency in MHz}

\subsubsection{DEVice:REFerence:IN}
\event{Set the reference input mode}{DEVice:REFerence:IN <mode>}{<mode>:\\ \hspace{1cm} INT: use internal reference\\ \hspace{1cm} EXT: use external reference\\ \hspace{1cm} AUTO: automatic reference switching}
\query{Queries the reference source}{DEVice:REFerence:IN?}{None}{INT or EXT}

\subsubsection{DEVice:STAtus:UNLOcked}
\query{Queries the PLL lock error flag}{DEVice:STAtus:UNLOcked?}{None}{TRUE or FALSE}

\subsubsection{DEVice:STAtus:ADCOVERload}
\query{Queries the ADC overload error flag}{DEVice:STAtus:ADCOVERload?}{None}{TRUE or FALSE}

\subsubsection{DEVice:STAtus:UNLEVel}
\query{Queries the output level error flag}{DEVice:STAtus:UNLEVel?}{None}{TRUE or FALSE}

\subsubsection{DEVice:INFo:FWREVision}
\query{Returns the firmware revision of the connected device}{DEVice:INFo:FWREVision?}{None}{<mayor>.<minor>.<patch>}
\begin{example}
:DEV:INF:FWREV?
1.0.0
\end{example}
\subsubsection{DEVice:INFo:HWREVision}
\query{Returns the hardware revision of the connected device}{DEVice:INFo:HWREVision?}{None}{<revision>, single char}
\begin{example}
:DEV:INF:HWREV?
B
\end{example}

\subsubsection{DEVice:INFo:LIMits:MINFrequency}
\query{Queries the lowest frequency the device can measure}{DEVice:INFo:LIMits:MINFrequency?}{None}{lowest frequency in Hz}

\subsubsection{DEVice:INFo:LIMits:MAXFrequency}
\query{Queries the highest frequency the device can measure}{DEVice:INFo:LIMits:MAXFrequency?}{None}{highest frequency in Hz}

\subsubsection{DEVice:INFo:LIMits:MINIFBW}
\query{Queries the lowest IF bandwidth setting}{DEVice:INFo:LIMits:MINIFBW?}{None}{lowest possible IF bandwidth in Hz}

\subsubsection{DEVice:INFo:LIMits:MAXIFBW}
\query{Queries the highest IF bandwidth setting}{DEVice:INFo:LIMits:MAXIFBW?}{None}{highest possible IF bandwidth in Hz}

\subsubsection{DEVice:INFo:LIMits:MAXPoints}
\query{Queries the maximum number of points per sweep}{DEVice:INFo:LIMits:MAXPoints?}{None}{maximum number of points}

\subsubsection{DEVice:INFo:LIMits:MINPOWer}
\query{Queries the minimum output power}{DEVice:INFo:LIMits:MINPOWer?}{None}{minimum output power in dBm}

\subsubsection{DEVice:INFo:LIMits:MAXPOWer}
\query{Queries the maximum output power}{DEVice:INFo:LIMits:MAXPOWer?}{None}{maximum output power in dBm}

\subsubsection{DEVice:INFo:LIMits:MINRBW}
\query{Queries the lowest resolution bandwidth setting}{DEVice:INFo:LIMits:MINRBW?}{None}{lowest possible resolution bandwidth in Hz}

\subsubsection{DEVice:INFo:LIMits:MAXRBW}
\query{Queries the highest resolution bandwidth setting}{DEVice:INFo:LIMits:MAXRBW?}{None}{highest possible resolution bandwidth in Hz}

\subsubsection{DEVice:INFo:LIMits:MAXHARMonicfrequency}
\query{Queries the (theoretical) maximum frequency when using harmonic mixing in VNA mode}{DEVice:INFo:LIMits:MAXHARMonicfrequency?}{None}{maximum frequency in Hz}

\subsection{VNA Commands}
These commands change or query VNA settings. Although most of them are available regardless of the current device mode, they usually only have an effect once the VNA mode is active (e.g. it is possible to change the span while in signal generator mode but it does not effect the \vna{} until the mode is switched to VNA). Certain commands (like taking a calibration measurement) are only available in VNA mode and will return an error if another mode is active.

\subsubsection{VNA:SWEEP}
\event{Sets the type of the sweep}{VNA:SWEEP}{<type>, either FREQUENCY or POWER}
\query{Queries the currently selected type}{VNA:SWEEP?}{None}{<type>, either FREQUENCY or POWER}

\subsubsection{VNA:FREQuency:SPAN}
\event{Sets the span of the sweep}{VNA:FREQuency:SPAN}{<span>, in Hz}
\query{Queries the currently selected span}{VNA:FREQuency:SPAN?}{None}{span in Hz}

\subsubsection{VNA:FREQuency:START}
\event{Sets the start frequency of the sweep}{VNA:FREQuency:START}{<start frequency>, in Hz}
\query{Queries the currently selected start frequency}{VNA:FREQuency:START?}{None}{start frequency in Hz}

\subsubsection{VNA:FREQuency:CENTer}
\event{Sets the center frequency of the sweep}{VNA:FREQuency:CENTer}{<center frequency>, in Hz}
\query{Queries the currently selected center frequency}{VNA:FREQuency:CENTer?}{None}{center frequency in Hz}

\subsubsection{VNA:FREQuency:STOP}
\event{Sets the stop frequency of the sweep}{VNA:FREQuency:STOP}{<stop frequency>, in Hz}
\query{Queries the currently selected stop frequency}{VNA:FREQuency:STOP?}{None}{stop frequency in Hz}

\subsubsection{VNA:FREQuency:FULL}
\event{Sets the device to the maximum span possible}{VNA:FREQuency:FULL}{None}

\subsubsection{VNA:FREQuency:ZERO}
\event{Sets the device to zero span mode}{VNA:FREQuency:ZERO}{None}

\subsubsection{VNA:POWer:START}
\event{Sets the start power of the power sweep}{VNA:POWer:START}{<start power>, in dBm}
\query{Queries the currently selected start power}{VNA:POWer:START?}{None}{start power in dBm}

\subsubsection{VNA:POWer:STOP}
\event{Sets the stop power of the power sweep}{VNA:POWer:STOP}{<stop power>, in dBm}
\query{Queries the currently selected stop power}{VNA:POWer:STOP?}{None}{stop power in dBm}

\subsubsection{VNA:SWEEPTYPE}
\event{Selects between linear and logarithmic sweeps}{VNA:SWEEPTYPE}{<type>, either ``LIN'' or ``LOG''}
\query{Queries the currently selected sweep type}{VNA:SWEEPTYPE?}{None}{``LIN'' or ``LOG''}

\subsubsection{VNA:ACQuisition:RUN}
\event{Puts the VNA into run mode (sweep active)}{VNA:ACQuisition:RUN}{None}
\query{Queries whether the VNA is in run mode}{VNA:ACQuisition:RUN?}{None}{TRUE or FALSE}

\subsubsection{VNA:ACQuisition:STOP}
\event{Puts the VNA into stop mode (sweep inactive)}{VNA:ACQuisition:STOP}{None}

\subsubsection{VNA:ACQuisition:IFBW}
\event{Sets the IF bandwidth}{VNA:ACQuisition:IFBW}{<IF bandwidth>, in Hz}
\query{Queries the currently selected IF bandwidth}{VNA:ACQuisition:IFBW?}{None}{IF bandwidth in Hz}

\subsubsection{VNA:ACQuisition:DWELLtime}
\event{Sets the dwell time}{VNA:ACQuisition:DWELLtime}{<dwell time>, in seconds}
\query{Queries the currently selected dwell time}{VNA:ACQuisition:DWELLtime?}{None}{dwell time in seconds}

\subsubsection{VNA:ACQuisition:POINTS}
\event{Sets the number of points per sweep}{VNA:ACQuisition:POINTS}{<points>}
\query{Queries the currently selected number of points}{VNA:ACQuisition:POINTS?}{None}{points}

\subsubsection{VNA:ACQuisition:AVG}
\event{Sets the number of sweeps over which a moving average is calculated}{VNA:ACQuisition:AVG}{<averaging sweeps>}
\query{Queries the currently configured number of sweeps}{VNA:ACQuisition:AVG?}{None}{<averaging sweeps>}

\subsubsection{VNA:ACQuisition:AVGLEVel}
\query{Queries the number of sweeps that have been acquired by the average function.}{VNA:ACQuisition:AVGLEVel?}{None}{<acquired sweeps>}
<acquired sweeps> resets to zero whenever a setting is changed. It is incremented at the end of each sweep, but will not go above the number of configured sweeps for the averaging.

Example (assuming <averaging sweep> = 3):
\begin{longtable}{p{.2\textwidth} | p{.2\textwidth} }
\textbf{\# of active sweep} & \textbf{<acquired sweeps>}\\
\hline
1 & 0\\
2 & 1\\
3 & 2\\
4 & 3\\
5 & 3\\
\end{longtable}

\subsubsection{VNA:ACQuisition:FINished}
\query{Queries whether the average filter has reached a steady state (that is <acquired sweeps> = <averaging sweeps>)}{VNA:ACQuisition:FINished?}{None}{TRUE or FALSE}

\subsubsection{VNA:ACQuisition:LIMit}
\query{Queries the status of limits that maybe set up on any graph}{VNA:ACQuisition:LIMit?}{None}{PASS or FAIL}

\subsubsection{VNA:ACQuisition:SINGLE}
\event{Configures the VNA for single or continuous sweep}{VNA:ACQuisition:SINGLE}{TRUE or FALSE}
\query{Queries whether the VNA is set up for single sweep}{VNA:ACQuisition:SINGLE?}{None}{TRUE or FALSE}

If single sweep is enabled, the acquisition is stopped when the required number of averages have been reached. There are two ways to trigger a new sweep:
\begin{itemize}
\item Change any sweep setting (e.g. center frequency)
\item Issue the command again (i.e. VNA:ACQ:SINGLE TRUE always triggers a new sweep)
\end{itemize}

\subsubsection{VNA:ACQuisition:FREQuency}
\query{Returns the current frequency of the sweep}{VNA:ACQuisition:FREQuency?}{None}{<Frequency in Hz>}

This command only returns valid data when a sweep is running and the the sweep is a frequency sweep.

\subsubsection{VNA:ACQuisition:POWer}
\query{Returns the current power of the sweep}{VNA:ACQuisition:POWer?}{None}{<Power in dBm>}

This command only returns valid data when a sweep is running and the the sweep is a power sweep.

\subsubsection{VNA:ACQuisition:TIME}
\query{Returns the current time of the sweep}{VNA:ACQuisition:TIME?}{None}{<Time in seconds>}

This command only returns valid data when a sweep is running and the the sweep is a zero-span sweep.

\subsubsection{VNA:STIMulus:LVL}
\event{Sets the output power of the stimulus signal when sweep type is frequency}{VNA:STIMulus:LVL}{<power>, in dBm}
\query{Queries the currently selected output power}{VNA:STIMulus:LVL?}{None}{power in dBm}

\subsubsection{VNA:STIMulus:FREQuency}
\event{Sets the frequency of the stimulus signal when sweep type is power}{VNA:STIMulus:FREQuency}{<freq>, in Hz}
\query{Queries the currently selected frequency}{VNA:STIMulus:FREQuency?}{None}{frequency in Hz}

\subsubsection{VNA:TRACe:LIST}
\query{Lists the names of all available traces}{VNA:TRACe:LIST?}{None}{comma-separated list of trace name}
\begin{example}
VNA:TRAC:LIST?
S11,S12,S21,S22
\end{example}

\subsubsection{VNA:TRACe:DATA}
\query{Returns the data of a trace}{VNA:TRACe:DATA?}{<trace>, either by name or by index}{comma-separated list of tuples [x, real(y), imag(y]}
Depending on the sweep and possible confiigured math operations, x may be either frequency, power or time.
\begin{example}
:VNA:TRAC:DATA? S11
[1e+6,0.400172,0.0377869],
[6.67556e+8,-0.0922281,-0.00990373],
[1.33411e+9,-0.0341439,-0.0331184],
[2.00067e+9,0.00750893,0.0490847],
[2.66722e+9,0.0472666,-0.175552],
[3.33378e+9,-0.106545,-0.00952825],
[4.00033e+9,-0.102039,0.0890605],
[4.66689e+9,0.0464292,0.118183],
[5.33344e+9,0.13223,-0.00780554],
[6e+9,-0.0314859,-0.246024]
\end{example}
\vspace{-0.3cm}
\begin{center}
\footnotesize{Note: actual response will not include newlines between data points, only at the end}
\end{center}

\subsubsection{VNA:TRACe:AT}
\query{Returns the data at a specific frequency (possibly interpolated)}{VNA:TRACe:AT?}{<trace>, either by name or by index\\<frequency>, in Hz}{real,imag (or ``NaN,NaN'' if specified frequeny is invalid)}
\begin{example}
:VNA:TRAC:AT? S11 1200000000
-0.0458452,-0.028729
\end{example}

\subsubsection{VNA:TRACe:TOUCHSTONE}
\query{Returns the content of multiple trace according to the touchstone format}{VNA:TRACe:TOUCHSTONE?}{<trace1>,<trace2>,<trace3>,...}{Touchstone file content in ASCII}
Some additional constraints apply:
\begin{itemize}
\item The number of specified traces must be a square number. The number of ports in the touchstone file is inferred from that.
\item Only frequency domain traces are allowed.
\item All traces must have the same number of points and the same start/stop frequency.
\item The order in which the traces are specified matters and depending on its index and each trace must be a reflection or transmission measurement:
\begin{itemize}
\item Assuming that $n$ is the number of ports of the desired touchstone file, the $n*n$ number of traces must be specified in this order:
$$ S_{11}...S_{1n},S_{21}...S_{2n},...,S_{n1}...S_{nn} $$
\item For every trace $S_{ij}$, the trace must contain a reflection measurement if $i=j$ and a transmission measurement if $i\neq j$.
\end{itemize}
\item Traces can be specified either by name or by index.
\item A deviation from any of these points (invalid number of traces, non-existing trace, wrong order, ...) will result in an error being returned.
\end{itemize}
\begin{example}
:VNA:TRACE:TOUCHSTONE? S11 S12 S21 S22
# GHZ S RI R 50
1.000000000000 1.000497817993 0.010679213330 0.000013886895 -0.000054684886 -0.000023392624 -0.000021111371 0.401717424393 0.702864229679
1.002000000000 1.000323534012 0.010577851906 -0.000011075452 -0.000013504875 0.000000477609 -0.000007789199 0.413144201040 0.696514129639
...
\end{example}

\subsubsection{VNA:TRACe:MAXFrequency}
\query{Returns the highest frequency contained in the trace}{VNA:TRACe:MAXFrequency?}{<trace>, either by name or by index}{maximum frequency in Hz}

\subsubsection{VNA:TRACe:MINFrequency}
\query{Returns the lowest frequency contained in the trace}{VNA:TRACe:MINFrequency?}{<trace>, either by name or by index}{maximum frequency in Hz}

\subsubsection{VNA:TRACe:MAXAmplitude}
\query{Returns the datapoint with the highest amplitude in the trace}{VNA:TRACe:MAXAmplitude?}{<trace>, either by name or by index}{<frequency>,<real>,<imag> of the highest amplitude point}
\begin{example}
:VNA:TRAC:MAXA? S21
5.66406e+9,-6.21766e-5,-0.000795846
\end{example}

\subsubsection{VNA:TRACe:MINAmplitude}
\query{Returns the datapoint with the lowest amplitude in the trace}{VNA:TRACe:MINAmplitude?}{<trace>, either by name or by index}{<frequency>,<real>,<imag> of the lowest amplitude point}

\subsubsection{VNA:TRACe:NEW}
\event{Creates a new trace}{VNA:TRACe:NEW}{<trace name>}

\subsubsection{VNA:TRACe:DELete}
\event{Deletes a trace}{VNA:TRACe:DELete}{<trace>, either by name or by index}

\subsubsection{VNA:TRACe:RENAME}
\event{Changes the name of a trace}{VNA:TRACe:RENAME}{<trace>, either by name or by index\\<new name>}

\subsubsection{VNA:TRACe:PAUSE}
\event{Pauses (freezes) a trace}{VNA:TRACe:PAUSE}{<trace>, either by name or by index}

\subsubsection{VNA:TRACe:RESUME}
\event{Resumes (unfreezes) a trace}{VNA:TRACe:RESUME}{<trace>, either by name or by index}

\subsubsection{VNA:TRACe:PAUSED}
\query{Queries whether a trace is paused}{VNA:TRACe:PAUSED?}{<trace>, either by name or by index}{TRUE or FALSE}

\subsubsection{VNA:TRACe:DEEMBedding:ACTive}
\event{Enables/disables de-embedding on a trace}{VNA:TRACe:DEEMBedding:ACTive}{<trace>, either by name or by index\\<enable>, either TRUE or FALSE}

If no de-embedding is configured for the selected trace, enabling the de-embedding will fail.

\query{Queries whether de-embedding is active for the selected trace}{VNA:TRACe:DEEMBedding:ACTive?}{<trace>, either by name or by index}{TRUE or FALSE}

\subsubsection{VNA:TRACe:DEEMBedding:AVAILable}
\query{Queries whether de-embedding is available for the selected trace}{VNA:TRACe:DEEMBedding:AVAILable?}{<trace>, either by name or by index}{TRUE or FALSE}

\subsubsection{VNA:TRACe:PARAMeter}
\event{Sets the measurement parameter that is stored in the trace}{VNA:TRACe:PARAMeter}{<trace>, either by name or by index\\<parameter>, options are S11, S12, S21 or S22}
\query{Queries the measurement parameter of a trace}{VNA:TRACe:PARAMeter?}{<trace>, either by name or by index}{S11, S12, S21 or S22}

\subsubsection{VNA:TRACe:TYPE}
\event{Sets the storage type of a trace}{VNA:TRACe:TYPE}{<trace>, either by name or by index\\<type>, options are OVERWRITE, MAXHOLD or MINHOLD}
\query{Queries the storage type of a trace}{VNA:TRACe:TYPE?}{<trace>, either by name or by index}{OVERWRITE, MAXHOLD or MINHOLD}

\subsubsection{VNA:CALibration:ACTivate}
\event{Activates a specific calibration. This command fails if the required measurements have not been taken yet}{VNA:CALibration:ACTivate}{<type>}
\query{Queries the currently available calibration types}{VNA:CALibration:ACTivate?}{None}{comma-separated list of available calibration types}

\subsubsection{VNA:CALibration:ACTIVE}
\query{Queries the currently active calibration type}{VNA:CALibration:ACTIVE?}{None}{Currently active calibration type}

\subsubsection{VNA:CALibration:NUMber}
\query{Queries the number of available calibration measurements}{VNA:CALibration:NUMber?}{None}{<number of configured measurements>}

\subsubsection{VNA:CALibration:RESET}
\event{Resets the calibration. Deactivates the calibration and deletes all measurements.}{VNA:CALibration:RESET}{None}

\subsubsection{VNA:CALibration:ADD}
\event{Adds a new empty calibration measurement.}{VNA:CALibration:ADD}{<type> Measurement type, one of:\\
\hspace{1cm}OPEN\\
\hspace{1cm}SHORT\\
\hspace{1cm}LOAD\\
\hspace{1cm}THROUGH\\
\hspace{1cm}ISOLATION\\
\hspace{1cm}SLIDINGLOAD\\
\hspace{1cm}REFLECT\\
\hspace{1cm}LINE\\
{[<standard>]}, calibration kit standard name, optional\\}

\subsubsection{VNA:CALibration:TYPE}
\query{Returns the type of the specified measurement}{VNA:CALibration:TYPE?}{<measurement number>}{Measurement type, one of:\\
\hspace{1cm}OPEN\\
\hspace{1cm}SHORT\\
\hspace{1cm}LOAD\\
\hspace{1cm}THROUGH\\
\hspace{1cm}ISOLATION\\
\hspace{1cm}SLIDINGLOAD\\
\hspace{1cm}REFLECT\\
\hspace{1cm}LINE\\}

\subsubsection{VNA:CALibration:PORT}
\event{Sets the port for the specified measurement}{VNA:CALibration:PORT}{<measurement number> <port number>}
\query{Returns the port for the specified measurement}{VNA:CALibration:PORT?}{<measurement number>}{<port number>}

\subsubsection{VNA:CALibration:STANDARD}
\event{Sets the calibration standard which will be used for the specified measurement}{VNA:CALibration:STANDARD}{<measurement number> <standard name>}
\query{Returns the standard name for the specified measurement}{VNA:CALibration:STANDARD?}{<measurement number>}{Name of used calibration standard (from calibration kit)}

\subsubsection{VNA:CALibration:MEASure}
\event{Starts a calibration measurement. This command fails if no device is connected, the VNA mode is not active or a calibration measurement is already in progress.}{VNA:CALibration:MEASure}{<measurement 1>,<measurement 2>,...}
Any number of measurements can be specified (by their number). These measurements will be taken simultaneously. This only works if they are measuring different ports (e.g. measure SHORT on port 1 and OPEN on port 2). If colliding measurements are specified (e.g. SHORT on port 1 and LOAD on port 1), an error is returned and no measurements are started.

\subsubsection{VNA:CALibration:BUSY}
\query{Queries whether a calibration measurement is ongoing}{VNA:CALibration:BUSY?}{None}{TRUE or FALSE}

\subsubsection{VNA:CALibration:SAVE}
\event{Saves the active calibration to a file}{VNA:CALibration:SAVE}{<filename>}
Important points when saving/loading calibration files through SCPI commands:
\begin{itemize}
\item Filenames must be either absolute or relative to the location of the GUI application.
\item If the LibreVNA-GUI (and thus also the SCPI server) is running on a different machine than the SCPI client, the calibration files will be saved/loaded from the machine that runs the GUI.
\end{itemize}

\subsubsection{VNA:CALibration:LOAD}
\query{Loads a calibration file}{VNA:CALibration:LOAD?}{<filename>}{TRUE or FALSE}

\subsubsection{VNA:CALibration:KIT:MANufacturer}
\event{Sets the manufacturer name of the calibration kit}{VNA:CALibration:KIT:MANufacturer}{<manufacturer>}
\query{Returns the manufacturer name of the calibration kit}{VNA:CALibration:KIT:MANufacturer?}{None}{<manufacturer>}

\subsubsection{VNA:CALibration:KIT:SERial}
\event{Sets the serial number of the calibration kit}{VNA:CALibration:KIT:SERial}{<serial number>}
\query{Returns the serial number of the calibration kit}{VNA:CALibration:KIT:SERial?}{None}{<serial number>}

\subsubsection{VNA:CALibration:KIT:DESCription}
\event{Sets the description of the calibration kit}{VNA:CALibration:KIT:DESCription}{<description>}
\query{Returns the description of the calibration kit}{VNA:CALibration:KIT:DESCription?}{None}{<description>}

\subsubsection{VNA:CALibration:KIT:FILEname}
\query{Returns the filename of the calibration kit}{VNA:CALibration:KIT:FILEname?}{None}{<filename>}

The filename is only available if the calibration kit was loaded from a dedicated file. If it was loaded as part of a calibration file or has not been loaded since the GUI started, no filename will be returned.

\subsubsection{VNA:CALibration:KIT:SAVE}
\event{Saves the active calibration kit to a file}{VNA:CALibration:KIT:SAVE}{<filename>}
Important points when saving/loading calibration kit files through SCPI commands:
\begin{itemize}
\item Filenames must be either absolute or relative to the location of the GUI application.
\item If the LibreVNA-GUI (and thus also the SCPI server) is running on a different machine than the SCPI client, the calibration kit files will be saved/loaded from the machine that runs the GUI.
\end{itemize}

\subsubsection{VNA:CALibration:KIT:LOAD}
\query{Loads a calibration kit file}{VNA:CALibration:KIT:LOAD?}{<filename>}{TRUE or FALSE}

\subsubsection{Common calibration kit standards commands}
The calibration kit supports an arbitrary amount of standards. This requires a flexible SCPI API which adjusts to the currently configured standards.

A few calibration kit standard commands are always available and they can be used to create and delete calibration standards. Every created calibration standard adds their own commands. They can be accessed by including the calibration standard number in the command (shown as ``x'' in the following commands).

\subsubsubsection{VNA:CALibration:KIT:STAndard:CLEAR}
\event{Resets the calibration kit to default values (ideal standards)}{VNA:CALibration:KIT:STAndard:CLEAR}{None}

\subsubsubsection{VNA:CALibration:KIT:STAndard:NUMber}
\query{Returns the number of configured calibration standards}{VNA:CALibration:KIT:STAndard:NUMber?}{None}{<number of calibration standards>}

\subsubsubsection{VNA:CALibration:KIT:STAndard:TYPE}
\query{Returns the type of a created calibration standard}{VNA:CALibration:KIT:STAndard:TYPE?}{<x> Number of calibration standard}{Type of standard, one of:\\
\hspace{1cm}Open\\
\hspace{1cm}Short\\
\hspace{1cm}Load\\
\hspace{1cm}Reflect\\
\hspace{1cm}Through\\
\hspace{1cm}Line\\}

\subsubsubsection{VNA:CALibration:KIT:STAndard:NEW}
\event{Adds a new calibration standard}{VNA:CALibration:KIT:STAndard:NEW}{<type> Type of calibration standard, one of:\\
\hspace{1cm}Open\\
\hspace{1cm}Short\\
\hspace{1cm}Load\\
\hspace{1cm}Reflect\\
\hspace{1cm}Through\\
\hspace{1cm}Line\\
<name> User selectable name of new standard}

\subsubsubsection{VNA:CALibration:KIT:STAndard:DELete}
\event{Removes a calibration standard}{VNA:CALibration:KIT:STAndard:DELete}{<x> Number of standard to delete}

\subsubsection{OPEN standard commands}
The following commands are only valid for a calibration standard of type ``Open''. The ``x'' in the command names must be replaced with the calibration standard number.

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:NAME}
\event{Sets the name of the standard}{VNA:CALibration:KIT:STAndard:x:NAME}{<name> User selectable name}
\query{Queries the name of the standard}{VNA:CALibration:KIT:STAndard:x:NAME?}{None}{<name> User selectable name}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:Z0}
\event{Sets the characteristic impedance of the standard}{VNA:CALibration:KIT:STAndard:x:Z0}{<Z> Characteristic impedance in Ohm}
\query{Queries the characteristic impedance of the standard}{VNA:CALibration:KIT:STAndard:x:Z0?}{None}{<Z> Characteristic impedance in Ohm}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:DELAY}
\event{Sets the delay of the standard}{VNA:CALibration:KIT:STAndard:x:DELAY}{<delay> Delay in \unit{\pico\second}}
\query{Queries the delay of the standard}{VNA:CALibration:KIT:STAndard:x:DELAY?}{None}{<delay> Delay in \unit{\pico\second}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:LOSS}
\event{Sets the loss of the standard}{VNA:CALibration:KIT:STAndard:x:LOSS}{<loss> Loss in \unit{\giga\ohm\per\second}}
\query{Queries the loss of the standard}{VNA:CALibration:KIT:STAndard:x:LOSS?}{None}{<loss> Loss in \unit{\giga\ohm\per\second}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:C0}
\event{Sets the fringing capacitance polynom term 0 of the standard}{VNA:CALibration:KIT:STAndard:x:C0}{<C0> in \num{d-15}\unit{\farad}}
\query{Queries the fringing capacitance polynom term 0 of the standard}{VNA:CALibration:KIT:STAndard:x:C0?}{None}{<C0> in \num{d-15}\unit{\farad}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:C1}
\event{Sets the fringing capacitance polynom term 1 of the standard}{VNA:CALibration:KIT:STAndard:x:C1}{<C1> in \num{d-27}\unit{\farad\per\hertz}}
\query{Queries the fringing capacitance polynom term 1 of the standard}{VNA:CALibration:KIT:STAndard:x:C1?}{None}{<C1> in \num{d-27}\unit{\farad\per\hertz}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:C2}
\event{Sets the fringing capacitance polynom term 2 of the standard}{VNA:CALibration:KIT:STAndard:x:C2}{<C2> in \num{d-36}\unit{\farad\per\hertz\squared}}
\query{Queries the fringing capacitance polynom term 2 of the standard}{VNA:CALibration:KIT:STAndard:x:C2?}{None}{<C2> in \num{d-36}\unit{\farad\per\hertz\squared}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:C3}
\event{Sets the fringing capacitance polynom term 3 of the standard}{VNA:CALibration:KIT:STAndard:x:C3}{<C3> in \num{d-45}\unit{\farad\per\hertz\cubed}}
\query{Queries the fringing capacitance polynom term 3 of the standard}{VNA:CALibration:KIT:STAndard:x:C3?}{None}{<C3> in \num{d-45}\unit{\farad\per\hertz\cubed}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:FILE}
\event{Loads the coefficients for the calibration standard from a touchstone file}{VNA:CALibration:KIT:STAndard:x:FILE}{<filename>\\<port> sets the port from the file which is used to define the standard, optional}

\subsubsection{SHORT standard commands}
The following commands are only valid for a calibration standard of type ``Short''. The ``x'' in the command names must be replaced with the calibration standard number.

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:NAME}
\event{Sets the name of the standard}{VNA:CALibration:KIT:STAndard:x:NAME}{<name> User selectable name}
\query{Queries the name of the standard}{VNA:CALibration:KIT:STAndard:x:NAME?}{None}{<name> User selectable name}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:Z0}
\event{Sets the characteristic impedance of the standard}{VNA:CALibration:KIT:STAndard:x:Z0}{<Z> Characteristic impedance in Ohm}
\query{Queries the characteristic impedance of the standard}{VNA:CALibration:KIT:STAndard:x:Z0?}{None}{<Z> Characteristic impedance in Ohm}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:DELAY}
\event{Sets the delay of the standard}{VNA:CALibration:KIT:STAndard:x:DELAY}{<delay> Delay in \unit{\pico\second}}
\query{Queries the delay of the standard}{VNA:CALibration:KIT:STAndard:x:DELAY?}{None}{<delay> Delay in \unit{\pico\second}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:LOSS}
\event{Sets the loss of the standard}{VNA:CALibration:KIT:STAndard:x:LOSS}{<loss> Loss in \unit{\giga\ohm\per\second}}
\query{Queries the loss of the standard}{VNA:CALibration:KIT:STAndard:x:LOSS?}{None}{<loss> Loss in \unit{\giga\ohm\per\second}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:L0}
\event{Sets the residual inductance polynom term 0 of the standard}{VNA:CALibration:KIT:STAndard:x:L0}{<L0> in \num{d-12}\unit{\henry}}
\query{Queries the residual inductance polynom term 0 of the standard}{VNA:CALibration:KIT:STAndard:x:L0?}{None}{<L0> in \num{d-12}\unit{\henry}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:L1}
\event{Sets the residual inductance polynom term 1 of the standard}{VNA:CALibration:KIT:STAndard:x:L1}{<L1> in \num{d-24}\unit{\henry\per\hertz}}
\query{Queries the residual inductance polynom term 1 of the standard}{VNA:CALibration:KIT:STAndard:x:L1?}{None}{<L1> in \num{d-24}\unit{\henry\per\hertz}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:L2}
\event{Sets the residual inductance polynom term 2 of the standard}{VNA:CALibration:KIT:STAndard:x:L2}{<L2> in \num{d-33}\unit{\henry\per\hertz\squared}}
\query{Queries the residual inductance polynom term 2 of the standard}{VNA:CALibration:KIT:STAndard:x:L2?}{None}{<L2> in \num{d-33}\unit{\henry\per\hertz\squared}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:L3}
\event{Sets the residual inductance polynom term 3 of the standard}{VNA:CALibration:KIT:STAndard:x:L3}{<L3> in \num{d-42}\unit{\henry\per\hertz\cubed}}
\query{Queries the residual inductance polynom term 3 of the standard}{VNA:CALibration:KIT:STAndard:x:L3?}{None}{<L3> in \num{d-42}\unit{\henry\per\hertz\cubed}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:FILE}
\event{Loads the coefficients for the calibration standard from a touchstone file}{VNA:CALibration:KIT:STAndard:x:FILE}{<filename>\\<port> sets the port from the file which is used to define the standard, optional}

\subsubsection{LOAD standard commands}
The following commands are only valid for a calibration standard of type ``Load''. The ``x'' in the command names must be replaced with the calibration standard number.

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:NAME}
\event{Sets the name of the standard}{VNA:CALibration:KIT:STAndard:x:NAME}{<name> User selectable name}
\query{Queries the name of the standard}{VNA:CALibration:KIT:STAndard:x:NAME?}{None}{<name> User selectable name}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:RESistance}
\event{Sets the resistance of the standard}{VNA:CALibration:KIT:STAndard:x:RESistance}{<R> in \unit{\ohm}}
\query{Queries the resistance of the standard}{VNA:CALibration:KIT:STAndard:x:RESistance?}{None}{<R> in \unit{\ohm}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:Z0}
\event{Sets the characteristic impedance of the standard}{VNA:CALibration:KIT:STAndard:x:Z0}{<Z> Characteristic impedance in Ohm}
\query{Queries the characteristic impedance of the standard}{VNA:CALibration:KIT:STAndard:x:Z0?}{None}{<Z> Characteristic impedance in Ohm}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:DELAY}
\event{Sets the delay of the standard}{VNA:CALibration:KIT:STAndard:x:DELAY}{<delay> Delay in \unit{\pico\second}}
\query{Queries the delay of the standard}{VNA:CALibration:KIT:STAndard:x:DELAY?}{None}{<delay> Delay in \unit{\pico\second}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:LOSS}
\event{Sets the loss of the standard}{VNA:CALibration:KIT:STAndard:x:LOSS}{<loss> Loss in \unit{\giga\ohm\per\second}}
\query{Queries the loss of the standard}{VNA:CALibration:KIT:STAndard:x:LOSS?}{None}{<loss> Loss in \unit{\giga\ohm\per\second}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:CARallel}
\event{Sets the residual capacitance polynom of the standard}{VNA:CALibration:KIT:STAndard:x:CARallel}{<C> in \unit{\farad}}
\query{Queries the residual capacitance of the standard}{VNA:CALibration:KIT:STAndard:x:CARallel?}{None}{<C> in \unit{\farad}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:LSERies}
\event{Sets the residual inductance of the standard}{VNA:CALibration:KIT:STAndard:x:LSERies}{<L> in \unit{\henry}}
\query{Queries the residual inductance of the standard}{VNA:CALibration:KIT:STAndard:x:LSERies?}{None}{<L> in \unit{\henry}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:CFIRST}
\event{Sets the order of residual capacitance/inductance}{VNA:CALibration:KIT:STAndard:x:CFIRST}{TRUE or FALSE}
\query{Queries the order of residual capacitance/inductance}{VNA:CALibration:KIT:STAndard:x:CFIRST?}{None}{TRUE or FALSE}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:FILE}
\event{Loads the coefficients for the calibration standard from a touchstone file}{VNA:CALibration:KIT:STAndard:x:FILE}{<filename>\\<port> sets the port from the file which is used to define the standard, optional}

\subsubsection{REFLECT standard commands}
The following commands are only valid for a calibration standard of type ``Reflect''. The ``x'' in the command names must be replaced with the calibration standard number.

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:NAME}
\event{Sets the name of the standard}{VNA:CALibration:KIT:STAndard:x:NAME}{<name> User selectable name}
\query{Queries the name of the standard}{VNA:CALibration:KIT:STAndard:x:NAME?}{None}{<name> User selectable name}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:SHORT}
\event{Sets the type of reflection standard}{VNA:CALibration:KIT:STAndard:x:SHORT}{TRUE for short standard or FALSE for open standard}
\query{Queries the type of reflection standard}{VNA:CALibration:KIT:STAndard:x:SHORT?}{None}{TRUE for short standard or FALSE for open standard}

\subsubsection{THROUGH standard commands}
The following commands are only valid for a calibration standard of type ``Through''. The ``x'' in the command names must be replaced with the calibration standard number.

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:NAME}
\event{Sets the name of the standard}{VNA:CALibration:KIT:STAndard:x:NAME}{<name> User selectable name}
\query{Queries the name of the standard}{VNA:CALibration:KIT:STAndard:x:NAME?}{None}{<name> User selectable name}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:Z0}
\event{Sets the characteristic impedance of the standard}{VNA:CALibration:KIT:STAndard:x:Z0}{<Z> Characteristic impedance in Ohm}
\query{Queries the characteristic impedance of the standard}{VNA:CALibration:KIT:STAndard:x:Z0?}{None}{<Z> Characteristic impedance in Ohm}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:DELAY}
\event{Sets the delay of the standard}{VNA:CALibration:KIT:STAndard:x:DELAY}{<delay> Delay in \unit{\pico\second}}
\query{Queries the delay of the standard}{VNA:CALibration:KIT:STAndard:x:DELAY?}{None}{<delay> Delay in \unit{\pico\second}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:LOSS}
\event{Sets the loss of the standard}{VNA:CALibration:KIT:STAndard:x:LOSS}{<loss> Loss in \unit{\giga\ohm\per\second}}
\query{Queries the loss of the standard}{VNA:CALibration:KIT:STAndard:x:LOSS?}{None}{<loss> Loss in \unit{\giga\ohm\per\second}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:FILE}
\event{Loads the coefficients for the calibration standard from a touchstone file}{VNA:CALibration:KIT:STAndard:x:FILE}{<filename>\\
<port1> selects the first port from the file which is used to define the standard\\
<port1> selects the second port from the file which is used to define the standard}

\subsubsection{LINE standard commands}
The following commands are only valid for a calibration standard of type ``Line''. The ``x'' in the command names must be replaced with the calibration standard number.

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:NAME}
\event{Sets the name of the standard}{VNA:CALibration:KIT:STAndard:x:NAME}{<name> User selectable name}
\query{Queries the name of the standard}{VNA:CALibration:KIT:STAndard:x:NAME?}{None}{<name> User selectable name}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:Z0}
\event{Sets the characteristic impedance of the standard}{VNA:CALibration:KIT:STAndard:x:Z0}{<Z> Characteristic impedance in Ohm}
\query{Queries the characteristic impedance of the standard}{VNA:CALibration:KIT:STAndard:x:Z0?}{None}{<Z> Characteristic impedance in Ohm}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:DELAY}
\event{Sets the delay of the standard}{VNA:CALibration:KIT:STAndard:x:DELAY}{<delay> Delay in \unit{\pico\second}}
\query{Queries the delay of the standard}{VNA:CALibration:KIT:STAndard:x:DELAY?}{None}{<delay> Delay in \unit{\pico\second}}

\subsubsubsection{VNA:CALibration:KIT:STAndard:x:FILE}
\event{Loads the coefficients for the calibration standard from a touchstone file}{VNA:CALibration:KIT:STAndard:x:FILE}{<filename>\\
<port1> selects the first port from the file which is used to define the standard\\
<port1> selects the second port from the file which is used to define the standard}

\subsubsection{Common Deembedding Commands}
The VNA supports various deembedding options which can also be configured through the SCPI API. Because the deembedding system is flexible and supports any number of deembedding options at the same time, the SCPI API is also flexible. Instead of fixed commands, the available commands change depending on the configured deembedding options.

A few deembedding commands are always available and they can be used to create, delete and swap deembedding options. Every created deembedding option adds their own commands. They can be accessed by including the option number in the command (shown as ``x'' in the following commands).

\subsubsubsection{VNA:DEEMBedding:NUMber}
\query{Returns the number of configured deembedding options}{VNA:DEEMBedding:NUMber?}{None}{<number of deembedding options>}

\subsubsubsection{VNA:DEEMBedding:TYPE}
\query{Returns the type of a configured deembedding option}{VNA:DEEMBedding:TYPE?}{<x> Number of deembedding option}{Type of option, one of:\\
\hspace{1cm}Port\_Extension\\
\hspace{1cm}2xThru\\
\hspace{1cm}Matching\_Network\\
\hspace{1cm}Impedance\_Renormalization\\}

\subsubsubsection{VNA:DEEMBedding:NEW}
\event{Adds a new deembedding option}{VNA:DEEMBedding:NEW}{<type> Type of option, one of:\\
\hspace{1cm}Port\_Extension\\
\hspace{1cm}2xThru\\
\hspace{1cm}Matching\_Network\\
\hspace{1cm}Impedance\_Renormalization\\}

\subsubsubsection{VNA:DEEMBedding:DELete}
\event{Removes a deembedding option}{VNA:DEEMBedding:DELete}{<x> Number of option to delete}

\subsubsubsection{VNA:DEEMBedding:SWAP}
\event{Swaps the order of two deembedding options}{VNA:DEEMBedding:SWAP}{<x1> Number of option 1 to swap\\<x2> Number of option 2 to swap}

\subsubsubsection{VNA:DEEMBedding:CLEAR}
\event{Delete all deembedding options}{VNA:DEEMBedding:CLEAR}{None}

\subsubsection{Port Extension Deembedding Commands}
The following commands are only valid for a deembedding option of type ``Port\_Extension''. The ``x'' in the command names must be replaced with the option number.

\subsubsubsection{VNA:DEEMBedding:x:PORT}
\event{Sets the port}{VNA:DEEMBedding:x:PORT}{<port>, 1...n}
\query{Queries the selected port}{VNA:DEEMBedding:x:PORT?}{None}{<port>, 1...n}

\subsubsubsection{VNA:DEEMBedding:x:DELAY}
\event{Sets the delay of the port extension}{VNA:DEEMBedding:x:DELAY}{<delay> Delay in seconds}
\query{Queries the delay of the port extension}{VNA:DEEMBedding:x:DELAY?}{None}{<delay> Delay in seconds}

\subsubsubsection{VNA:DEEMBedding:x:DCLOSS}
\event{Sets the DC loss of the port extension}{VNA:DEEMBedding:x:DCLOSS}{<loss> Loss at DC in dB}
\query{Queries the DC loss of the port extension}{VNA:DEEMBedding:x:DCLOSS?}{None}{<loss> Loss at DC in dB}

\subsubsubsection{VNA:DEEMBedding:x:LOSS}
\event{Sets the loss of the port extension at the configured frequency}{VNA:DEEMBedding:x:LOSS}{<loss> Loss at frequency in dB}
\query{Queries the loss of the port extension at the configured frequency}{VNA:DEEMBedding:x:LOSS?}{None}{<loss> Loss at frequency in dB}

\subsubsubsection{VNA:DEEMBedding:x:FREQuency}
\event{Sets the frequency for the specified loss of the port extension}{VNA:DEEMBedding:x:FREQuency}{<freq> Frequency for loss in Hz}
\query{Queries the frequency for the specified loss of the port extension}{VNA:DEEMBedding:x:FREQuency?}{None}{<freq> Frequency for loss in Hz}

\subsubsection{2xThru Deembedding Commands}
The 2xThru deembedding does not have a SCPI API so far because it requires the user to manually make specific connections and take additional measurements.

\subsubsection{Matching Network Deembedding Commands}
The following commands are only valid for a deembedding option of type ``Matching\_Network''. The ``x'' in the command names must be replaced with the option number.

Similarly to the deembedding options, the matching network itself is also flexible and requires a flexible API as well. A similar approach is used where components in the matching network are given a number. This number is shown as ``y'' in the following commands.

\subsubsubsection{VNA:DEEMBedding:x:PORT}
\event{Sets the port at which the matching network is added}{VNA:DEEMBedding:x:PORT}{<port>, 1...n}
\query{Queries the port at which the matching network is added}{VNA:DEEMBedding:x:PORT?}{None}{<port>, 1...n}

\subsubsubsection{VNA:DEEMBedding:x:ADD}
\event{Selects whether the network is added or removed during the deembedding}{VNA:DEEMBedding:x:ADD}{TRUE if the effect of the network should be added. FALSE if the effect of the\\
\hspace{1cm}network should be subtracted}
\query{Queries whether the network is added or removed during the deembedding}{VNA:DEEMBedding:x:ADD?}{None}{TRUE or FALSE}

\subsubsubsection{VNA:DEEMBedding:x:NUMber}
\query{Returns the number of configured matching network components}{VNA:DEEMBedding:x:NUMber?}{None}{<number of matching network components>}

\subsubsubsection{VNA:DEEMBedding:x:TYPE}
\query{Returns the type of a configured matching network component}{VNA:DEEMBedding:x:TYPE? <y>}{<y> Number of matching component}{Type of component, one of:\\
\hspace{1cm}SeriesR\\
\hspace{1cm}SeriesL\\
\hspace{1cm}SeriesC\\
\hspace{1cm}ParallelR\\
\hspace{1cm}ParallelL\\
\hspace{1cm}ParallelC\\
\hspace{1cm}Touchstone\_Through\\
\hspace{1cm}Touchstone\_Shunt\\}

\subsubsubsection{VNA:DEEMBedding:x:NEW}
\event{Adds a new matching network component}{VNA:DEEMBedding:x:NEW}{<type> Type of component, one of:\\
\hspace{1cm}SeriesR\\
\hspace{1cm}SeriesL\\
\hspace{1cm}SeriesC\\
\hspace{1cm}ParallelR\\
\hspace{1cm}ParallelL\\
\hspace{1cm}ParallelC\\
\hspace{1cm}Touchstone\_Through\\
\hspace{1cm}Touchstone\_Shunt\\
<pos> position at which the component will be added. A value of 0 adds the\\
\hspace{1cm}component closest to the port. This parameter is optional. If it is omitted,\\
\hspace{1cm}the component is added closest to the DUT}

\subsubsubsection{VNA:DEEMBedding:x:DELete}
\event{Removes a matching network component}{VNA:DEEMBedding:x:DELete}{<y> Number of component to delete}

\subsubsubsection{VNA:DEEMBedding:x:CLEAR}
\event{Removes all matching network components}{VNA:DEEMBedding:x:DELete}{None}

\subsubsection{Impedance Renormalization Deembedding Commands}
The following commands are only valid for a deembedding option of type ``Impedance\_Renormalization''. The ``x'' in the command names must be replaced with the option number.

\subsubsubsection{VNA:DEEMBedding:x:IMPedance}
\event{Sets the target impedance}{VNA:DEEMBedding:x:IMPedance}{<impedance> Impedance in Ohm}
\query{Queries the target impedance}{VNA:DEEMBedding:x:IMPedance?}{None}{<impedance> Impedance in Ohm}

\subsubsubsection{VNA:DEEMBedding:x:y:VALue}
\event{Sets the value of a matching network component}{VNA:DEEMBedding:x:y:VALue}{<value>, either in Ohm, Farad or Henry}
\query{Queries the value of a matching network component}{VNA:DEEMBedding:x:y:VALue?}{None}{<port>, either in Ohm, Farad or Henry}

This command is only available for a component of these types:
\begin{itemize}
\item SeriesR
\item SeriesL
\item SeriesC
\item ParallelR
\item ParallelL
\item ParallelC
\end{itemize}

\subsubsubsection{VNA:DEEMBedding:x:y:FILE}
\event{Loads a matching network component values from a Touchstone file}{VNA:DEEMBedding:x:y:FILE}{<filename>}

This command is only available for a component of these types:
\begin{itemize}
\item Touchstone\_Through
\item Touchstone\_Shunt
\end{itemize}

\subsection{Signal Generator Commands}
These commands change or query signal generator settings. Although most of them are available regardless of the current device mode, they usually only have an effect once the generator mode is active.

\subsubsection{GENerator:FREQuency}
\event{Sets the output frequeny}{GENerator:FREQuency}{<frequency>, in Hz}
\query{Queries the selected output frequency}{GENerator:FREQuency?}{None}{frequency in Hz}

\subsubsection{GENerator:LVL}
\event{Sets the output power}{GENerator:LVL}{<output level>, in dBm}
\query{Queries the selected output power}{GENerator:LVL?}{None}{output level in dBm}

\subsubsection{GENerator:PORT}
\event{Sets the active output port}{GENerator:PORT}{<output port>\\
\hspace{1cm}0: output disabled\\
\hspace{1cm}1: output signal at port 1\\
\hspace{1cm}2: output signal at port 2\\}
\query{Queries the selected output}{GENerator:PORT?}{None}{output port}

\subsection{Spectrum Analyzer Commands}
These commands change or query spectrum analyzer settings. Although most of them are available regardless of the current device mode, they usually only have an effect once the spectrum analyzer mode is active.

\subsubsection{SA:FREQuency:SPAN}
\event{Sets the span of the sweep}{SA:FREQuency:SPAN}{<span>, in Hz}
\query{Queries the currently selected span}{SA:FREQuency:SPAN?}{None}{span in Hz}

\subsubsection{SA:FREQuency:START}
\event{Sets the start frequency of the sweep}{SA:FREQuency:START}{<start frequency>, in Hz}
\query{Queries the currently selected start frequency}{SA:FREQuency:START?}{None}{start frequency in Hz}

\subsubsection{SA:FREQuency:CENTer}
\event{Sets the center frequency of the sweep}{SA:FREQuency:CENTer}{<center frequency>, in Hz}
\query{Queries the currently selected center frequency}{SA:FREQuency:CENTer?}{None}{center frequency in Hz}

\subsubsection{SA:FREQuency:STOP}
\event{Sets the stop frequency of the sweep}{SA:FREQuency:STOP}{<stop frequency>, in Hz}
\query{Queries the currently selected stop frequency}{SA:FREQuency:STOP?}{None}{stop frequency in Hz}

\subsubsection{SA:FREQuency:FULL}
\event{Sets the device to the maximum span possible}{SA:FREQuency:FULL}{None}

\subsubsection{SA:FREQuency:ZERO}
\event{Sets the device to zero span mode}{SA:FREQuency:ZERO}{None}

\subsubsection{SA:ACQuisition:RUN}
\event{Puts the spectrum analyzer into run mode (sweep active)}{SA:ACQuisition:RUN}{None}
\query{Queries whether the spectrum analyzer is in run mode}{SA:ACQuisition:RUN?}{None}{TRUE or FALSE}

\subsubsection{SA:ACQuisition:STOP}
\event{Puts the spectrum analyzer into stop mode (sweep inactive)}{SA:ACQuisition:STOP}{None}

\subsubsection{SA:ACQuisition:RBW}
\event{Sets the resolution bandwidth}{SA:ACQuisition:IFBW}{<resolution bandwidth>, in Hz}
\query{Queries the currently selected resolution bandwidth}{SA:ACQuisition:IFBW?}{None}{resolution bandwidth in Hz}

\subsubsection{SA:ACQuisition:WINDow}
\event{Sets the type of window used in the acquisition}{SA:ACQuisition:WINDow}{<windowtype>\\
\hspace{1cm}NONE\\
\hspace{1cm}KAISER\\
\hspace{1cm}HANN\\
\hspace{1cm}FLATTOP\\
}
\query{Queries the currently selected type of window}{SA:ACQuisition:WINDow?}{None}{NONE, KAISER, HANN or FLATTOP}

\subsubsection{SA:ACQuisition:DETector}
\event{Sets the detector type}{SA:ACQuisition:DETector}{<detector>\\
\hspace{1cm}+PEAK\\
\hspace{1cm}-PEAK\\
\hspace{1cm}NORMAL\\
\hspace{1cm}SAMPLE\\
\hspace{1cm}AVERAGE\\
}
\query{Queries the currently selected detector type}{SA:ACQuisition:DETector?}{None}{+PEAK, -PEAK, NORMAL, SAMPLE or AVERAGE}

\subsubsection{SA:ACQuisition:AVG}
\event{Sets the number of sweeps over which a moving average is calculated}{SA:ACQuisition:AVG}{<sweeps>}
\query{Queries the currently configured number of sweeps}{SA:ACQuisition:AVG?}{None}{sweeps}

\subsubsection{SA:ACQuisition:AVGLEVel}
\query{Queries the number of sweeps that have been acquired by the average function.}{SA:ACQuisition:AVGLEVel?}{None}{<acquired sweeps>}
<acquired sweeps> resets to zero whenever a setting is changed. It is incremented at the end of each sweep, but will not go above the number of configured sweeps for the averaging.

Example (assuming <averaging sweep> = 3):
\begin{longtable}{p{.2\textwidth} | p{.2\textwidth} }
\textbf{\# of active sweep} & \textbf{<acquired sweeps>}\\
\hline
1 & 0\\
2 & 1\\
3 & 2\\
4 & 3\\
5 & 3\\
\end{longtable}

\subsubsection{SA:ACQuisition:FINished}
\query{Queries whether the average filter has reached a steady state (that is <acquired sweeps> = <averaging sweeps>)}{SA:ACQuisition:FINished?}{None}{TRUE or FALSE}

\subsubsection{SA:ACQuisition:LIMit}
\query{Queries the status of limits that maybe set up on any graph}{SA:ACQuisition:LIMit?}{None}{PASS or FAIL}

\subsubsection{SA:ACQuisition:SINGLE}
\event{Configures the spectrum analyzer for single or continuous sweep}{SA:ACQuisition:SINGLE}{TRUE or FALSE}
\query{Queries whether the spectrum analyzer is set up for single sweep}{SA:ACQuisition:SINGLE?}{None}{TRUE or FALSE}

If single sweep is enabled, the acquisition is stopped when the required number of averages have been reached. There are two ways to trigger a new sweep:
\begin{itemize}
\item Change any sweep setting (e.g. center frequency)
\item Issue the command again (i.e. SA:ACQ:SINGLE TRUE always triggers a new sweep)
\end{itemize}

\subsubsection{SA:ACQuisition:SIGid}
\event{Enables/disables signal identification}{SA:ACQuisition:SIGid}{<enabled>, option are TRUE, FALSE, 1 or 0}
\query{Queries whether signal identification is enabled}{SA:ACQuisition:SIGid?}{None}{TRUE or FALSE}

\subsubsection{SA:ACQuisition:FREQuency}
\query{Returns the current frequency of the sweep}{SA:ACQuisition:FREQuency?}{None}{<Frequency in Hz>}

This command only returns valid data when a sweep is running and the the sweep is a frequency sweep.

\subsubsection{SA:ACQuisition:TIME}
\query{Returns the current time of the sweep}{SA:ACQuisition:TIME?}{None}{<Time in seconds>}

This command only returns valid data when a sweep is running and the the sweep is a zero-span sweep.

\subsubsection{SA:TRACKing:ENable}
\event{Enables/disables the tracking generator}{SA:TRACKing:ENable}{<enabled>, option are TRUE, FALSE, 1 or 0}
\query{Queries whether tracking generator is enabled}{SA:TRACKing:ENable?}{None}{TRUE or FALSE}

\subsubsection{SA:TRACKing:PORT}
\event{Sets the output port of the tracking generator}{SA:TRACKing:PORT}{<port>, either 1 or 2}
\query{Queries the output port of the tracking generator}{SA:TRACKing:PORT?}{None}{1 or 2}

\subsubsection{SA:TRACKing:LVL}
\event{Sets the output power of the tracking generator}{SA:TRACKing:LVL}{<output level>, in dBm}
\query{Queries the selected output power of the tracking generator}{SA:TRACKing:LVL?}{None}{output level in dBm}

\subsubsection{SA:TRACKing:OFFset}
\event{Sets the offset frequency of the tracking generator}{SA:TRACKing:OFFset}{<offset>, in Hz}
\query{Queries the selected offset frequency of the tracking generator}{SA:TRACKing:OFFset?}{None}{offset in Hz}

\subsubsection{SA:TRACKing:NORMalize:ENable}
\event{Enables/disables normalization. If the span has changed since the last active normalization, a normalization measurement is also started.}{SA:TRACKing:NORMalize:ENable}{<enabled>, option are TRUE, FALSE, 1 or 0}
\query{Queries whether tracking generator normalization is enabled}{SA:TRACKing:NORMalize:ENable?}{None}{TRUE or FALSE}

\subsubsection{SA:TRACKing:NORMalize:MEASure}
\event{Triggers a new normalization measurement}{SA:TRACKing:NORMalize:MEASure}{None}

\subsubsection{SA:TRACKing:NORMalize:LVL}
\event{Sets the reference level for the normalization}{SA:TRACKing:NORMalize:LVL}{<normalization level>, in dBm}
\query{Queries the selected reference level for the normalization}{SA:TRACKing:NORMalize:LVL?}{None}{normalization level in dBm}

\subsubsection{SA:TRACe:LIST}
\query{Lists the names of all available traces}{SA:TRACe:LIST?}{None}{comma-separated list of trace name}
\begin{example}
VNA:TRAC:LIST?
Port1,Port2
\end{example}

\subsubsection{SA:TRACe:DATA}
\query{Returns the data of a trace}{SA:TRACe:DATA?}{<trace>, either by name or by index}{comma-separated list of tuples [x, dBm]}
\begin{example}
:SA:TRACE:DATA? PORT1
[9.75e+8,-100.351],
[9.7505e+8,-95.7394],
[9.751e+8,-97.5749],
[9.7515e+8,-96.9667],
[9.752e+8,-96.2391],
[9.7525e+8,-94.8761],
[9.753e+8,-96.0805],
[9.7535e+8,-95.7997],
[9.754e+8,-95.2021],
[9.7545e+8,-96.3472]
\end{example}
\vspace{-0.6cm}
\begin{center}
\footnotesize{Note: actual response will not include newlines between data points, only at the end}\\
\end{center}

\subsubsection{SA:TRACe:AT}
\query{Returns the data at a specific frequency (possibly interpolated)}{SA:TRACe:AT?}{<trace>, either by name or by index\\<frequency>, in Hz}{<dBm> or ``NaN'' if specified frequeny is invalid)}
\begin{example}
:SA:TRAC:AT? Port1 1000000000
-96.424
\end{example}

\subsubsection{SA:TRACe:MAXFrequency}
\query{Returns the highest frequency contained in the trace}{SA:TRACe:MAXFrequency?}{<trace>, either by name or by index}{maximum frequency in Hz}

\subsubsection{SA:TRACe:MINFrequency}
\query{Returns the lowest frequency contained in the trace}{SA:TRACe:MINFrequency?}{<trace>, either by name or by index}{maximum frequency in Hz}

\subsubsection{SA:TRACe:MAXAmplitude}
\query{Returns the datapoint with the highest amplitude in the trace}{SA:TRACe:MAXAmplitude?}{<trace>, either by name or by index}{<frequency>,<dBm> of the highest amplitude point}
\begin{example}
:SA:TRAC:MAXA? Port1
9.63e+8,-12.534
\end{example}

\subsubsection{SA:TRACe:MINAmplitude}
\query{Returns the datapoint with the lowest amplitude in the trace}{SA:TRACe:MINAmplitude?}{<trace>, either by name or by index}{<frequency>,<dBm> of the lowest amplitude point}

\subsubsection{SA:TRACe:NEW}
\event{Creates a new trace}{SA:TRACe:NEW}{<trace name>}

\subsubsection{SA:TRACe:DELete}
\event{Deletes a trace}{VNA:TRACe:DELete}{<trace>, either by name or by index}

\subsubsection{SA:TRACe:RENAME}
\event{Changes the name of a trace}{SA:TRACe:RENAME}{<trace>, either by name or by index\\<new name>}

\subsubsection{SA:TRACe:PAUSE}
\event{Pauses (freezes) a trace}{SA:TRACe:PAUSE}{<trace>, either by name or by index}

\subsubsection{SA:TRACe:RESUME}
\event{Resumes (unfreezes) a trace}{SA:TRACe:RESUME}{<trace>, either by name or by index}

\subsubsection{SA:TRACe:PAUSED}
\query{Queries whether a trace is paused}{SA:TRACe:PAUSED?}{<trace>, either by name or by index}{TRUE or FALSE}

\subsubsection{SA:TRACe:PARAMeter}
\event{Sets the measurement parameter that is stored in the trace}{SA:TRACe:PARAMeter}{<trace>, either by name or by index\\<parameter>, options are PORT1 and PORT2}
\query{Queries the measurement parameter of a trace}{SA:TRACe:PARAMeter?}{<trace>, either by name or by index}{PORT1 or PORT2}

\subsubsection{SA:TRACe:TYPE}
\event{Sets the storage type of a trace}{SA:TRACe:TYPE}{<trace>, either by name or by index\\<type>, options are OVERWRITE, MAXHOLD or MINHOLD}
\query{Queries the storage type of a trace}{SA:TRACe:TYPE?}{<trace>, either by name or by index}{OVERWRITE, MAXHOLD or MINHOLD}

\section{Custom Driver Commands}
The \gui{} is mainly intended to be used with the \vna{}. However, the interface between the \gui{} and the actual VNA is abstracting certain hardware features to allow the \gui{} to interact with other devices as well. This is mainly intended for future extensions and only very few other devices are supported for testing and demonstration purposes.

Each device driver may implement additional SCPI commands that are too specific to be useful with every device. These commands are only available when the \gui{} is connected to the device.

\subsection{LibreVNA Version 1}
The following commands are available when connected to a LibreVNA (hardware version 1):

\subsubsection{DEVice:UPDATE}
\event{Updates the firmware of the connected device}{DEVice:UPDATE <fw\_file>}{<fw\_file> Path to the firmware file}
Important points when saving/loading setup files through SCPI commands:
\begin{itemize}
\item The path must be either absolute or relative to the location of the GUI application.
\item If the LibreVNA-GUI (and thus also the SCPI server) is running on a different machine than the SCPI client, the firmware file must be stored on the machine that runs the GUI.
\end{itemize}

\subsubsection{DEVice:INFo:TEMPeratures}
\query{Queries the temperatures of certain chips}{DEVice:INFo:TEMPeratures?}{None}{<source>/<1.LO>/<CPU>}
\begin{example}
:DEV:INF:TEMP?
45/51/31
\end{example}

\subsubsection{MANual:STArt}
\event{Starts the manual device control dialog}{MANual:STArt}{None}

The manual device control dialog allows the user to directly access all the hardware components. This can be considered as a forth mode (in addition to VNA, signal generator and spectrum analyzer). As long as it is active, it takes priority over any other mode. After starting the manual control dialog, all hardware components are disabled by default. While the manual control dialog is active, additional SCPI commands are available to configure the hardware and retrieve ADC readings.

\subsubsection{MANual:STOp}
\event{Stops the manual device control dialog}{MANual:STOp}{None}

\subsubsection{MANual:HSRC\_CE}
Only available when the manual control dialog is active.

\event{Controls the chip enable for the highband source}{MANual:HSRC\_CE}{TRUE or FALSE}
\query{Queries the status of the chip enable for the highband source}{MANual:HSRC\_CE?}{None}{TRUE or FALSE}

\subsubsection{MANual:HSRC\_RFEN}
Only available when the manual control dialog is active.

\event{Controls the RF enable for the highband source}{MANual:HSRC\_RFEN}{TRUE or FALSE}
\query{Queries the status of the RF enable for the highband source}{MANual:HSRC\_RFEN?}{None}{TRUE or FALSE}

\subsubsection{MANual:HSRC\_LOCKed}
Only available when the manual control dialog is active.

\query{Queries the lock status of the highband source}{MANual:HSRC\_LOCKed?}{None}{TRUE or FALSE}

\subsubsection{MANual:HSRC\_PWR}
Only available when the manual control dialog is active.

\event{Sets the output power of the highband source}{MANual:HSRC\_PWR}{<power>, output power in dBm, allowed values are -4, -1, 2 and 5}
\query{Queries the output power of the highband source}{MANual:HSRC\_PWR?}{None}{<power>, output power in dBm}

\subsubsection{MANual:HSRC\_FREQ}
Only available when the manual control dialog is active.

\event{Sets the target frequency of the highband source}{MANual:HSRC\_FREQ}{<freq>, frequency in Hz}
\query{Queries the target frequency of the highband source}{MANual:HSRC\_FREQ?}{None}{<freq>, frequency in Hz}

\subsubsection{MANual:HSRC\_LPF}
Only available when the manual control dialog is active.

\event{Sets the lowpass filter of the highband source}{MANual:HSRC\_LPF}{<cutoff>, Cutoff frequency in MHz, allowed values are 947, 1880, 3500 and\\0 (no filter)}
\query{Queries the lowpass filter setting of the highband source}{MANual:HSRC\_LPF?}{None}{<cutoff>, Cutoff frequency in MHz}

\subsubsection{MANual:LSRC\_EN}
Only available when the manual control dialog is active.

\event{Controls the enable signal for the lowband source}{MANual:LSRC\_EN}{TRUE or FALSE}
\query{Queries the status of the enable signal for the lowband source}{MANual:LSRC\_EN?}{None}{TRUE or FALSE}

\subsubsection{MANual:LSRC\_PWR}
Only available when the manual control dialog is active.

\event{Sets the output power of the lowband source}{MANual:LSRC\_PWR}{<power>, output power in mA, allowed values are 2, 4, 6 and 8}
\query{Queries the output power of the lowband source}{MANual:LSRC\_PWR?}{None}{<power>, output power in mA}

\subsubsection{MANual:LSRC\_FREQ}
Only available when the manual control dialog is active.

\event{Sets the target frequency of the lowband source}{MANual:LSRC\_FREQ}{<freq>, frequency in Hz}
\query{Queries the target frequency of the lowband source}{MANual:LSRC\_FREQ?}{None}{<freq>, frequency in Hz}

\subsubsection{MANual:BAND\_SW}
Only available when the manual control dialog is active.

\event{Controls the band selector switch}{MANual:BAND\_SW}{TRUE for highband, FALSE for lowband}
\query{Queries the status of the band selector switch}{MANual:BAND\_SW?}{None}{TRUE for highband, FALSE for lowband}

\subsubsection{MANual:ATTenuator}
Only available when the manual control dialog is active.

\event{Sets the attenuator value}{MANual:ATTenuator}{<att>, Attenuation in dB, values between -31.75 and 0}
\query{Queries the attenuator value}{MANual:ATTenuator?}{None}{<att>, Attenuation in dB}

\subsubsection{MANual:AMP\_EN}
Only available when the manual control dialog is active.

\event{Controls the enable signal for the amplifier}{MANual:AMP\_EN}{TRUE or FALSE}
\query{Queries the status of the enable signal for the amplifier}{MANual:AMP\_EN?}{None}{TRUE or FALSE}

\subsubsection{MANual:PORT\_SW}
Only available when the manual control dialog is active.

\event{Controls the port selector switch}{MANual:PORT\_SW}{<port>, either 1 or 2}
\query{Queries the status of the port selector switch}{MANual:PORT\_SW?}{None}{<port>}

\subsubsection{MANual:LO1\_CE}
Only available when the manual control dialog is active.

\event{Controls the chip enable for the LO1 PLL}{MANual:LO1\_CE}{TRUE or FALSE}
\query{Queries the status of the chip enable for the LO1 PLL}{MANual:LO1\_CE?}{None}{TRUE or FALSE}

\subsubsection{MANual:LO1\_RFEN}
Only available when the manual control dialog is active.

\event{Controls the RF enable for the LO1 PLL}{MANual:LO1\_RFEN}{TRUE or FALSE}
\query{Queries the status of the RF enable for the LO1 PLL}{MANual:LO1\_RFEN?}{None}{TRUE or FALSE}

\subsubsection{MANual:LO1\_LOCKed}
Only available when the manual control dialog is active.

\query{Queries the lock status of the LO1 PLL}{MANual:LO1\_LOCKed?}{None}{TRUE or FALSE}

\subsubsection{MANual:LO1\_FREQ}
Only available when the manual control dialog is active.

\event{Sets the target frequency of the LO1 PLL}{MANual:LO1\_FREQ}{<freq>, frequency in Hz}
\query{Queries the target frequency of the LO1 PLL}{MANual:LO1\_FREQ?}{None}{<freq>, frequency in Hz}

\subsubsection{MANual:IF1\_FREQ}
Only available when the manual control dialog is active.

\event{Sets the IF1 frequency}{MANual:IF1\_FREQ}{<freq>, frequency in Hz}
\query{Queries the IF1 frequency}{MANual:IF1\_FREQ?}{None}{<freq>, frequency in Hz}

\subsubsection{MANual:LO2\_EN}
Only available when the manual control dialog is active.

\event{Controls the enable signal for the LO2 PLL}{MANual:LO2\_EN}{TRUE or FALSE}
\query{Queries the status of the enable signal for the LO2 PLL}{MANual:LO2\_EN?}{None}{TRUE or FALSE}

\subsubsection{MANual:LO2\_FREQ}
Only available when the manual control dialog is active.

\event{Sets the target frequency of the LO2 PLL}{MANual:LO2\_FREQ}{<freq>, frequency in Hz}
\query{Queries the target frequency of the LO2 PLL}{MANual:LO2\_FREQ?}{None}{<freq>, frequency in Hz}

\subsubsection{MANual:IF2\_FREQ}
Only available when the manual control dialog is active.

\event{Sets the IF2 frequency}{MANual:IF2\_FREQ}{<freq>, frequency in Hz}
\query{Queries the IF2 frequency}{MANual:IF2\_FREQ?}{None}{<freq>, frequency in Hz}

\subsubsection{MANual:PORT1\_EN}
Only available when the manual control dialog is active.

\event{Controls the enable signal for the port 1 receiver}{MANual:PORT1\_EN}{TRUE or FALSE}
\query{Queries the status of the enable signal for the port 1 receiver}{MANual:PORT1\_EN?}{None}{TRUE or FALSE}

\subsubsection{MANual:PORT2\_EN}
Only available when the manual control dialog is active.

\event{Controls the enable signal for the port 2 receiver}{MANual:PORT2\_EN}{TRUE or FALSE}
\query{Queries the status of the enable signal for the port 2 receiver}{MANual:PORT2\_EN?}{None}{TRUE or FALSE}

\subsubsection{MANual:REF\_EN}
Only available when the manual control dialog is active.

\event{Controls the enable signal for the reference receiver}{MANual:REF\_EN}{TRUE or FALSE}
\query{Queries the status of the enable signal for the reference receiver}{MANual:REF\_EN?}{None}{TRUE or FALSE}

\subsubsection{MANual:SAMPLES}
Only available when the manual control dialog is active.

\event{Sets the number of ADC samples per reading}{MANual:SAMPLES}{<samples>, value between 16 and 131072 in increments of 16}
\query{Queries the number of ADC samples per reading}{MANual:SAMPLES?}{None}{<samples>}

\subsubsection{MANual:WINdow}
Only available when the manual control dialog is active.

\event{Sets the window for the DFT calculation}{MANual:WINdow}{<window>, either NONE, KAISER, HANN or FLATTOP}
\query{Queries the window for the DFT calculatio}{MANual:WINdow?}{None}{NONE, KAISER, HANN or FLATTOP}

\subsubsection{MANual:PORT1\_MIN}
Only available when the manual control dialog is active.

\query{Queries the minimum observed port 1 ADC value in the last sampling period}{MANual:PORT1\_MIN?}{None}{minimum ADC value}

\subsubsection{MANual:PORT1\_MAX}
Only available when the manual control dialog is active.

\query{Queries the maximum observed port 1 ADC value in the last sampling period}{MANual:PORT1\_MAX?}{None}{maximum ADC value}

\subsubsection{MANual:PORT1\_MAG}
Only available when the manual control dialog is active.

\query{Queries the observerd magnitude at port 1 in the last sampling period}{MANual:PORT1\_MAG?}{None}{port 1 magnitude (linear unit, arbitrary scale)}

\subsubsection{MANual:PORT1\_PHAse}
Only available when the manual control dialog is active.

\query{Queries the observed phase at port 1 in the last sampling period}{MANual:PORT1\_PHAse?}{None}{phase in degree (random value because it is relativ to an internal sampling clock)}

\subsubsection{MANual:PORT1\_REFerenced}
Only available when the manual control dialog is active.

\query{Queries the observed signal at port 1 relative to the reference in the last sampling period}{MANual:PORT1\_REFerenced?}{None}{<real>, <imag>}

\subsubsection{MANual:PORT2\_MIN}
Only available when the manual control dialog is active.

\query{Queries the minimum observed port 2 ADC value in the last sampling period}{MANual:PORT2\_MIN?}{None}{minimum ADC value}

\subsubsection{MANual:PORT2\_MAX}
Only available when the manual control dialog is active.

\query{Queries the maximum observed port 2 ADC value in the last sampling period}{MANual:PORT2\_MAX?}{None}{maximum ADC value}

\subsubsection{MANual:PORT2\_MAG}
Only available when the manual control dialog is active.

\query{Queries the observerd magnitude at port 2 in the last sampling period}{MANual:PORT2\_MAG?}{None}{port 1 magnitude (linear unit, arbitrary scale)}

\subsubsection{MANual:PORT2\_PHAse}
Only available when the manual control dialog is active.

\query{Queries the observed phase at port 2 in the last sampling period}{MANual:PORT2\_PHAse?}{None}{phase in degree (random value because it is relativ to an internal sampling clock)}

\subsubsection{MANual:PORT2\_REFerenced}
Only available when the manual control dialog is active.

\query{Queries the observed signal at port 2 relative to the reference in the last sampling period}{MANual:PORT2\_REFerenced?}{None}{<real>, <imag>}

\subsubsection{MANual:REF\_MIN}
Only available when the manual control dialog is active.

\query{Queries the minimum observed reference ADC value in the last sampling period}{MANual:REF\_MIN?}{None}{minimum ADC value}

\subsubsection{MANual:REF\_MAX}
Only available when the manual control dialog is active.

\query{Queries the maximum observed reference ADC value in the last sampling period}{MANual:REF\_MAX?}{None}{maximum ADC value}

\subsubsection{MANual:REF\_MAG}
Only available when the manual control dialog is active.

\query{Queries the observerd magnitude at the reference receiver in the last sampling period}{MANual:REF\_MAG?}{None}{port 1 magnitude (linear unit, arbitrary scale)}

\subsubsection{MANual:REF\_PHAse}
Only available when the manual control dialog is active.

\query{Queries the observed phase at the reference receiver in the last sampling period}{MANual:REF\_PHAse?}{None}{phase in degree (random value because it is relativ to an internal sampling clock)}

\section{Streaming data}
The SCPI server works well for configuring the device and also for reading trace data once an acquition is done. But it isn't very well suited for reading data while the device is capturing it. For some applications (e.g. when running continuous sweeps) it may be beneficial to process the data externally as it getting captured. For this purpose, the LibreVNA-GUI supports streaming the data over dedicated ports.

These streaming servers have to be enbled first. This can be done in \menu[,]{Window,Preferences,Streaming Servers}.

There are a total of 5 streaming servers available. They can all be enabled and used at the same time, although not all servers will output data all the time.

\begin{itemize}
\item \textbf{VNA raw data:} Outputs the raw S-parameters without any calibration applied. This output is always available, even when a calibration is enabled or de-embedding it active. Apart from averaging (if enabled) no processing is done on the data.
\item \textbf{VNA calibrated data:} Outputs the calibrated S-parameters with the calibration applied. This output is only available when a calibration is enabled.
\item \textbf{VNA de-embedded data:} Outputs the de-embedded S-parameters with the de-embbeding and calibration (if enabled) applied. This output is only available when de-embedding is active.
\item \textbf{SA raw data:} Outputs the raw (not normalized) power levels from the spectrum analyzer. This output is always available, even when normalizing is active.
\item \textbf{SA normalized data:} Outputs the normalized power levels from the spectrum analyzer. This output is only available when normalizing is active.
\end{itemize}

\vspace{0.5cm}

All servers output a newline-terminated line of json formatted data for each measurement point in the sweep. The format of the output data changes depending on the configured sweep type.

\begin{itemize}
\item VNA frequency or power sweeps:
\begin{example}
{"Z0":50.0,"dBm":-20.0,"frequency":42993000.0,"measurements":{"S11_imag":-0.061379313997181856,"S11_real":0.023033630841401063,"S12_imag":0.3205479840477101,"S12_real":-0.5742283570681822,"S21_imag":-0.3746074656570865,"S21_real":0.6126114195570408,"S22_imag":0.06312766256272641,"S22_real":-0.018668561526968372},"pointNum":7}
\end{example}
\item VNA zero span sweeps:
\begin{example}
{"Z0":50.0,"measurements":{"S11_imag":0.0697879786634009,"S11_real":0.11959939538177566,"S12_imag":-0.2820494760489866,"S12_real":0.4134518710922877,"S21_imag":0.11201366122663228,"S21_real":-0.4258244924547545,"S22_imag":-0.004193267854043776,"S22_real":0.028964823536021114},"pointNum":7,"time":2.438674}
\end{example}
\item Spectrum analyzer non zero span sweeps:
\begin{example}
{"frequency":2182396.0,"measurements":{"PORT1":7.343487141042715e-06,"PORT2":6.78117066854611e-06},"pointNum":445}
\end{example}
\item Spectrum analyzer zero span sweeps:
\begin{example}
{"measurements":{"PORT1":2.595309979369631e-06,"PORT2":1.4385256008608849e-06},"pointNum":7,"time":0.344095}
\end{example}
\end{itemize}

For zero span sweeps, the time in seconds since the beginning of the sweep is given instead of a frequency of power level. The time is always relative to point 0 of the current sweep and point 0 will have a time of 0.

\end{document}
