Skip to content

API Reference

CoBrite(address='cobrite.local', port=2000, timeout=10, max_retries=3, open=False, _transport=None)

Driver for an ID Photonics CoBrite tunable laser controller.

Connect with open(), control lasers with port commands (explicit CSD or property API), and disconnect with close(). Level-1 commands require a password; supply it via login(1) or login_from_file(path).

CSD addressing — most port commands accept chassis, slot, and device integers. Passing 0 (the default) expands to every known port at that level, so set_state(True) enables all lasers on the unit. Multi-port queries return a tuple of (chassis, slot, device, value) tuples, one per matched port.

Property API — call set_active_port(c, s, d) once, then read and write laser parameters as plain Python attributes (cb.wavelength, cb.power, etc.).

Example
cb = CoBrite(address="192.168.1.99", timeout=20)
cb.open()

# Explicit CSD style
cb.set_wavelength(1550.0, 1, 1, 1)
wav = cb.get_wavelength(1, 1, 1)[0][-1]

# Property style
cb.set_active_port(1, 1, 1)
cb.wavelength = 1550.0
print(cb.wavelength)

cb.close()

Create a CoBrite driver instance.

Parameters:

Name Type Description Default
address str

Hostname or IP address of the CoBrite unit.

'cobrite.local'
port int

TCP port number exposed by the unit (default 2000).

2000
timeout int

Socket timeout in seconds. Must be longer than the maximum laser tuning time (typically 10-30 s).

10
max_retries int

How many times to retry a command when the device returns an unparsable response before raising RuntimeError.

3
open bool

When True, call open() immediately after construction.

False
_transport Transport | None

For testing only. Inject a custom Transport instead of opening a real PyVISA connection. When set, open() skips hostname resolution and PyVISA entirely.

None
Example
# Lazy open
cb = CoBrite(address="192.168.1.99", timeout=20)
cb.open()

# Eager open
cb = CoBrite(address="192.168.1.99", timeout=20, open=True)

actual_power property

Actual measured output power of the active port in dBm.

CSD equivalent: get_actual_power.

Raises:

Type Description
RuntimeError

If no active port has been set.

dither property writable

Dither enable state of the active port.

CSD equivalents: get_dither / set_dither.

Raises:

Type Description
RuntimeError

If no active port has been set.

frequency property writable

Target frequency of the active port in THz.

CSD equivalents: get_frequency / set_frequency.

Raises:

Type Description
RuntimeError

If no active port has been set.

frequency_limits property

Frequency range of the active port as {"min": float, "max": float} in THz.

CSD equivalent: get_frequency_limits.

Raises:

Type Description
RuntimeError

If no active port has been set.

laser_alarm property

Laser alarm code of the active port. 0 = no alarm.

CSD equivalent: get_laser_alarm.

Raises:

Type Description
RuntimeError

If no active port has been set.

laser_config property writable

Full laser configuration of the active port.

CSD equivalents: get_config / set_config. Keys: frequency (THz), offset (GHz), power (dBm), state (bool), busy (bool), dither (int).

Raises:

Type Description
RuntimeError

If no active port has been set.

limits property

All tuning limits of the active port.

CSD equivalent: get_limits. Returns a dict with keys freq_min, freq_max (THz), offset_range (GHz), pow_min, pow_max (dBm).

Raises:

Type Description
RuntimeError

If no active port has been set.

monitor property

Thermal and current monitor readings of the active port.

CSD equivalent: get_monitor. Keys: ld_chip_temp (°C), base_temp (°C), ld_current_ma, tec_current_ma.

Raises:

Type Description
RuntimeError

If no active port has been set.

offset property writable

Frequency offset of the active port in GHz.

CSD equivalents: get_offset / set_offset.

Raises:

Type Description
RuntimeError

If no active port has been set.

offset_limits property

Symmetric offset limit of the active port in GHz.

CSD equivalent: get_offset_limits. The allowed range is [-offset_limits, +offset_limits].

Raises:

Type Description
RuntimeError

If no active port has been set.

power property writable

Target output power of the active port in dBm.

CSD equivalents: get_power / set_power. For the actual measured power use actual_power.

Raises:

Type Description
RuntimeError

If no active port has been set.

power_limits property

Power range of the active port as {"min": float, "max": float} in dBm.

