qmi.core.transport
Implementation of the QMI_Transport class.
Functions
|
Create a bidirectional communication channel. |
Return a list of currently detected USBTMC transports. |
Classes
|
Byte stream transport via serial port. |
|
Base class for bidirectional data streams via socket network connection. |
|
Bidirectional byte stream via TCP network connection. |
QMI_Transport is the base class for bidirectional byte stream transport implementations, typically used to talk to instruments. |
|
|
An instance of QMI_UdpTransport represents a server-side UDP connection with a listening port to an instrument. |
|
Transport SCPI commands via USBTMC device class. |
|
VXI-11 based transport to a supported device. |
|
This class is for creating a transport-specific parser classes and has (static) methods that are used for parsing transport strings. |
- class qmi.core.transport.QMI_Transport
QMI_Transport is the base class for bidirectional byte stream transport implementations, typically used to talk to instruments.
An instance of QMI_Transport represents a channel that admits reading and writing of arbitrary byte sequences. Message boundaries are not preserved. Subclasses of QMI_Transport implement the transport API for specific types of communication channels.
Once created, a QMI_Transport needs to be opened via the open() method before reading and writing. When the application has finished using the transport, it must call the close() method to close the underlying channel and release system resources.
- open() None
Open the transport and claim associated resources.
- close() None
Close the transport and release associated resources.
This transport instance can never be used again after it has been closed.
Subclasses must override this method to close specific resources. When overriding this method, the subclass should make a call to this method before all resources are closed.
- write(data: bytes) None
Write a sequence of bytes to the transport.
When this method returns, all bytes are written to the transport or queued to be written to the transport.
An exception is raised if the transport is closed from the remote side before all bytes could be written.
Subclasses must override this method, if applicable.
- read(nbytes: int, timeout: float | None) bytes
Read a specified number of bytes from the transport.
This method blocks until the specified number of bytes are available, then returns the received bytes.
If “timeout” is not None and the timeout expires before the requested number of bytes are available, QMI_TimeoutException is raised and any available bytes remain in the input buffer. If “timeout” is None, this method waits until the requested number of bytes are received.
Subclasses must override this method, if applicable.
- Parameters:
nbytes – Number of bytes to read.
timeout – Maximum time to wait (in seconds), or None to wait indefinitely.
- Returns:
Received bytes.
- Raises:
QMI_TimeoutException – If the timeout expires before the requested number of bytes are available.
QMI_EndOfInputException – If the transport has been closed on the remote side before the requested number of bytes are available.
- read_until(message_terminator: bytes, timeout: float | None) bytes
Read a sequence of bytes ending in “message_terminator”.
This method blocks until the specified message terminator sequence is found, then returns the received bytes including the message terminator.
If “timeout” is not None and the timeout expires before the message terminator is received, QMI_TimeoutException is raised and any available bytes remain in the input buffer. If “timeout” is None, this method waits until the message terminator is received.
Subclasses must override this method, if applicable.
- Parameters:
message_terminator – Byte sequence terminating a message.
timeout – Maximum time to wait (in seconds), or None to wait indefinitely.
- Returns:
Received bytes, including the terminator.
- Raises:
QMI_TimeoutException – If the timeout expires before the requested number of bytes are available.
QMI_EndOfInputException – If the transport has been closed on the remote side and the end of the input is reached before the message terminator is found.
- read_until_timeout(nbytes: int, timeout: float) bytes
Read a sequence of bytes from the transport.
This method blocks until either the specified number of bytes are available or the timeout (in seconds) expires, whichever occurs sooner.
If timeout occurs, the partial sequence of available bytes is returned. This sequence may be empty if timeout occurs before any byte was available.
If the transport has been closed on the remote side, any remaining input bytes are returned (up to the maximum number of bytes requested). If there are no more bytes to read, QMI_EndOfInputException is raised.
Subclasses must override this method, if applicable.
- Parameters:
nbytes – Maximum number of bytes to read.
timeout – Maximum time to wait (in seconds).
- Returns:
Received bytes.
- Raises:
QMI_EndOfInputException – If the transport has been closed on the remote side and there are no more bytes to read.
- discard_read() None
Discard all bytes that are immediately available for reading.
- class qmi.core.transport.TransportDescriptorParser(interface: str, positionals: list[tuple[str, tuple[Type, bool]]], keywords: Mapping[str, tuple[Type, bool]])
This class is for creating a transport-specific parser classes and has (static) methods that are used for parsing transport strings.
- parse_parameter_strings(transport_descriptor: str, default_parameters: Mapping[str, Any] | None = None) dict[str, Any]
Method for parsing transport descriptor strings.
- Parameters:
transport_descriptor – The string to parse.
default_parameters – Dictionary of default parameters to be used if not present in the string.
- Returns:
A dictionary object of the parsed parameters.
- Return type:
- match_interface(transport_descriptor: str) bool
A method to check the transport descriptor is used with the correct parser class.
- class qmi.core.transport.QMI_SerialTransport(device: str, baudrate: int, bytesize: int = 8, parity: str = 'N', stopbits: float = 1.0, rtscts: bool = False)
Byte stream transport via serial port.
This class can also be used for “virtual” serial ports via USB.
- SERIAL_READ_TIMEOUT
Set a fixed read timeout on the serial port device. The actual specified timeout for read() and read_until() calls will be rounded up to a multiple of this fixed timeout. The timeout parameter of the serial port device must be fixed because changing the timeout causes reprogramming of the serial port parameters, which is a slow operation and can even cause data loss (with an FTDI device under Windows).
- close() None
Close the transport and release associated resources.
This transport instance can never be used again after it has been closed.
Subclasses must override this method to close specific resources. When overriding this method, the subclass should make a call to this method before all resources are closed.
- write(data: bytes) None
Write a sequence of bytes to the transport.
When this method returns, all bytes are written to the transport or queued to be written to the transport.
An exception is raised if the transport is closed from the remote side before all bytes could be written.
Subclasses must override this method, if applicable.
- read(nbytes: int, timeout: float | None) bytes
Read a specified number of bytes from the transport.
This method blocks until the specified number of bytes are available, then returns the received bytes.
If “timeout” is not None and the timeout expires before the requested number of bytes are available, QMI_TimeoutException is raised and any available bytes remain in the input buffer. If “timeout” is None, this method waits until the requested number of bytes are received.
Subclasses must override this method, if applicable.
- Parameters:
nbytes – Number of bytes to read.
timeout – Maximum time to wait (in seconds), or None to wait indefinitely.
- Returns:
Received bytes.
- Raises:
QMI_TimeoutException – If the timeout expires before the requested number of bytes are available.
QMI_EndOfInputException – If the transport has been closed on the remote side before the requested number of bytes are available.
- read_until(message_terminator: bytes, timeout: float | None) bytes
Read a sequence of bytes ending in “message_terminator”.
This method blocks until the specified message terminator sequence is found, then returns the received bytes including the message terminator.
If “timeout” is not None and the timeout expires before the message terminator is received, QMI_TimeoutException is raised and any available bytes remain in the input buffer. If “timeout” is None, this method waits until the message terminator is received.
Subclasses must override this method, if applicable.
- Parameters:
message_terminator – Byte sequence terminating a message.
timeout – Maximum time to wait (in seconds), or None to wait indefinitely.
- Returns:
Received bytes, including the terminator.
- Raises:
QMI_TimeoutException – If the timeout expires before the requested number of bytes are available.
QMI_EndOfInputException – If the transport has been closed on the remote side and the end of the input is reached before the message terminator is found.
- read_until_timeout(nbytes: int, timeout: float) bytes
Read a sequence of bytes from the transport.
This method blocks until either the specified number of bytes are available or the timeout (in seconds) expires, whichever occurs sooner.
If timeout occurs, the partial sequence of available bytes is returned. This sequence may be empty if timeout occurs before any byte was available.
If the transport has been closed on the remote side, any remaining input bytes are returned (up to the maximum number of bytes requested). If there are no more bytes to read, QMI_EndOfInputException is raised.
Subclasses must override this method, if applicable.
- Parameters:
nbytes – Maximum number of bytes to read.
timeout – Maximum time to wait (in seconds).
- Returns:
Received bytes.
- Raises:
QMI_EndOfInputException – If the transport has been closed on the remote side and there are no more bytes to read.
- discard_read() None
Discard all bytes that are immediately available for reading.
- open() None
Open the transport and claim associated resources.
- class qmi.core.transport.QMI_SocketTransport(host: str, port: int)
Base class for bidirectional data streams via socket network connection.
- MIN_PACKET_SIZE
The minimum packet size to read with read_until method.
- Type:
int
- MAX_PACKET_SIZE
The maximum packet size to read with read method.
- Type:
int
- close() None
Close the transport and release associated resources.
This transport instance can never be used again after it has been closed.
Subclasses must override this method to close specific resources. When overriding this method, the subclass should make a call to this method before all resources are closed.
- write(data: bytes) None
Write a sequence of bytes to the transport.
When this method returns, all bytes are written to the transport or queued to be written to the transport.
An exception is raised if the transport is closed from the remote side before all bytes could be written.
Subclasses must override this method, if applicable.
- read(nbytes: int, timeout: float | None = None) bytes
Read a specified number of bytes from the transport.
This method blocks until the specified number of bytes are available, then returns the received bytes.
If “timeout” is not None and the timeout expires before the requested number of bytes are available, QMI_TimeoutException is raised and any available bytes remain in the input buffer. If “timeout” is None, this method waits until the requested number of bytes are received.
Subclasses must override this method, if applicable.
- Parameters:
nbytes – Number of bytes to read.
timeout – Maximum time to wait (in seconds), or None to wait indefinitely.
- Returns:
Received bytes.
- Raises:
QMI_TimeoutException – If the timeout expires before the requested number of bytes are available.
QMI_EndOfInputException – If the transport has been closed on the remote side before the requested number of bytes are available.
- read_until(message_terminator: bytes, timeout: float | None = None) bytes
Read a sequence of bytes ending in “message_terminator”.
This method blocks until the specified message terminator sequence is found, then returns the received bytes including the message terminator.
If “timeout” is not None and the timeout expires before the message terminator is received, QMI_TimeoutException is raised and any available bytes remain in the input buffer. If “timeout” is None, this method waits until the message terminator is received.
Subclasses must override this method, if applicable.
- Parameters:
message_terminator – Byte sequence terminating a message.
timeout – Maximum time to wait (in seconds), or None to wait indefinitely.
- Returns:
Received bytes, including the terminator.
- Raises:
QMI_TimeoutException – If the timeout expires before the requested number of bytes are available.
QMI_EndOfInputException – If the transport has been closed on the remote side and the end of the input is reached before the message terminator is found.
- read_until_timeout(nbytes: int, timeout: float) bytes
Read a sequence of bytes from the transport.
This method blocks until either the specified number of bytes are available or the timeout (in seconds) expires, whichever occurs sooner.
If timeout occurs, the partial sequence of available bytes is returned. This sequence may be empty if timeout occurs before any byte was available.
If the transport has been closed on the remote side, any remaining input bytes are returned (up to the maximum number of bytes requested). If there are no more bytes to read, QMI_EndOfInputException is raised.
Subclasses must override this method, if applicable.
- Parameters:
nbytes – Maximum number of bytes to read.
timeout – Maximum time to wait (in seconds).
- Returns:
Received bytes.
- Raises:
QMI_EndOfInputException – If the transport has been closed on the remote side and there are no more bytes to read.
- discard_read() None
Discard all bytes that are immediately available for reading.
- open() None
Open the transport and claim associated resources.
- class qmi.core.transport.QMI_UdpTransport(host: str, port: int)
An instance of QMI_UdpTransport represents a server-side UDP connection with a listening port to an instrument. Client-side UDP connections are not supported.
The maximum UDP packet size is 64KB (including headers). For write and read functions, this means limitations. The write function we can check the data size to send and split into multiple messages. For read functions this is not possible and the client must limit the data size as necessary. If for read functions the receivable data size is larger than the size defined in recvfrom(<size>), an exception is raised.
- MIN_PACKET_SIZE
The minimum packet size to read with read method.
- Type:
int
- MAX_PACKET_SIZE
The maximum packet size to read with read_until method.
- Type:
int
- close() None
Close the transport and release associated resources.
This transport instance can never be used again after it has been closed.
Subclasses must override this method to close specific resources. When overriding this method, the subclass should make a call to this method before all resources are closed.
- write(data: bytes) None
Write a sequence of bytes to the transport.
When this method returns, all bytes are written to the transport or queued to be written to the transport.
An exception is raised if the transport is closed from the remote side before all bytes could be written.
Subclasses must override this method, if applicable.
- discard_read() None
Discard all bytes that are immediately available for reading.
- open() None
Open the transport and claim associated resources.
- read(nbytes: int, timeout: float | None = None) bytes
Read a specified number of bytes from the transport.
This method blocks until the specified number of bytes are available, then returns the received bytes.
If “timeout” is not None and the timeout expires before the requested number of bytes are available, QMI_TimeoutException is raised and any available bytes remain in the input buffer. If “timeout” is None, this method waits until the requested number of bytes are received.
Subclasses must override this method, if applicable.
- Parameters:
nbytes – Number of bytes to read.
timeout – Maximum time to wait (in seconds), or None to wait indefinitely.
- Returns:
Received bytes.
- Raises:
QMI_TimeoutException – If the timeout expires before the requested number of bytes are available.
QMI_EndOfInputException – If the transport has been closed on the remote side before the requested number of bytes are available.
- read_until(message_terminator: bytes, timeout: float | None = None) bytes
Read a sequence of bytes ending in “message_terminator”.
This method blocks until the specified message terminator sequence is found, then returns the received bytes including the message terminator.
If “timeout” is not None and the timeout expires before the message terminator is received, QMI_TimeoutException is raised and any available bytes remain in the input buffer. If “timeout” is None, this method waits until the message terminator is received.
Subclasses must override this method, if applicable.
- Parameters:
message_terminator – Byte sequence terminating a message.
timeout – Maximum time to wait (in seconds), or None to wait indefinitely.
- Returns:
Received bytes, including the terminator.
- Raises:
QMI_TimeoutException – If the timeout expires before the requested number of bytes are available.
QMI_EndOfInputException – If the transport has been closed on the remote side and the end of the input is reached before the message terminator is found.
- read_until_timeout(nbytes: int, timeout: float) bytes
Read a sequence of bytes from the transport.
This method blocks until either the specified number of bytes are available or the timeout (in seconds) expires, whichever occurs sooner.
If timeout occurs, the partial sequence of available bytes is returned. This sequence may be empty if timeout occurs before any byte was available.
If the transport has been closed on the remote side, any remaining input bytes are returned (up to the maximum number of bytes requested). If there are no more bytes to read, QMI_EndOfInputException is raised.
Subclasses must override this method, if applicable.
- Parameters:
nbytes – Maximum number of bytes to read.
timeout – Maximum time to wait (in seconds).
- Returns:
Received bytes.
- Raises:
QMI_EndOfInputException – If the transport has been closed on the remote side and there are no more bytes to read.
- class qmi.core.transport.QMI_TcpTransport(host: str, port: int, connect_timeout: float | None = 10)
Bidirectional byte stream via TCP network connection.
An instance of QMI_TcpTransport represents a client-side TCP connection to an instrument. Server-side TCP connections are not supported.
- DEFAULT_CONNECT_TIMEOUT
A default timeout period for connecting to TCP client. Default is 10 seconds.
- MIN_PACKET_SIZE
The minimum packet size to read with read method.
- Type:
int
- MAX_PACKET_SIZE
The maximum packet size to read with read_until method.
- Type:
int
- close() None
Close the transport and release associated resources.
This transport instance can never be used again after it has been closed.
Subclasses must override this method to close specific resources. When overriding this method, the subclass should make a call to this method before all resources are closed.
- write(data: bytes) None
Write a sequence of bytes to the transport.
When this method returns, all bytes are written to the transport or queued to be written to the transport.
An exception is raised if the transport is closed from the remote side before all bytes could be written.
Subclasses must override this method, if applicable.
- discard_read() None
Discard all bytes that are immediately available for reading.
- open() None
Open the transport and claim associated resources.
- read(nbytes: int, timeout: float | None = None) bytes
Read a specified number of bytes from the transport.
This method blocks until the specified number of bytes are available, then returns the received bytes.
If “timeout” is not None and the timeout expires before the requested number of bytes are available, QMI_TimeoutException is raised and any available bytes remain in the input buffer. If “timeout” is None, this method waits until the requested number of bytes are received.
Subclasses must override this method, if applicable.
- Parameters:
nbytes – Number of bytes to read.
timeout – Maximum time to wait (in seconds), or None to wait indefinitely.
- Returns:
Received bytes.
- Raises:
QMI_TimeoutException – If the timeout expires before the requested number of bytes are available.
QMI_EndOfInputException – If the transport has been closed on the remote side before the requested number of bytes are available.
- read_until(message_terminator: bytes, timeout: float | None = None) bytes
Read a sequence of bytes ending in “message_terminator”.
This method blocks until the specified message terminator sequence is found, then returns the received bytes including the message terminator.
If “timeout” is not None and the timeout expires before the message terminator is received, QMI_TimeoutException is raised and any available bytes remain in the input buffer. If “timeout” is None, this method waits until the message terminator is received.
Subclasses must override this method, if applicable.
- Parameters:
message_terminator – Byte sequence terminating a message.
timeout – Maximum time to wait (in seconds), or None to wait indefinitely.
- Returns:
Received bytes, including the terminator.
- Raises:
QMI_TimeoutException – If the timeout expires before the requested number of bytes are available.
QMI_EndOfInputException – If the transport has been closed on the remote side and the end of the input is reached before the message terminator is found.
- read_until_timeout(nbytes: int, timeout: float) bytes
Read a sequence of bytes from the transport.
This method blocks until either the specified number of bytes are available or the timeout (in seconds) expires, whichever occurs sooner.
If timeout occurs, the partial sequence of available bytes is returned. This sequence may be empty if timeout occurs before any byte was available.
If the transport has been closed on the remote side, any remaining input bytes are returned (up to the maximum number of bytes requested). If there are no more bytes to read, QMI_EndOfInputException is raised.
Subclasses must override this method, if applicable.
- Parameters:
nbytes – Maximum number of bytes to read.
timeout – Maximum time to wait (in seconds).
- Returns:
Received bytes.
- Raises:
QMI_EndOfInputException – If the transport has been closed on the remote side and there are no more bytes to read.
- class qmi.core.transport.QMI_UsbTmcTransport(vendorid: int, productid: int, serialnr: str)
Transport SCPI commands via USBTMC device class.
When running under Windows, this class depends on VISA for the actual USBTMC implementation.
When running under Linux, this class depends on python-usbtmc (and libusb) for the actual USBTMC implementation.
This class does not implement the full functionality of QMI_Transport. The issue is that USBTMC is fundamentally a message-oriented protocol, while QMI_Transport assumes a byte stream without message delimiters.
- Only the following operations are supported:
write() writes the specified bytes as a single USBTMC message.
read_until() reads a single USBTMC message (until the device indicates end-of-message) and returns the fetched bytes.
- DEFAULT_READ_TIMEOUT
Default timeout in seconds for USBTMC read transactions.
- WRITE_TIMEOUT
Timeout in seconds for USBTMC write transactions.
- close() None
Close the transport and release associated resources.
This transport instance can never be used again after it has been closed.
Subclasses must override this method to close specific resources. When overriding this method, the subclass should make a call to this method before all resources are closed.
- write(data: bytes) None
Send the specified data to the instrument as a single USBTMC message. A fixed timeout of 5 seconds is applied. If timeout occurs, the transfer is aborted and an exception is raised.
- Parameters:
data – The data to write in a byte string.
- read(nbytes: int, timeout: float | None) bytes
Read a specified number of bytes from the transport.
All bytes must belong to the same USBTMC message.
This method blocks until the specified number of bytes are available, then returns the received bytes. If timeout occurs, any partial read data is discarded and QMI_TimeoutException is raised.
- Parameters:
nbytes – Expected number of bytes to read.
timeout – Maximum time to wait in seconds (default: 60 seconds).
- Returns:
Received bytes.
- Raises:
QMI_TimeoutException – If the timeout expires before the requested number of bytes are available.
QMI_EndOfInputException – If an end-of-message indicator is received before the requested number of bytes is reached.
- read_until(message_terminator: bytes, timeout: float | None) bytes
The specified message_terminator is ignored. Instead, the instrument must autonomously indicate the end of the message according to the USBTMC protocol.
As the message_terminator is not used, we forward simply the call to the read_until_timeout call.
- Parameters:
message_terminator – This input is ignored.
timeout – Maximum time to wait (in seconds).
- Returns:
Received bytes.
- read_until_timeout(nbytes: int, timeout: float | None) bytes
Read a single USBTMC message from the instrument.
If the timeout expires before the message is received, the read is aborted and any data already received are discarded. In this case an empty bytes string is returned.
- Parameters:
nbytes – This input is ignored.
timeout – Maximum time to wait (in seconds).
- Returns:
Received bytes.
- discard_read() None
Discard all bytes that are immediately available for reading.
- static list_resources() list[str]
List available resources from USB connections. This should be implemented in deriving classes.
- Returns:
List of available resources in QMI’s USBTMC transport string format.
- Return type:
resources
- open() None
Open the transport and claim associated resources.
- class qmi.core.transport.QMI_Vxi11Transport(host: str)
VXI-11 based transport to a supported device.
- close() None
Close the transport and release associated resources.
This transport instance can never be used again after it has been closed.
Subclasses must override this method to close specific resources. When overriding this method, the subclass should make a call to this method before all resources are closed.
- write(data: bytes) None
Write a sequence of bytes to the transport.
When this method returns, all bytes are written to the transport or queued to be written to the transport.
An exception is raised if the transport is closed from the remote side before all bytes could be written.
Subclasses must override this method, if applicable.
- read(nbytes: int, timeout: float | None = None) bytes
Read a specified number of bytes from the transport.
This method blocks until the specified number of bytes are available, then returns the received bytes.
If “timeout” is not None and the timeout expires before the requested number of bytes are available, QMI_TimeoutException is raised and any available bytes remain in the input buffer. If “timeout” is None, this method waits until the requested number of bytes are received.
Subclasses must override this method, if applicable.
- Parameters:
nbytes – Number of bytes to read.
timeout – Maximum time to wait (in seconds), or None to wait indefinitely.
- Returns:
Received bytes.
- Raises:
QMI_TimeoutException – If the timeout expires before the requested number of bytes are available.
QMI_EndOfInputException – If the transport has been closed on the remote side before the requested number of bytes are available.
- read_until(message_terminator: bytes, timeout: float | None = None) bytes
Read a sequence of bytes ending in “message_terminator”.
This method blocks until the specified message terminator sequence is found, then returns the received bytes including the message terminator.
If “timeout” is not None and the timeout expires before the message terminator is received, QMI_TimeoutException is raised and any available bytes remain in the input buffer. If “timeout” is None, this method waits until the message terminator is received.
Subclasses must override this method, if applicable.
- Parameters:
message_terminator – Byte sequence terminating a message.
timeout – Maximum time to wait (in seconds), or None to wait indefinitely.
- Returns:
Received bytes, including the terminator.
- Raises:
QMI_TimeoutException – If the timeout expires before the requested number of bytes are available.
QMI_EndOfInputException – If the transport has been closed on the remote side and the end of the input is reached before the message terminator is found.
- read_until_timeout(nbytes: int, timeout: float) bytes
Read a sequence of bytes from the transport.
This method blocks until either the specified number of bytes are available or the timeout (in seconds) expires, whichever occurs sooner.
If timeout occurs, the partial sequence of available bytes is returned. This sequence may be empty if timeout occurs before any byte was available.
If the transport has been closed on the remote side, any remaining input bytes are returned (up to the maximum number of bytes requested). If there are no more bytes to read, QMI_EndOfInputException is raised.
Subclasses must override this method, if applicable.
- Parameters:
nbytes – Maximum number of bytes to read.
timeout – Maximum time to wait (in seconds).
- Returns:
Received bytes.
- Raises:
QMI_EndOfInputException – If the transport has been closed on the remote side and there are no more bytes to read.
- discard_read() None
Discard all bytes that are immediately available for reading.
- open() None
Open the transport and claim associated resources.
- qmi.core.transport.list_usbtmc_transports() list[str]
Return a list of currently detected USBTMC transports.
- qmi.core.transport.create_transport(transport_descriptor: str, default_attributes: dict[str, Any] | None = None) QMI_Transport
Create a bidirectional communication channel.
A transport_descriptor specifies all information that may be needed to open a transport, including parameters such as port number, baud rate, etc. Certain entries are obligatory, like giving the host IP address for UDP and TCP transports. Other entries are optional, and are indicated with <, > characters. For those entries, if not given, the string format below indicates the default value used in that case with the =value part. Do not include the <, > characters in the strings.
- String format:
VXI-11 instrument: “vxi11:host”
UDP connection: “udp:host<:port>”
TCP connection: “tcp:host<:port><:connect_timeout=10>”
Serial port: “serial:device<:baudrate=115200><:databits=8><:parity=N><:stopbits=1>”
USBTMC device: “usbtmc:vendorid:productid:serialnr”
GPIB device: “gpib:<board=None:>primary_addr<:secondary_addr=None><:connect_timeout=30.0>”
- UDP, TCP and VXI-11:
“host” (for UDP, TCP & VXI-11 transports) specifies the host name or IP address of the UDP server/TCP client. Numerical IPv6 addresses must be enclosed in square brackets, e.g. “tcp:[2620:0:2d0:200::8]:5000”.
“port” (for UDP and TCP transports) specifies the UDP/TCP port number of the server/client.
“connect_timeout” is TCP connection timeout.
- Serial:
“device” is the name of the serial port, for example “COM3” or “/dev/ttyUSB0”.
“baudrate” specifies the number of bits per second. This attribute is only required for instruments with a configurable baud rate.
“bytesize” specifies the number of data bits per character (valid range 5 - 8). This attribute is only required for instruments with a configurable character format.
“parity” specifies the parity bit (‘O’ or ‘E’ or ‘’N’). This attribute is only required for instruments with a configurable character format.
“stopbits” specifies the number of stop bits (1 or 1.5 or 2). This attribute is only required for instruments with a configurable character format.
“rtscts” enables or disables RTS/CTS flow control. Possible values are True and False; the default is False.
- USBTMC:
“vendorid” is the USB Vendor ID as a decimal number or as hexadecimal with 0x prefix.
“productid” is the USB Product ID as a decimal number or as hexadecimal with 0x prefix.
“serialnr” is the USB serial number string.
- GPIB:
“primary_addr” is GPIB device number (integer).
“board” is optional GPIB interface number (in VISA syntax GPIB[board]::…).
“secondary_addr” is optional secondary device address number.
“connect_timeout” is for opening resource for GPIB device, in seconds.