IEEE488.2

Every SCPI interface is based on the IEEE488.2 protocol. This Python implementation separates the protocol into two layers:

  • IEEE488.2 layer: IEEE488.2 layer that implements the protocol based on the transport layer.

  • Transport layer: Transport layers responsible for lowest level of communcation (e.g. Ethernet).”

IEEE488.2 layer

class ieee488_2.ieee488_2.ieee488_2(transport_inst: <module 'ieee488_2.transport' from '/home/docs/checkouts/readthedocs.org/user_builds/qblox-qblox-instruments/checkouts/v0.3.2/ieee488_2/transport.py'>)[source]

Bases: object

Class that implements the IEEE488.2 interface.

__init__(transport_inst: <module 'ieee488_2.transport' from '/home/docs/checkouts/readthedocs.org/user_builds/qblox-qblox-instruments/checkouts/v0.3.2/ieee488_2/transport.py'>) None[source]

Creates IEEE488.2 interface object.

Parameters

transport_inst (transport) – Transport class responsible for the lowest level of communication (e.g. ethernet).

Transport layer

class ieee488_2.transport.transport[source]

Bases: object

Abstract base class for data transport to instruments.

close() None[source]

Abstract method to close instrument.

write(cmd_str: str) None[source]

Abstract method to write command to instrument.

Parameters

cmd_str (str) – Command

write_binary(data: bytes) None[source]

Abstract method to write binary data to instrument.

Parameters

data (bytes) – Binary data

read_binary(size: int) bytes[source]

Abstract method to read binary data from instrument.

Parameters

size (int) – Number of bytes

Returns

Binary data array of length “size”.

Return type

bytes

readline() str[source]

Abstract method to read data from instrument.

Returns

String with data.

Return type

str

class ieee488_2.transport.ip_transport(host: str, port: int = 5025, timeout: float = 60.0, snd_buf_size: int = 524288)[source]

Bases: ieee488_2.transport.transport

Class for data transport of IP socket.

__init__(host: str, port: int = 5025, timeout: float = 60.0, snd_buf_size: int = 524288) None[source]

Create IP socket transport class.

Parameters
  • host (str) – Instrument IP address.

  • port (int) – Instrument port.

  • timeout (float) – Instrument call timeout in seconds.

  • snd_buf_size (int) – Instrument buffer size for transmissions to instrument.

close() None[source]

Close IP socket.

write(cmd_str: str) None[source]

Write command to instrument over IP socket.

Parameters

cmd_str (str) – Command

write_binary(data: bytes) None[source]

Write binary data to instrument over IP socket.

Parameters

data (bytes) – Binary data

read_binary(size: int) bytes[source]

Read binary data from instrument over IP socket.

Parameters

size (int) – Number of bytes

Returns

Binary data array of length “size”.

Return type

bytes

readline() str[source]

Read data from instrument over IP socket.

Returns

String with data.

Return type

str

class ieee488_2.transport.file_transport(out_file_name: str, in_file_name: str = '')[source]

Bases: ieee488_2.transport.transport

Class implementing file I/O to support driver testing.

__init__(out_file_name: str, in_file_name: str = '') None[source]

Create file transport class.

Parameters
  • out_file_name (str) – Output file name/path to write all commands to.

  • in_file_name (str) – Input file name/path to read all command responses from.

close() None[source]

Close file descriptors.

write(cmd_str: str) None[source]

Write command to file.

Parameters

cmd_str (str) – Command

write_binary(data: bytes) None[source]

Write binary data to file.

Parameters

data (bytes) – Binary data

read_binary(size: int) bytes[source]

Read binary data from file.

Parameters

size (int) – Number of bytes

Returns

Binary data array of length “size”.

Return type

bytes

readline() str[source]

Read data from file.

Returns

String with data.

Return type

str

class ieee488_2.transport.pulsar_dummy_transport(cfg_format: str)[source]

Bases: ieee488_2.transport.transport

Class to replace Pulsar device with dummy device to support software stack testing without hardware. The class implements all mandatory, required and Pulsar specific SCPI calls. Call reponses are largely artifically constructed to be inline with the call’s functionality (e.g. *IDN? returns valid, but artificial IDN data.) To assist development, the Q1ASM assembler has been completely implemented. Please have a look at the call’s implentation to know what to expect from its response.

__init__(cfg_format: str) None[source]

Create Pulsar dummy transport class.

Parameters

cfg_format (str) – Configuration format based on struct.pack format used to calculate configration transaction size.

close() None[source]

Close and resets Pulsar dummy transport class.

write(cmd_str: str) None[source]

Write command to Pulsar dummy. Stores command in command history (see ieee488_2.transport.pulsar_dummy_transport.get_cmd_hist()).

Parameters

cmd_str (str) – Command

write_binary(data: bytes) None[source]

Write binary data to Pulsar dummy. Stores command in command history (see ieee488_2.transport.pulsar_dummy_transport.get_cmd_hist()).

Parameters

data (bytes) – Binary data

read_binary(size: int) bytes[source]

Read binary data from Pulsar dummy.

Parameters

size (int) – Number of bytes

Returns

Binary data array of length “size”.

Return type

bytes

readline() str[source]

Read data from Pulsar dummy.

Returns

String with data.

Return type

str

get_cmd_hist() list[source]

Get list of every executed command since the initialization or reset of the class.

Returns

List of executed command strings including arguments (does not include binary data argument).

Return type

list