pylablib.devices.Arduino package

Submodules

pylablib.devices.Arduino.base module

exception pylablib.devices.Arduino.base.ArduinoError[source]

Bases: pylablib.core.devio.base.DeviceError

Generic Arduino devices error

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception pylablib.devices.Arduino.base.ArduinoBackendError(exc)[source]

Bases: pylablib.devices.Arduino.base.ArduinoError, pylablib.core.devio.comm_backend.DeviceBackendError

Generic Arduino backend communication error

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class pylablib.devices.Arduino.base.IArduinoDevice(port, rate=9600, timeout=10.0, term_write='n', term_read='n', flush_before_op=True)[source]

Bases: pylablib.core.devio.comm_backend.ICommBackendWrapper

Generic Arduino device.

Parameters:
  • port – serial port name
  • rate – baud rate
  • timeout – default communication timeout
  • term_write – default write terminating character (automatically appended on every sent message)
  • term_read – default read terminating character (used to determine when the incoming message is received completely)
  • flush_before_op – if True (default), automatically flush input buffer on comm/query
Error

alias of ArduinoError

reset_board()[source]

Reset the board by pulsing the DTR and RTS lines

comm(comm, timeout=None, flush=False, flush_delay=0.02)[source]

Send a device command.

If timeout is not None, it specifies a custom timeout for the operation. If flush==True, then wait for flush_delay seconds after the write and read everything returned by the device.

query(query, timeout=None, query_delay=0, flush=False, flush_delay=0.02)[source]

Send a device query and return the reply.

If timeout is not None, it specifies a custom timeout for the reply read operation. If query_delay>0, it specifies the delay between write and subsequent read attempt. If flush==True, then wait for flush_delay seconds after the write and read everything returned by the device.

class NoParameterCaller(device, kind)

Bases: object

Class to simplify calling functions without a parameter

apply_settings(settings)

Apply the settings.

settings is the dict {name: value} of the device available settings. Non-applicable settings are ignored.

close()

Close the backend

get_device_variable(key)

Get the value of a settings, status, or full info parameter

get_full_info(include=0)

Get dict {name: value} containing full device information (including status and settings).

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

get_full_status(include=0)

Get dict {name: value} containing the device status (including settings).

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

get_settings(include=0)

Get dict {name: value} containing all the device settings.

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

is_opened()

Check if the device is connected

lock(timeout=None)

Lock the access to the device from other threads/processes (isn’t necessarily implemented)

locking(timeout=None)

Context manager for lock & unlock

open()

Open the backend

set_device_variable(key, value)

Set the value of a settings parameter

unlock()

Unlock the access to the device from other threads/processes (isn’t necessarily implemented)

Module contents