msl.equipment.connection_prologix module

Uses Prologix hardware to establish a connection to the equipment.

class msl.equipment.connection_prologix.ConnectionPrologix(record)[source]

Bases: Connection

Uses Prologix hardware to establish a connection to the equipment.

For the GPIB-ETHERNET Controller, the format of the address is Prologix::HOST::1234::PAD[::SAD], where PAD (Primary Address) is a decimal value between 0 and 30 and SAD (Secondary Address) is a decimal value between 96 and 126. SAD is optional. For example, Prologix::192.168.1.110::1234::6 or Prologix::192.168.1.110::1234::6::96.

For the GPIB-USB Controller, the format of the address is Prologix::PORT::PAD[::SAD], where PAD (Primary Address) is a decimal value between 0 and 30 and SAD (Secondary Address) is a decimal value between 96 and 126. SAD is optional. For example, Prologix::COM3::6 or Prologix::/dev/ttyUSB0::6::112.

The properties for a Prologix connection supports the following key-value pairs in the Connections Database and any of the key-value pairs supported by ConnectionSerial or ConnectionSocket (depending on whether a GPIB-USB or a GPIB-ETHERNET Controller is used):

'eoi': int, 0 or 1
'eos': int, 0, 1, 2 or 3
'eot_char': int, an ASCII value less than 256
'eot_enable': int, 0 or 1
'mode': int, 0 or 1 [default: 1]
'read_tmo_ms': int, a timeout value between 1 and 3000 milliseconds

The backend value must be equal to MSL to use this class for the communication system. This is achieved by setting the value in the Backend field for a connection record in the Connections Database to be MSL.

Do not instantiate this class directly. Use the connect() method to connect to the equipment.

Parameters:

record (EquipmentRecord) – A record from an Equipment-Register Database.

controllers = {}

A dict of all Prologix Controllers that are being used to communicate with GPIB devices.

selected_addresses = {}

A dict of the currently-selected GPIB address for all Prologix Controllers.

property encoding

The encoding that is used for read() and write() operations.

Type:

str

property encoding_errors

The error handling scheme to use when encoding and decoding messages.

For example: strict, ignore, replace, xmlcharrefreplace, backslashreplace

Type:

str

property read_termination

The termination character sequence that is used for the read() method.

Reading stops when the equipment stops sending data or the read_termination character sequence is detected. If you set the read_termination to be equal to a variable of type str it will automatically be encoded.

Type:

bytes or None

property write_termination

The termination character sequence that is appended to write() messages.

If you set the write_termination to be equal to a variable of type str it will automatically be encoded.

Type:

bytes or None

property max_read_size

The maximum number of bytes that can be read().

Type:

int

property timeout

The timeout, in seconds, for read() and write() operations.

Type:

float or None

property rstrip

Whether to remove trailing whitespace from read() messages.

Type:

bool

property controller

ConnectionSerial or ConnectionSocket: The connection to the Prologix Controller for this equipment.

Depends on whether a GPIB-USB or a GPIB-ETHERNET Controller is being used to communicate with the equipment.

disconnect()[source]

Calling this method does not close the underlying ConnectionSerial or ConnectionSocket connection to the Prologix Controller since the connection to the Prologix Controller may still be required to send messages to other devices via GPIB.

Calling this method sets the controller to be None.

group_execute_trigger(*addresses)[source]

Send the Group Execute Trigger command to equipment at the specified addresses.

Up to 15 addresses may be specified. If no address is specified then the Group Execute Trigger command is issued to the currently-addressed equipment.

Parameters:

addresses

The primary (and optional secondary) GPIB addresses. If a secondary address is specified then it must follow its corresponding primary address. For example:

  • group_execute_trigger(1, 11, 17) \(\rightarrow\) primary, primary, primary

  • group_execute_trigger(3, 96, 12, 21) \(\rightarrow\) primary, secondary, primary, primary

Returns:

int – The number of bytes written.

read(**kwargs)[source]

Read a message from the equipment.

Parameters:

**kwargs – All keyword arguments are passed to read().

Returns:

str, bytes or ndarray – The message from the equipment. If dtype is specified, then the message is returned as an ndarray, if decode is True then the message is returned as a str, otherwise the message is returned as bytes.

write(message, **kwargs)[source]

Write a message to the equipment.

Parameters:
  • message (str or bytes) – The message to write to the equipment.

  • **kwargs – All keyword arguments are passed to write().

Returns:

int – The number of bytes written.

query(message, **kwargs)[source]

Convenience method for performing a write() followed by a read().

Parameters:
  • message (str or bytes) – The message to write to the equipment.

  • **kwargs – All keyword arguments are passed to query().

Returns:

str, bytes or ndarray – The message from the equipment. If dtype is specified, then the message is returned as an ndarray, if decode is True then the message is returned as a str, otherwise the message is returned as bytes.

property query_auto

Whether to send ++auto 1 before and ++auto 0 after a query() to the Prologix Controller.

Type:

bool

version()[source]

Get the version of the Prologix Controller.

Returns:

str – The type of the Controller (GPIB-USB or GPIB-ETHERNET) and the version of the firmware.

static parse_address(address)[source]

Parse the address to determine the connection class and the GPIB address.

Parameters:

address (str) – The address of a ConnectionRecord.

Returns:

dict or None – If address is valid for a Prologix connection then the key-value pairs are:

otherwise None is returned.

msl.equipment.connection_prologix.find_prologix(*, ip: list[str] | None = None, timeout: float = 1) dict[str, str | list[str]][source]

Find all Prologix ENET-GPIB devices that are on the network.

To resolve the MAC address of a Prologix device, the arp program must be installed. On Linux, install net-tools. On Windows and macOS, arp should already be installed.

Parameters:
  • ip – The IP address(es) on the local computer to use to search for Prologix ENET-GPIB devices. If not specified, uses all network interfaces.

  • timeout – The maximum number of seconds to wait for a reply.

Returns:

The information about the Prologix ENET-GPIB devices that were found.