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.ABCBase class for Instrument sessions, to be inherited and specialized by VISAObject and PrologixGPIBObject
-
query_ascii_values(message, converter='f', separator=', ', container=<class 'list'>)[source]¶ Taken from pvisa.
-
timeout¶
-
-
class
TCPSocketConnection(ip_address, port, timeout=2, termination='n')[source]¶ Bases:
objectOpens 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: -
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.
-
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
-
send(value)[source]¶ Sends an ASCII string to the socket server. Auto-connects if necessary.
Parameters: value (str) – value to be sent