CSD equivalent: get_power_limits.

Raises:

Type Description
RuntimeError

If no active port has been set.

state property writable

Enable state of the active port.

CSD equivalents: get_state / set_state.

Raises:

Type Description
RuntimeError

If no active port has been set.

trigger_config property writable

Buffered trigger configuration of the active port.

CSD equivalents: get_trigger_config / set_trigger_config. Same keys as laser_config. Applied when the hardware trigger input fires.

Raises:

Type Description
RuntimeError

If no active port has been set.

trigger_out_active property writable

Whether the active port contributes to the hardware trigger output.

CSD equivalents: get_trigger_out_active / set_trigger_out_active.

Raises:

Type Description
RuntimeError

If no active port has been set.

wavelength property writable

Target wavelength of the active port in nm.

CSD equivalents: get_wavelength / set_wavelength.

Raises:

Type Description
RuntimeError

If no active port has been set.

wavelength_limits property

Wavelength range of the active port as {"min": float, "max": float} in nm.

CSD equivalent: get_wavelength_limits.

Raises:

Type Description
RuntimeError

If no active port has been set.

abort()

Abort the current operation (ABOR).

busy_wait(chassis=0, slot=0, device=0)

Send a server-side blocking wait command (BWAI).

The device holds the TCP connection open until the laser finishes tuning, avoiding the round-trip overhead of client-side BUSY? polling. Prefer this over wait() for single-port workflows.

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

clear_status()

Clear all status and alarm registers (*CLS).

Requires level 1.

close(disable=True)

Close the TCP connection.

Parameters:

Name Type Description Default
disable bool

When True (default), disable all laser ports before closing by calling set_state(False) for every port.

True

connect_guard(_func=None, *, value='call open() to connect.', exception=True) staticmethod

connect_guard(_func: F) -> F
connect_guard(
    _func: None = None,
    *,
    value: str = ...,
    exception: bool = ...,
) -> Callable[[F], F]

Decorator that raises ConnectionError if the socket is not open.

Can be used bare (@connect_guard) or with keyword arguments (@connect_guard(exception=False)).

Parameters:

Name Type Description Default
_func F | None

The function being decorated when used bare.

None
value str

Message for the ConnectionError (or return value when exception=False).

'call open() to connect.'
exception bool

When False, return value instead of raising.

True

Returns:

Type Description
F | Callable[[F], F]

Decorated function or decorator factory.

default_ip_config()

Reset network configuration to factory defaults (IPCDEF).

Changes take effect after the next reboot. Requires level 1.

default_settings()

Reset all laser settings to factory defaults (DEFAULT).

Network configuration is not affected. Requires level 1.

format_layout(indent=2)

Return the device layout as an indented human-readable string.

Parameters:

Name Type Description Default
indent int

Number of spaces per indentation level.

2

Returns:

Type Description
str

Multi-line string listing chassis, slots, and devices.

Example
Chassis 1:
  Slot 1:
    Device 1: GC

full_info(indent=2)

Return identification, layout, and per-port laser state as a string.

Queries frequency, wavelength, power, and enable state for every port in the cached layout.

Parameters:

Name Type Description Default
indent int

Number of spaces per indentation level.

2

Returns:

Type Description
str

Multi-line string suitable for console display.

get_active_port()

Return the currently active port, or None if not set.

Returns:

Type Description
tuple[int, int, int] | None

(chassis, slot, device) tuple, or None.

get_actual_power(chassis=0, slot=0, device=0)

Return the actual measured output power in dBm (APOW?).

Property equivalent: actual_power.

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

Returns:

Type Description
tuple[tuple[int, int, int, float], ...]

Tuple of (chassis, slot, device, actual_power_dbm) per matched port.

get_alarm()

Return the system alarm register (ALAR?).

Returns:

Type Description
int

Integer alarm code; 0 means no alarm.

get_card_info(chassis, slot)

Return card information for a specific slot (CARD:INFO?).

Parameters:

Name Type Description Default
chassis int

Chassis number.

required
slot int

Slot number.

required

Returns:

Type Description
str

Card information string from the device.

get_config(chassis=0, slot=0, device=0)

Return the full laser configuration in one query (CONF?).

Property equivalent: laser_config.

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

Returns:

