lightlab.equipment.visa_bases.driver_base module

Summary

Classes:

InstrumentSessionBase Base class for Instrument sessions, to be inherited and specialized by VISAObject and PrologixGPIBObject
TCPSocketConnection Opens a TCP socket connection, much like netcat.

Data:

CR str(object=’‘) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
LF str(object=’‘) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Reference

class InstrumentSessionBase[source]

Bases: abc.ABC

Base class for Instrument sessions, to be inherited and specialized by VISAObject and PrologixGPIBObject

spoll()[source]
LLO()[source]
LOC()[source]
open()[source]
close()[source]
write()[source]
query()[source]
wait()[source]
clear()[source]
query_raw_binary()[source]
query_ascii_values(message, converter='f', separator=', ', container=<class 'list'>)[source]

Taken from pvisa.

instrID()[source]

Returns the *IDN? string

timeout
class TCPSocketConnection(ip_address, port, timeout=2, termination='n')[source]

Bases: object

Opens a TCP socket connection, much like netcat.

Usage:
s = TCPSocketConnection(‘socket-server.school.edu’, 1111) s.connect() # connects to socket and leaves it open s.send(‘command’) # sends the command through the socket r = s.recv(1000) # receives a message of up to 1000 bytes s.disconnect() # shuts down connection
Parameters:
  • ip_address (str) – hostname or ip address of the socket server
  • port (int) – socket server’s port number
  • timeout (float) – timeout in seconds for establishing socket connection to socket server, default 2.
port = None

socket server’s port number

connect()[source]

Connects to the socket and leaves the connection open. If already connected, does nothing.

Returns:socket object.
disconnect()[source]

If connected, disconnects and kills the socket.

connected()[source]

Context manager for ensuring that the socket is connected while sending and receiving commands to remote socket. This is safe to use everywhere, even if the socket is previously connected. It can also be nested. This is useful to bundle multiple commands that you desire to be executed together in a single socket connection, for example:

def query(self, query_msg, msg_length=2048):
    with self.connected():
        self._send(self._socket, query_msg)
        recv = self._recv(self._socket, msg_length)
    return recv
startup()[source]
send(value)[source]

Sends an ASCII string to the socket server. Auto-connects if necessary.

Parameters:value (str) – value to be sent
recv(msg_length=2048)[source]

Receives an ASCII string from the socket server. Auto-connects if necessary.

Parameters:msg_length (int) – maximum message length.
query(query_msg, msg_length=2048)[source]