pylab_ml.base_instrument.LocalInstrument
- class LocalInstrument(*args, **kwargs)[source]
Bases:
objectClass for local instruments that are connected via interfaces such as GPIB, USB, or serial. This class handles the initialization and communication with the instrument using the PyVISA library.
Methods
__init__()Check if the user is in the 'dialout' group on UNIX systems, which is required for accessing serial ports.
idtry(instrument)Attempt to fix VISA termination characters to Query IDN.
list_com()List all COM ports available on the system.
List all USB serial ports available on the system.
resource_id(interface, address)Generate the resource ID for the instrument based on its interface and address.
search4vidpid(addr[, backend])Search for VID:PID in the addr.
serial_list([backend])List all devices from serial-port (USB-Ports).
Attributes
has_visa- check_group_dialout()[source]
Check if the user is in the ‘dialout’ group on UNIX systems, which is required for accessing serial ports.
- Returns:
True if the user is in the ‘dialout’ group or if the platform is Windows, False otherwise.
- Return type:
bool
- idtry(instrument)[source]
Attempt to fix VISA termination characters to Query IDN.
- Parameters:
instrument (Instrument) – The instrument object for which to attempt the IDN query.
- Returns:
The IDN string returned by the instrument, with termination characters removed.
- Return type:
str
- pyvisa = <module 'pyvisa' from '/home/runner/miniconda3/envs/test/lib/python3.9/site-packages/pyvisa/__init__.py'>
- resource_id(interface, address)[source]
Generate the resource ID for the instrument based on its interface and address.
- Parameters:
interface (Interface) – The interface type of the instrument (e.g., GPIB, USB, serial).
address (str or int) – The address of the instrument.
- Returns:
id_name – The resource ID string for the instrument.
- Return type:
str
- search4vidpid(addr, backend=None)[source]
Search for VID:PID in the addr.
- Parameters:
addr (str or int) – The address of the device in the format ‘VID:PID’ (e.g., ‘16C0:0483’).
backend (str, optional) – The backend to use for the search.
- Returns:
The device name or address if found, otherwise None.
- Return type:
str or int