Type Description
tuple[int, int, int, dict[str, float | bool | int]]

Tuple of (chassis, slot, device, config) where config is a dict

...

with keys:

tuple[tuple[int, int, int, dict[str, float | bool | int]], ...]
  • frequency (float): Target frequency in THz.
tuple[tuple[int, int, int, dict[str, float | bool | int]], ...]
  • offset (float): Frequency offset in GHz.
tuple[tuple[int, int, int, dict[str, float | bool | int]], ...]
  • power (float): Target output power in dBm.
tuple[tuple[int, int, int, dict[str, float | bool | int]], ...]
  • state (bool): Laser enabled.
tuple[tuple[int, int, int, dict[str, float | bool | int]], ...]
  • busy (bool): Tuning in progress.
tuple[tuple[int, int, int, dict[str, float | bool | int]], ...]
  • dither (int): Dither state (1 = on, 0 = off, -1 = not supported).

get_dhcp()

Return the DHCP setting for the Ethernet interface (DHCP?).

Returns:

Type Description
str

"on" if DHCP is enabled, "off" if static IP is configured.

get_dither(chassis=0, slot=0, device=0)

Return the dither enable state (DIT?).

Property equivalent: dither.

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

Returns:

Type Description
tuple[tuple[int, int, int, bool], ...]

Tuple of (chassis, slot, device, dither_enabled) per matched port.

get_dns_ip()

Return the primary DNS server IP address (DNSIP?).

Returns:

Type Description
str

Dotted-decimal DNS IP string.

get_echo()

Return True if command echo is enabled (ECHO?).

Returns:

Type Description
bool

True = echo on.

get_enable_autostart()

Return True if laser on/off state is preserved across reboots (ENABAUTOSTA?).

Returns:

Type Description
bool

True = autostart enabled.

get_error()

Return the last error string (ERR?).

Returns:

Type Description
str

Error description string from the device.

get_fan()

Return the current fan level as a percentage string (FAN?).

Returns:

Type Description
str

Fan level string (device-dependent format).

get_frequency(chassis=0, slot=0, device=0)

Return the target frequency in THz (FREQ?).

Property equivalent: frequency.

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

Returns:

Type Description
tuple[tuple[int, int, int, float], ...]

Tuple of (chassis, slot, device, frequency_thz) per matched port.

get_frequency_limits(chassis=0, slot=0, device=0)

Return the tunable frequency range in THz (FREQ:LIM?).

Property equivalent: frequency_limits.

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

Returns:

Type Description
tuple[int, int, int, dict[str, float]]

Tuple of (chassis, slot, device, limits) where limits is

...

{"min": float, "max": float} in terahertz.

get_gateway_ip()

Return the gateway IP address (GATEWAYIP?). DX and DX2 only.

For MX: get_gateway_ip_1 / get_gateway_ip_2.

Returns:

Type Description
str

Dotted-decimal gateway IP string.

get_gateway_ip_1()

Return the front-panel gateway IP address (GATEWAYIP1?). MX only.

For DX/DX2: get_gateway_ip.

Returns:

Type Description
str

Dotted-decimal gateway IP string.

get_gateway_ip_2()

Return the rear-panel gateway IP address (GATEWAYIP2?). MX only.

For DX/DX2: get_gateway_ip.

Returns:

Type Description
str

Dotted-decimal gateway IP string.

get_interlock()

Return the hardware interlock state (INTL?).

Returns:

Type Description
bool

False when the interlock is satisfied and lasers can be enabled;

bool

True when the interlock is open (lasers blocked).

get_ip_address()

Return the Ethernet IP address (IPADDR?). DX and DX2 only.

For MX: get_ip_address_1 / get_ip_address_2.

Returns:

Type Description
str

Dotted-decimal IP address string.

get_ip_address_1()

Return the front-panel Ethernet IP address (IPADDR1?). MX only.

For DX/DX2: get_ip_address.

Returns:

Type Description
str

Dotted-decimal IP address string.

get_ip_address_2()

Return the rear-panel Ethernet IP address (IPADDR2?). MX only.

For DX/DX2: get_ip_address.

Returns:

Type Description
str

Dotted-decimal IP address string.

get_ip_config_changed()

Return True if network config has changed since last reboot (IPCCH?).

Returns:

Type Description
bool

