msl.equipment.vxi11 module
Implementation of the VXI-11 protocol.
VXI-11 is a client-service model to send messages through a network. The messages are formatted using the Remote Procedure Call protocol [RFC-1057] and are encoded/decoded using the eXternal Data Representation standard [RFC-1014].
References
VXI-11 – TCP/IP Instrument Protocol Specification (Revision 1.0), VXIbus Consortium, July 1995.
RFC-1057 – RPC: Remote Procedure Call Protocol Specification (Version 2), Sun Microsystems, June 1988.
RFC-1014 – XDR: External Data Representation Standard, Sun Microsystems, June 1987.
- class msl.equipment.vxi11.OperationFlag(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
VXI-11: Additional information concerning how a request is carried out.
- NULL = 0
- WAITLOCK = 1
- END = 8
- TERMCHRSET = 128
- class msl.equipment.vxi11.MessageType(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
RPC: The message type.
- CALL = 0
- REPLY = 1
- class msl.equipment.vxi11.ReplyStatus(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
RPC: Message reply status.
- MSG_ACCEPTED = 0
- MSG_DENIED = 1
- class msl.equipment.vxi11.AcceptStatus(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
RPC: Message accepted status.
- SUCCESS = 0
- PROG_UNAVAIL = 1
- PROG_MISMATCH = 2
- PROC_UNAVAIL = 3
- GARBAGE_ARGS = 4
- class msl.equipment.vxi11.RejectStatus(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
RPC: Message rejected status.
- RPC_MISMATCH = 0
- AUTH_ERROR = 1
- class msl.equipment.vxi11.AuthStatus(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
RPC: Authorization status.
- AUTH_BADCRED = 1
- AUTH_REJECTEDCRED = 2
- AUTH_BADVERF = 3
- AUTH_REJECTEDVERF = 4
- AUTH_TOOWEAK = 5
- class msl.equipment.vxi11.RPCClient(host)[source]
Bases:
object
Remote Procedure Call implementation for a client.
- Parameters:
host (
str
) – The hostname or IP address of the remote device.
- append(data)[source]
Append data to the body of the current RPC message.
- Parameters:
data (
bytes
ormemoryview
) – The data to append.
- append_opaque(text)[source]
Append a variable-length string to the body of the current RPC message.
- Parameters:
text (
memoryview
,bytes
orstr
) – The data to append.
- get_buffer()[source]
Get the data in the buffer.
- Returns:
bytearray
– The data in the current RPC message.
- get_port(prog, vers, prot, timeout=10)[source]
Call the Port Mapper procedure to determine which port to use for a program.
This method will automatically open and close the socket connection.
- Parameters:
prog (
int
) – The program number to get the port number of.vers (
int
) – The version number of prog.prot (
int
) – The socket protocol family type to use when sending requests to prog (IPPROTO_TCP
orIPPROTO_UDP
).timeout (
float
orNone
, optional) – The maximum number of seconds to wait to get the port value.
- Returns:
int
– The port number that corresponds to prog.
- interrupt_handler()[source]
Override this method to be notified of a service interrupt.
This method gets called if an interrupt is received during a
read()
. It does not continuously poll the device.
- read()[source]
Read an RPC message, check for errors, and return the procedure-specific data.
- Returns:
memoryview
– The procedure-specific data.
- set_timeout(timeout)[source]
Set the socket timeout value.
- Parameters:
timeout (
float
) – The timeout, in seconds, to use for the socket.
- static unpack_opaque(data)[source]
Unpack and return a variable-length string.
- Parameters:
data (
bytes
,bytearray
ormemoryview
) – The data to unpack.- Returns:
bytes
,bytearray
ormemoryview
– The unpacked data.
- check_reply(message)[source]
Checks the message for errors and returns the procedure-specific data.
- Parameters:
message (
memoryview
) – The reply from an RPC message.- Returns:
memoryview
orNone
– The reply orNone
if the transaction id does not match the value that was used in the correspondingwrite()
call.
- class msl.equipment.vxi11.VXIClient(host)[source]
Bases:
RPCClient
Base class for a VXI-11 program.
- Parameters:
host (
str
) – The hostname or IP address of the remote device.
- read_reply()[source]
Check the RPC message for an error and return the remaining data.
- Returns:
memoryview
– The reply data.
- class msl.equipment.vxi11.CoreClient(host)[source]
Bases:
VXIClient
Communicate with the Device Core program on the remote device.
- Parameters:
host (
str
) – The hostname or IP address of the remote device.
- create_link(device, lock_device, lock_timeout)[source]
Create a link.
- Parameters:
- Returns:
int
– The link ID.int
– The port number of the Device Async program (seeAsyncClient
).int
– The maximum data size the device will accept on adevice_write()
.
- device_write(lid, io_timeout, lock_timeout, flags, data)[source]
Write data to the specified device.
- Parameters:
lid (
int
) – Link id fromcreate_link()
.io_timeout (
int
) – Time, in milliseconds, to wait for I/O to complete.lock_timeout (
int
) – Time, in milliseconds, to wait on a lock.flags (
int
orOperationFlag
) – Operation flags to use.data (
memoryview
,bytes
orstr
) – The data to write.
- Returns:
int
– The number of bytes written.
- device_read(lid, request_size, io_timeout, lock_timeout, flags, term_char)[source]
Read data from the device.
- Parameters:
lid (
int
) – Link id fromcreate_link()
.request_size (
int
) – The number of bytes requested.io_timeout (
int
) – Time, in milliseconds, to wait for I/O to complete.lock_timeout (
int
) – Time, in milliseconds, to wait on a lock.flags (
int
orOperationFlag
) – Operation flags to use.term_char (
int
) – The termination character. Valid only if flags isTERMCHRSET
.
- Returns:
int
– The reason(s) the read completed.memoryview
– A view of the data (the RPC header is removed).
- device_readstb(lid, flags, lock_timeout, io_timeout)[source]
Read the status byte from the device.
- Parameters:
lid (
int
) – Link id fromcreate_link()
.flags (
int
orOperationFlag
) – Operation flags to use.lock_timeout (
int
) – Time, in milliseconds, to wait on a lock.io_timeout (
int
) – Time, in milliseconds, to wait for I/O to complete.
- Returns:
int
– The status byte.
- device_trigger(lid, flags, lock_timeout, io_timeout)[source]
Send a trigger to the device.
- Parameters:
lid (
int
) – Link id fromcreate_link()
.flags (
int
orOperationFlag
) – Operation flags to use.lock_timeout (
int
) – Time, in milliseconds, to wait on a lock.io_timeout (
int
) – Time, in milliseconds, to wait for I/O to complete.
- device_clear(lid, flags, lock_timeout, io_timeout)[source]
Send the clear command to the device.
- Parameters:
lid (
int
) – Link id fromcreate_link()
.flags (
int
orOperationFlag
) – Operation flags to use.lock_timeout (
int
) – Time, in milliseconds, to wait on a lock.io_timeout (
int
) – Time, in milliseconds, to wait for I/O to complete.
- device_remote(lid, flags, lock_timeout, io_timeout)[source]
Place the device in a remote state wherein all programmable local controls are disabled.
- Parameters:
lid (
int
) – Link id fromcreate_link()
.flags (
int
orOperationFlag
) – Operation flags to use.lock_timeout (
int
) – Time, in milliseconds, to wait on a lock.io_timeout (
int
) – Time, in milliseconds, to wait for I/O to complete.
- device_local(lid, flags, lock_timeout, io_timeout)[source]
Place the device in a local state wherein all programmable local controls are enabled.
- Parameters:
lid (
int
) – Link id fromcreate_link()
.flags (
int
orOperationFlag
) – Operation flags to use.lock_timeout (
int
) – Time, in milliseconds, to wait on a lock.io_timeout (
int
) – Time, in milliseconds, to wait for I/O to complete.
- device_lock(lid, flags, lock_timeout)[source]
Acquire a device’s lock.
- Parameters:
lid (
int
) – Link id fromcreate_link()
.flags (
int
orOperationFlag
) – Operation flags to use.lock_timeout (
int
) – Time, in milliseconds, to wait on a lock.
- device_unlock(lid)[source]
Release a lock acquired by
device_lock()
.- Parameters:
lid (
int
) – Link id fromcreate_link()
.
- device_enable_srq(lid, enable, handle)[source]
Enable or disable the sending of device_intr_srq RPCs by the network instrument server.
- Parameters:
lid (
int
) – Link id fromcreate_link()
.enable (
bool
) – Whether to enable or disable interrupts.handle (
bytes
) – Host specific data (maximum length is 40 characters).
- device_docmd(lid, flags, io_timeout, lock_timeout, cmd, network_order, datasize, data_in)[source]
Allows for a variety of operations to be executed.
- Parameters:
lid (
int
) – Link id fromcreate_link()
.flags (
int
orOperationFlag
) – Operation flags to use.io_timeout (
int
) – Time, in milliseconds, to wait for I/O to complete.lock_timeout (
int
) – Time, in milliseconds, to wait on a lock.cmd (
int
) – Which command to execute.network_order (
bool
) – Client’s byte order.datasize (
int
) – Size of individual data elements.
- Returns:
bytes
– The results defined by cmd.
- destroy_link(lid)[source]
Destroy the link.
- Parameters:
lid (
int
) – Link id fromcreate_link()
.
- class msl.equipment.vxi11.AsyncClient(host)[source]
Bases:
VXIClient
Communicate with the Device Async program on the remote device.
- Parameters:
host (
str
) – The hostname or IP address of the remote device.
- device_abort(lid)[source]
Stops an in-progress call.
- Parameters:
lid (
int
) – Link id fromcreate_link()
.
- msl.equipment.vxi11.find_vxi11(*, ip: list[str] | None = None, timeout: float = 1) dict[str, dict[str, str | list[str]]] [source]
Find all VXI-11 devices that are on the network.
The RPC port-mapper protocol (RFC-1057, Appendix A) broadcasts a message via UDP to port 111 for VXI-11 device discovery.
- Parameters:
ip – The IP address(es) on the local computer to use to broadcast the discovery message. If not specified, broadcast on all network interfaces.
timeout – The maximum number of seconds to wait for a reply.
- Returns:
The information about the VXI-11 devices that were found.