Skip to content

Keysight Network Analyzer

Bases: VisaDriver

Source code in driverlib/keysight/keysight_na.py
11
12
def __init__(self, resource_location: str):
    super().__init__(resource_location, "\n")

idn property

idn

Retrieve the identification string.

Returns:

Name Type Description
str str

The identification string of the device.

get_output

get_output()

Query the output state of the signal generator.

Returns:

Name Type Description
bool bool

True if the output is enabled, False otherwise.

Source code in driverlib/keysight/keysight_na.py
119
120
121
122
123
124
125
def get_output(self) -> bool:
    """Query the output state of the signal generator.

    Returns:
        bool: True if the output is enabled, False otherwise.
    """
    return bool(int(self.ask("OUTP?")))

set_output

set_output(value)

Set the output state of the signal generator.

Parameters:

Name Type Description Default
value bool | ON | OFF | 0 | 1

The desired output state. True to enable the output, False to disable it.

required
Source code in driverlib/keysight/keysight_na.py
127
128
129
130
131
132
133
134
135
136
def set_output(self, value):
    """Set the output state of the signal generator.

    Args:
        value (bool | ON | OFF | 0 | 1): The desired output state. True to enable the output, False to disable it.
    """
    if self._value_to_bool(value):
        self.write(":OUTP ON")
    else:
        self.write(":OUTP OFF")

close

close()

Close the connection to the device.

Source code in driverlib/visa_driver.py
64
65
66
def close(self):
    """Close the connection to the device."""
    self.backend.close()

get_error

get_error()

Retrieve the error message from the device.

Returns:

Name Type Description
str

The error message.

Source code in driverlib/visa_driver.py
77
78
79
80
81
82
83
def get_error(self):
    """Retrieve the error message from the device.

    Returns:
        str: The error message.
    """
    return self.ask("SYST:ERR?")

print_error

print_error()

Print eventual errors occurred.

Source code in driverlib/visa_driver.py
85
86
87
def print_error(self):
    """Print eventual errors occurred."""
    print(f"Errors: {self.get_error()}", end="")

reset

reset()

Reset instrument to factory default state. Does not clear volatile memory.

Source code in driverlib/visa_driver.py
89
90
91
92
def reset(self):
    """Reset instrument to factory default state. Does not clear volatile memory."""
    self.write("*RST")
    self.write("*WAI")

clear

clear()

Clear event register, error queue -when power is cycled-.

Source code in driverlib/visa_driver.py
94
95
96
97
def clear(self):
    """Clear event register, error queue -when power is cycled-."""
    self.write("*CLS")
    self.write("*WAI")