True when a reboot is required for network changes to take effect.

get_laser_alarm(chassis=0, slot=0, device=0)

Return the per-port laser alarm code (LALAR?).

Property equivalent: laser_alarm.

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

Returns:

Type Description
tuple[int, int, int, int]

Tuple of (chassis, slot, device, alarm_code) per matched port.

...

0 means no alarm.

get_limits(chassis=0, slot=0, device=0)

Return all tuning limits in one query (LIM?).

Property equivalent: limits.

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

Returns:

Type Description
tuple[int, int, int, dict[str, float]]

Tuple of (chassis, slot, device, limits) where limits is a dict

...

with keys:

tuple[tuple[int, int, int, dict[str, float]], ...]
  • freq_min, freq_max (float): Frequency range in THz.
tuple[tuple[int, int, int, dict[str, float]], ...]
  • offset_range (float): Symmetric offset limit in GHz.
tuple[tuple[int, int, int, dict[str, float]], ...]
  • pow_min, pow_max (float): Power range in dBm.

get_lockout()

Return the write-lockout state (LOCK?).

Returns:

Type Description
bool

True when another session holds the write lock.

get_mac_address()

Return the Ethernet MAC address (MACADDRESS?). DX and DX2 only.

For MX: get_mac_address_1 / get_mac_address_2.

Returns:

Type Description
str

MAC address string.

get_mac_address_1()

Return the front-panel Ethernet MAC address (MACADDRESS1?). MX only.

For DX/DX2: get_mac_address.

Returns:

Type Description
str

MAC address string.

get_mac_address_2()

Return the rear-panel Ethernet MAC address (MACADDRESS2?). MX only.

For DX/DX2: get_mac_address.

Returns:

Type Description
str

MAC address string.

get_monitor(chassis=0, slot=0, device=0)

Return thermal and current monitor readings (MON?).

Property equivalent: monitor.

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

Returns:

Type Description
tuple[int, int, int, dict[str, float]]

Tuple of (chassis, slot, device, monitor) where monitor is a

...

dict with keys:

tuple[tuple[int, int, int, dict[str, float]], ...]
  • ld_chip_temp (float): Laser diode chip temperature in °C.
tuple[tuple[int, int, int, dict[str, float]], ...]
  • base_temp (float): Module base temperature in °C.
tuple[tuple[int, int, int, dict[str, float]], ...]
  • ld_current_ma (float): Laser diode drive current in mA.
tuple[tuple[int, int, int, dict[str, float]], ...]
  • tec_current_ma (float): TEC current in mA.

get_netmask()

Return the Ethernet netmask (NETMASK?). DX and DX2 only.

For MX: get_netmask_1 / get_netmask_2.

Returns:

Type Description
str

Dotted-decimal netmask string.

get_netmask_1()

Return the front-panel Ethernet netmask (NETMASK1?). MX only.

For DX/DX2: get_netmask.

Returns:

Type Description
str

Dotted-decimal netmask string.

get_netmask_2()

Return the rear-panel Ethernet netmask (NETMASK2?). MX only.

For DX/DX2: get_netmask.

Returns:

Type Description
str

Dotted-decimal netmask string.

get_offset(chassis=0, slot=0, device=0)

Return the current frequency offset in GHz (OFF?).

Property equivalent: offset.

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

Returns:

Type Description
tuple[tuple[int, int, int, float], ...]

Tuple of (chassis, slot, device, offset_ghz) per matched port.

get_offset_limits(chassis=0, slot=0, device=0)

Return the symmetric frequency offset limit in GHz (OFF:LIM?).

Property equivalent: offset_limits. The allowed offset range is [-limit, +limit].

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

Returns:

Type Description
tuple[tuple[int, int, int, float], ...]

Tuple of (chassis, slot, device, offset_limit_ghz) per matched port.

get_param_refresh()

Return the parameter-refresh change counter (PREF?).

The counter increments each time any parameter changes on the device. Poll this to detect changes without querying every parameter.

Returns:

Type Description
int

Integer change counter.

get_power(chassis=0, slot=0, device=0)

Return the target output power in dBm (POW?).

Property equivalent: power. For the actual measured power, use get_actual_power.

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

Returns:

Type Description
tuple[tuple[int, int, int, float], ...]

Tuple of (chassis, slot, device, power_dbm) per matched port.

