Skip to content

MeasmaticDevice#

The Measmatic device class enables communication with any device that can be controlled using TCP/IP, GPIB or RS232. The class provides functionality for sending and receiving commands to the device. It is the base class for all device classes that are internal to Measmatic. For custom devices that are defined by Python scripts, the base class is Device.


property device_class#

Gets the class of the device.

Returns#

Type Description
str The class of the device.

property device_type_caption#

Gets the type description for the device.

Returns#

Type Description
str The type description for the device.

property guid#

Gets the unique identifier for this device as UUID.

Returns#

Type Description
str The unique identifier for this device as UUID.

property identification_caption#

Gets a human-readable identifier for the device.

Returns#

Type Description
str A human-readable identifier for the device.

property identification_raw_string#

Gets the device response on *IDN?

Returns#

Type Description
str The device response on *IDN? .

property name#

Gets the name of the device.

Returns#

Type Description
str The name of the device.

method query(request: str)#

Sends a query to the device and returns its response.

Parameters#

Name Description
request The string that is sent to the device.

Returns#

Type Description
str The device response on the request.

Example#

Sends *IDN? to the device and puts the response into the variable response

response = device.query("*IDN?")


method receive_binary(number_of_bytes: int)#

Reads a specified number of bytes from the input buffer of the device.

Parameters#

Name Description
number_of_bytes The number of bytes to read.

Returns#

Type Description
byte The bytes that were read from the device.

Example#

Reads 10 bytes from the device

response_bytes = device.receive_binary(10)

method receive_line()#

Reads one line from the input buffer of the device.

Returns#

Type Description
str The first line of the device's input buffer.

Example#

Reads the first line of the response from the last request that was sent to the device.

response = device.receive_line()

method send_binary(data_bytes: list[byte])#

Sends the specified byte array to the device.

Parameters#

Name Description
data_bytes The bytes to send.

Example#

Sends "Hello World!" as UTF-8 encoded bytes to the device

hello_world = bytearray("Hello World!", 'utf-8')
device.send_binary(hello_world)

method send_line(request: str)#

Sends a command to the device.

Parameters#

Name Description
request The string that is sent to the device.

Example#

Send *RST to the device

device.send_line("*RST")