eric7.MicroPython.MicroPythonDeviceInterface

Module implementing some file system commands for MicroPython.

Global Attributes

None

Classes

MicroPythonDeviceInterface Class implementing an interface to talk to a connected MicroPython device.

Functions

None


MicroPythonDeviceInterface

Class implementing an interface to talk to a connected MicroPython device.

Signals

dataReceived(data)
emitted to send data received via the serial connection for further processing
executeAsyncFinished()
emitted to indicate the end of an asynchronously executed list of commands (e.g. a script)

Derived from

QObject

Class Attributes

PasteModePrompt
TracebackMarker

Class Methods

None

Methods

MicroPythonDeviceInterface Constructor
__execute_paste Private method to send commands to the connected device using 'paste' mode and return the result.
__execute_raw Private method to send commands to the connected device using 'raw REPL' mode and return the result.
__pasteOff Private method to switch 'paste' mode off.
__pasteOn Private method to switch the connected device to 'paste' mode.
__rawOff Private method to switch 'raw' mode off.
__rawOn Private method to switch the connected device to 'raw' mode.
__readSerial Private slot to read all available serial data and emit it with the "dataReceived" signal for further processing.
connectToDevice Public slot to start the manager.
disconnectFromDevice Public slot to stop the thread.
execute Public method to send commands to the connected device and return the result.
executeAsync Public method to execute a series of commands over a period of time without returning any result (asynchronous execution).
executeAsyncPaste Public method to execute a series of commands over a period of time without returning any result (asynchronous execution).
handlePreferencesChanged Public slot to handle a change of the preferences.
isConnected Public method to get the connection status.
probeDevice Public method to check the device is responding.
write Public method to write data to the connected device.

Static Methods

None

MicroPythonDeviceInterface (Constructor)

MicroPythonDeviceInterface(parent=None)

Constructor

parent (QObject)
reference to the parent object

MicroPythonDeviceInterface.__execute_paste

__execute_paste(commands, timeout=0)

Private method to send commands to the connected device using 'paste' mode and return the result.

If no serial connection is available, empty results will be returned.

commands (str or list of str)
list of commands to be executed
timeout (int (optional))
per command timeout in milliseconds (0 for configured default) (defaults to 0)
Return:
tuple containing stdout and stderr output of the device
Return Type:
tuple of (bytes, bytes)

MicroPythonDeviceInterface.__execute_raw

__execute_raw(commands, timeout=0)

Private method to send commands to the connected device using 'raw REPL' mode and return the result.

If no serial connection is available, empty results will be returned.

commands (str or list of str)
list of commands to be executed
timeout (int (optional))
per command timeout in milliseconds (0 for configured default) (defaults to 0)
Return:
tuple containing stdout and stderr output of the device
Return Type:
tuple of (bytes, bytes)

MicroPythonDeviceInterface.__pasteOff

__pasteOff()

Private method to switch 'paste' mode off.

MicroPythonDeviceInterface.__pasteOn

__pasteOn()

Private method to switch the connected device to 'paste' mode.

Note: switching to paste mode is done with synchronous writes.

Return:
flag indicating success
Return Type:
bool

MicroPythonDeviceInterface.__rawOff

__rawOff()

Private method to switch 'raw' mode off.

MicroPythonDeviceInterface.__rawOn

__rawOn()

Private method to switch the connected device to 'raw' mode.

Note: switching to raw mode is done with synchronous writes.

Return:
flag indicating success
Return Type:
bool

MicroPythonDeviceInterface.__readSerial

__readSerial()

Private slot to read all available serial data and emit it with the "dataReceived" signal for further processing.

MicroPythonDeviceInterface.connectToDevice

connectToDevice(port)

Public slot to start the manager.

port (str)
name of the port to be used
Return:
flag indicating success
Return Type:
bool

MicroPythonDeviceInterface.disconnectFromDevice

disconnectFromDevice()

Public slot to stop the thread.

MicroPythonDeviceInterface.execute

execute(commands, *, mode="raw", timeout=0)

Public method to send commands to the connected device and return the result.

If no serial connection is available, empty results will be returned.

commands (str or list of str)
list of commands to be executed
mode= (str)
submit mode to be used (one of 'raw' or 'paste') (defaults to 'raw')
timeout= (int (optional))
per command timeout in milliseconds (0 for configured default) (defaults to 0)
Return:
tuple containing stdout and stderr output of the device
Return Type:
tuple of (bytes, bytes)
Raises ValueError:
raised in case of an unsupported submit mode

MicroPythonDeviceInterface.executeAsync

executeAsync(commandsList)

Public method to execute a series of commands over a period of time without returning any result (asynchronous execution).

commandsList (list of bytes)
list of commands to be execute on the device

MicroPythonDeviceInterface.executeAsyncPaste

executeAsyncPaste(commandsList)

Public method to execute a series of commands over a period of time without returning any result (asynchronous execution).

commandsList (list of bytes)
list of commands to be execute on the device

MicroPythonDeviceInterface.handlePreferencesChanged

handlePreferencesChanged()

Public slot to handle a change of the preferences.

MicroPythonDeviceInterface.isConnected

isConnected()

Public method to get the connection status.

Return:
flag indicating the connection status
Return Type:
bool

MicroPythonDeviceInterface.probeDevice

probeDevice()

Public method to check the device is responding.

If the device has not been flashed with a MicroPython formware, the probe will fail.

Return:
flag indicating a communicating MicroPython device
Return Type:
bool

MicroPythonDeviceInterface.write

write(data)

Public method to write data to the connected device.

data (bytes or bytearray)
data to be written
Up