get_power_limits(chassis=0, slot=0, device=0)

Return the output power range in dBm (POW:LIM?).

Property equivalent: power_limits.

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

Returns:

Type Description
tuple[int, int, int, dict[str, float]]

Tuple of (chassis, slot, device, limits) where limits is

...

{"min": float, "max": float} in dBm.

get_remote()

Return True if the unit is in remote control mode (REMO?).

Returns:

Type Description
bool

True = remote mode active.

get_start_default()

Return True if the unit starts with factory defaults on boot (STADEF?).

Returns:

Type Description
bool

True = factory defaults applied on next start.

get_state(chassis=0, slot=0, device=0)

Return the enable state of matched laser ports (STAT?).

Property equivalent: state.

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

Returns:

Type Description
tuple[tuple[int, int, int, bool], ...]

Tuple of (chassis, slot, device, enabled) per matched port.

get_temp()

Return the location and temperature of the hottest laser (TEMP?).

Returns:

Type Description
dict[str, int | float]

Dict with keys:

dict[str, int | float]
  • chassis (int)
dict[str, int | float]
  • slot (int)
dict[str, int | float]
  • device (int)
dict[str, int | float]
  • temp (float): Temperature in °C.

get_time()

Return the system time as a Unix timestamp (TIME?).

The clock is volatile; it must be set after each cold start.

Returns:

Type Description
int

Unix timestamp (seconds since epoch).

get_trigger_config(chassis=0, slot=0, device=0)

Return the buffered trigger configuration (TRICONF?).

Property equivalent: trigger_config. The trigger config is applied when the hardware trigger input fires. It has the same structure as the regular laser config from get_config.

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

Returns:

Type Description
tuple[int, int, int, dict[str, float | bool | int]]

Tuple of (chassis, slot, device, config) per matched port.

...

See get_config for the dict key descriptions.

get_trigger_delay()

Return the hardware trigger delay in milliseconds (TRIDEL?).

Returns:

Type Description
int

Trigger delay in ms.

get_trigger_out_active(chassis=0, slot=0, device=0)

Return whether a port contributes to the hardware trigger output (TRIOUTACT?).

Property equivalent: trigger_out_active.

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

Returns:

Type Description
tuple[tuple[int, int, int, bool], ...]

Tuple of (chassis, slot, device, active) per matched port.

get_trigger_polarity()

Return the hardware trigger polarity settings (TRIPOL?).

Returns:

Type Description
dict[str, str | int]

Dict with keys:

dict[str, str | int]
  • direction (str): "IN" or "OUT".
dict[str, str | int]
  • polarity (int): 0 or 1.

get_usb_ip_address()

Return the IP address of the virtual Ethernet interface over USB (USBIPADDR?).

Returns:

Type Description
str

Dotted-decimal IP address string.

get_usb_netmask()

Return the netmask of the virtual Ethernet interface over USB (USBNETMASK?).

Returns:

Type Description
str

Dotted-decimal netmask string.

get_wavelength(chassis=0, slot=0, device=0)

Return the target wavelength in nm (WAV?).

Property equivalent: wavelength.

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

Returns:

Type Description
tuple[tuple[int, int, int, float], ...]

Tuple of (chassis, slot, device, wavelength_nm) per matched port.

get_wavelength_limits(chassis=0, slot=0, device=0)

Return the tunable wavelength range in nm (WAV:LIM?).

Property equivalent: wavelength_limits.

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

Returns:

Type Description
tuple[int, int, int, dict[str, float]]

Tuple of (chassis, slot, device, limits) where limits is

...

{"min": float, "max": float} in nanometres.

identify(enable)

Blink a visible indicator to identify the unit in a multi-unit setup (IDENT).

Parameters:

Name Type Description Default
enable bool

True to start blinking, False to stop.

required

idn()

Return the identification string of the unit (*IDN?).

Returns:

Type Description
str

Identification string, e.g. "ID Photonics,CoBrite-DX,...".

info()

Return the system information string (INFO?).

Returns the same identification and version information as idn() but via the system-level INFO? command.

Returns:

Type Description
str

System type and software version string.

init_interface()

Reset session parameters to defaults (INTI).

Resets ECHO, PASS, FORMAT, LINLOG, and EVENT to their default values. Also resets the cached user level to 0. Called automatically by open().

