pylablib.devices.Arduino package
Submodules
pylablib.devices.Arduino.base module
- exception pylablib.devices.Arduino.base.ArduinoError[source]
Bases:
DeviceError
Generic Arduino devices error
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception pylablib.devices.Arduino.base.ArduinoBackendError(exc)[source]
Bases:
ArduinoError
,DeviceBackendError
Generic Arduino backend communication error
- add_note()
Exception.add_note(note) – add a note to the exception
- 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, dtrrts=True)[source]
Bases:
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/querydtrrts – determines whether to use DTR/RTS signals for communication; generally, should be set to
True
on newer boards (e.g., Leonardo) and toFalse
on older boards (e.g., Uno); settingsdtrrts=True
on older boards leads to the board reset upon connection, and settingsdtrrts=False
on newer boards leads to the communications getting frozen
- Error
alias of
ArduinoError
- 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. Ifflush==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. Ifquery_delay>0
, it specifies the delay between write and subsequent read attempt. Ifflush==True
, then wait for flush_delay seconds after the write and read everything returned by the device.
- 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, settinginclude=-10
queries all available variables, which is equivalent toinclude="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, settinginclude=-10
queries all available variables, which is equivalent toinclude="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, settinginclude=-10
queries all available variables, which is equivalent toinclude="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)