IEEE488.2

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

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

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

IEEE488.2

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.2.1/ieee488_2/transport.py'>)

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.2.1/ieee488_2/transport.py'>) None

Creates IEEE488.2 interface object.

Parameters

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

Transport

class ieee488_2.transport.transport

Bases: object

Abstract base class for data transport to instruments.

close() None

Abstract method to close instrument.

write(cmd_str: str) None

Abstract method to write command to instrument.

Parameters

cmd_str (str) – Command

write_binary(data: bytes) None

Abstract method to write binary data to instrument.

Parameters

data (bytes) – Binary data

read_binary(size: int) bytes

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

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 = 10.0, snd_buf_size: int = 524288)

Bases: ieee488_2.transport.transport

Class for data transport of IP socket.

__init__(host: str, port: int = 5025, timeout: float = 10.0, snd_buf_size: int = 524288) None

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

Close IP socket.

write(cmd_str: str) None

Write command to instrument over IP socket.

Parameters

cmd_str (str) – Command

write_binary(data: bytes) None

Write binary data to instrument over IP socket.

Parameters

data (bytes) – Binary data

read_binary(size: int) bytes

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

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 = '')

Bases: ieee488_2.transport.transport

Class implementing file I/O to support driver testing.

__init__(out_file_name: str, in_file_name: str = '') None

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

Close file descriptors.

write(cmd_str: str) None

Write command to file.

Parameters

cmd_str (str) – Command

write_binary(data: bytes) None

Write binary data to file.

Parameters

data (bytes) – Binary data

read_binary(size: int) bytes

Read binary data from file.

Parameters

size (int) – Number of bytes

Returns

Binary data array of length “size”.

Return type

bytes

readline() str

Read data from file.

Returns

String with data.

Return type

str

class ieee488_2.transport.pulsar_dummy_transport(cfg_format: str)

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

Create Pulsar dummy transport class.

Parameters

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

close() None

Close and resets Pulsar dummy transport class.

write(cmd_str: str) None

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

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

Read binary data from Pulsar dummy.

Parameters

size (int) – Number of bytes

Returns

Binary data array of length “size”.

Return type

bytes

readline() str

Read data from Pulsar dummy.

Returns

String with data.

Return type

str

get_cmd_hist() list

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