layout()

Fetch and cache the device layout.

Queries LAY? and then TYP? for every discovered port. The result is cached internally and used to expand wildcard (0) CSD addresses. Called automatically by open().

Returns:

Type Description
dict[int, dict[int, dict[int, str]]]

Nested dict {chassis: {slot: {device: type_string}}}.

login(level=0, password='IDP')

Authenticate with the device.

The granted level is cached for the session; subsequent level-1 calls succeed without re-authenticating until close() or init_interface() resets it. For non-interactive scripts prefer login_from_file().

Parameters:

Name Type Description Default
level int

Target user level. 0 (default) logs out. 1 grants access to level-1 write commands.

0
password str

Password string (default "IDP"). Ignored when level is 0.

'IDP'

Returns:

Type Description
int

The user level confirmed by the device after authentication.

login_from_file(path, level=1)

Authenticate using a password stored in a file.

Reads the first non-empty line of path and uses it as the password. The granted level is cached exactly as with login().

Parameters:

Name Type Description Default
path str | Path

Path to a plain-text file whose first line is the password.

required
level int

Target user level (default 1).

1

Returns:

Type Description
int

The user level confirmed by the device after authentication.

Example
cb.login_from_file("/run/secrets/cobrite_password")
cb.set_trigger_delay(10)   # no prompt

manual() staticmethod

Open the CoBrite user manual in the default web browser.

opc()

Return True when all pending operations are complete (*OPC?).

Returns:

Type Description
bool

True if the device is idle.

opc_wait()

Block until all pending operations complete (*WAI).

The device holds the TCP connection open until *OPC? would return 1, eliminating the need for a client-side polling loop.

open()

Open the TCP connection to the CoBrite unit.

Resolves address to an IP, opens a PyVISA TCPIP socket, fetches the device layout, and resets session parameters with INTI. When a _transport was injected at construction time, the PyVISA step is skipped and the injected transport is used directly.

Raises:

Type Description
gaierror

If address cannot be resolved (real transport only).

VisaIOError

If the socket cannot be opened (real transport only).

query(command)

Send a SCPI command and return the raw response string.

Parameters:

Name Type Description Default
command str

SCPI command string (without terminator).

required

Returns:

Type Description
str

Stripped response string from the device.

Raises:

Type Description
ConnectionError

If open() has not been called.

RuntimeError

If the response contains "ERR".

requires_level(level) staticmethod

Decorator that raises PermissionError if the session user level is insufficient.

Call login(1) or login_from_file(path) before invoking level-1 methods. Can be used on subclass methods: @CoBrite.requires_level(1).

Parameters:

Name Type Description Default
level int

Minimum required user level.

required

Returns:

Type Description
Callable[[F], F]

Decorator factory.

Example
class MyDevice(CoBrite):
    @CoBrite.requires_level(1)
    def my_protected_method(self) -> None:
        ...

reset()

Perform a warm restart of the controller (*RST).

All open sessions are closed. Requires level 1.

retry(_func=None, *, max_retries=None) staticmethod

retry(_func: F) -> F
retry(
    _func: None = None, *, max_retries: int | None = None
) -> Callable[[F], F]

Decorator that retries the wrapped function on any exception.

Reads self.max_retries unless max_retries is given explicitly. Can be used bare (@CoBrite.retry) or with a keyword argument (@CoBrite.retry(max_retries=5)).

Parameters:

Name Type Description Default
_func F | None

The function being decorated when used bare.

None
max_retries int | None

Override for self.max_retries. When None, the instance attribute is used at call time.

None

Returns:

Type Description
F | Callable[[F], F]

Decorated function or decorator factory.

Example
class MyDevice(CoBrite):
    @CoBrite.retry
    def read_sensor(self) -> float:
        ...

    @CoBrite.retry(max_retries=5)
    def critical_read(self) -> float:
        ...

set_active_port(chassis, slot, device)

Set the port used by all property accessors.

Parameters:

Name Type Description Default
chassis int

Chassis number (must be non-zero).

required
slot int

Slot number (must be non-zero).

required
device int

Device number (must be non-zero).

required

set_config(frequency, offset, power, state, dither, chassis=0, slot=0, device=0, wait=True)

Set all laser parameters atomically in a single command (CONF).

Property equivalent: laser_config.

Parameters:

Name Type Description Default
frequency float

Target frequency in THz.

required
offset float

Frequency offset in GHz.

required
power float

Target output power in dBm.

required
state bool

True to enable the laser.

required
dither int

Dither state (1 = on, 0 = off, -1 = not supported).

required
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0
wait bool

When True, poll BUSY? until tuning completes.

True

set_dhcp(enable)

Enable or disable DHCP on the Ethernet interface (DHCP).

Requires level 1.

Parameters:

Name Type Description Default
enable bool

True to enable DHCP, False for static IP.

required

set_dither(enable, chassis=0, slot=0, device=0, wait=True)

Enable or disable dither on matched laser ports (DIT).

Property equivalent: dither.

Parameters:

Name Type Description Default
enable bool

True to enable dither, False to disable.

required
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0
wait bool

When True, poll BUSY? until operation completes.

True

set_dns_ip(ip)

Set the primary DNS server IP address (DNSIP).

Requires level 1.

Parameters:

Name Type Description Default
ip str

Dotted-decimal DNS server IP string.

required

set_echo(enable)

Enable or disable command echo (ECHO).

Parameters:

Name Type Description Default
enable bool

True to enable echo, False to disable.

required

set_enable_autostart(enable)

Enable or disable preservation of laser on/off state across reboots (ENABAUTOSTA).

Requires level 1.

Parameters:

Name Type Description Default
enable bool

True to enable autostart.

required

set_frequency(frequency, chassis=0, slot=0, device=0, wait=True)

Set the target frequency in THz (FREQ).

Property equivalent: frequency.

Parameters:

Name Type Description Default
frequency float

Target frequency in terahertz.

required
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0
wait bool

When True, poll BUSY? until tuning completes.

True

set_gateway_ip(ip)

Set the gateway IP address (GATEWAYIP). DX and DX2 only.

For MX: set_gateway_ip_1/ set_gateway_ip_2.

Requires level 1.

Parameters:

Name Type Description Default
ip str

Dotted-decimal gateway IP string.

required

set_gateway_ip_1(ip)

Set the front-panel gateway IP address (GATEWAYIP1). MX only.

For DX/DX2: set_gateway_ip.

Requires level 1.

Parameters:

Name Type Description Default
ip str

Dotted-decimal gateway IP string.

required

set_gateway_ip_2(ip)

Set the rear-panel gateway IP address (GATEWAYIP2). MX only.

For DX/DX2: set_gateway_ip.

Requires level 1.

Parameters:

Name Type Description Default
ip str

Dotted-decimal gateway IP string.

required

set_ip_address(ip)

Set the Ethernet IP address (IPADDR). DX and DX2 only.

For MX: set_ip_address_1/ set_ip_address_2.

Requires level 1.

Parameters:

Name Type Description Default
ip str

Dotted-decimal IP address string.

required

set_ip_address_1(ip)

Set the front-panel Ethernet IP address (IPADDR1). MX only.

For DX/DX2: set_ip_address.

Requires level 1.

Parameters:

Name Type Description Default
ip str

Dotted-decimal IP address string.

required

set_ip_address_2(ip)

Set the rear-panel Ethernet IP address (IPADDR2). MX only.

For DX/DX2: set_ip_address.

Requires level 1.

Parameters:

Name Type Description Default
ip str

Dotted-decimal IP address string.

required

set_lockout(enable)

Lock or unlock other sessions from performing write commands (LOCK).

Requires level 1.

Parameters:

Name Type Description Default
enable bool

True to acquire the write lock, False to release it.

required

set_netmask(mask)

Set the Ethernet netmask (NETMASK). DX and DX2 only.

For MX: set_netmask_1/ set_netmask_2.

Requires level 1.

Parameters:

Name Type Description Default
mask str

Dotted-decimal netmask string.

required

set_netmask_1(mask)

Set the front-panel Ethernet netmask (NETMASK1). MX only.

For DX/DX2: set_netmask.

Requires level 1.

Parameters:

Name Type Description Default
mask str

Dotted-decimal netmask string.

required

set_netmask_2(mask)

Set the rear-panel Ethernet netmask (NETMASK2). MX only.

For DX/DX2: set_netmask.

Requires level 1.

Parameters:

Name Type Description Default
mask str

Dotted-decimal netmask string.

required

set_offset(offset, chassis=0, slot=0, device=0, wait=True)

Set the frequency offset in GHz (OFF).

Property equivalent: offset. The offset is added to the nominal frequency set by set_frequency. Use get_offset_limits for the allowed range (symmetric, ±limit).

Parameters:

Name Type Description Default
offset float

Frequency offset in GHz.

required
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0
wait bool

When True, poll BUSY? until tuning completes.

True

set_password(password)

Change the password for the current user level (SPASS).

Requires level 1.

Parameters:

Name Type Description Default
password str

New password string.

required

set_power(power, chassis=0, slot=0, device=0, wait=True)

Set the target output power in dBm (POW).

Property equivalent: power.

Parameters:

Name Type Description Default
power float

Target output power in dBm.

required
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0
wait bool

When True, poll BUSY? until tuning completes.

True

set_start_default(enable)

Control whether the unit applies factory defaults on the next boot (STADEF).

Requires level 1.

Parameters:

Name Type Description Default
enable bool

True = apply factory defaults on start.

required

set_state(state=False, chassis=0, slot=0, device=0, wait=True)

Enable or disable laser output (STAT).

Property equivalent: state.

Parameters:

Name Type Description Default
state bool

True to enable, False to disable.

False
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0
wait bool

When True, poll BUSY? until tuning completes.

True

set_time(t)

Set the system time (TIME).

Stored in volatile memory; must be set after each cold start.

Parameters:

Name Type Description Default
t int

Unix timestamp (seconds since epoch).

required

set_trigger_config(frequency, offset, power, state, dither, chassis=0, slot=0, device=0, wait=True)

Buffer a configuration to apply when the hardware trigger input fires (TRICONF).

Property equivalent: trigger_config. Parameters have the same meaning as set_config. Requires level 1.

Parameters:

Name Type Description Default
frequency float

Target frequency in THz.

required
offset float

Frequency offset in GHz.

required
power float

Target output power in dBm.

required
state bool

True to enable the laser on trigger.

required
dither int

Dither state (1 = on, 0 = off, -1 = not supported).

required
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0
wait bool

When True, poll BUSY? until operation completes.

True

set_trigger_delay(ms)

Set the hardware trigger delay in milliseconds (TRIDEL).

Requires level 1.

Parameters:

Name Type Description Default
ms int

Trigger delay in milliseconds.

required

set_trigger_out_active(active, chassis=0, slot=0, device=0, wait=True)

Enable or disable a port's contribution to the hardware trigger output (TRIOUTACT).

Property equivalent: trigger_out_active. Requires level 1.

Parameters:

Name Type Description Default
active bool

True to include this port in the trigger output.

required
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0
wait bool

When True, poll BUSY? until operation completes.

True

set_trigger_polarity(in_out, polarity)

Set the hardware trigger polarity (TRIPOL).

Requires level 1.

Parameters:

Name Type Description Default
in_out str

Direction — "IN" or "OUT".

required
polarity int

Edge polarity — 0 (falling) or 1 (rising).

required

set_wavelength(wavelength, chassis=0, slot=0, device=0, wait=True)

Set the target wavelength in nm (WAV).

Property equivalent: wavelength.

Parameters:

Name Type Description Default
wavelength float

Target wavelength in nanometres.

required
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0
wait bool

When True, poll BUSY? until tuning completes.

True

wait(chassis=0, slot=0, device=0)

Poll BUSY? until all matched ports finish tuning.

Called automatically by set methods unless wait=False is passed. For a server-side blocking wait without polling, use busy_wait().

Parameters:

Name Type Description Default
chassis int

Chassis number, or 0 for all.

0
slot int

Slot number, or 0 for all.

0
device int

Device number, or 0 for all.

0

wait_ms(ms)

Insert a server-side delay before processing the next buffered command (WAITMS).

Parameters:

Name Type Description Default
ms int

Delay in milliseconds.

required

write(command)

Send a SCPI command and discard the response.

Internally calls query(), so the same error checking applies.

Parameters:

Name Type Description Default
command str

SCPI command string (without terminator).

required

Raises:

Type Description
ConnectionError

If open() has not been called.

RuntimeError

If the device returns an error response.