eric7.MicroPython.MicroPythonWebreplDeviceInterface

Module implementing an interface to talk to a connected MicroPython device via a webrepl connection.

Global Attributes

None

Classes

MicroPythonWebreplDeviceInterface Class implementing an interface to talk to a connected MicroPython device via a webrepl connection.

Functions

None


MicroPythonWebreplDeviceInterface

Class implementing an interface to talk to a connected MicroPython device via a webrepl connection.

Derived from

MicroPythonDeviceInterface

Class Attributes

None

Class Methods

None

Methods

MicroPythonWebreplDeviceInterface Constructor
__pasteOff Private method to switch 'paste' mode off.
__pasteOn Private method to switch the connected device to 'paste' mode.
__readAll Private method to read all data and emit it for further processing.
__readSocket Private slot to read all available data and emit it with the "dataReceived" signal for further processing.
connectToDevice Public method to connect to the device.
disconnectFromDevice Public slot to disconnect from the device.
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).
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

MicroPythonWebreplDeviceInterface (Constructor)

MicroPythonWebreplDeviceInterface(parent=None)

Constructor

parent (QObject)
reference to the parent object

MicroPythonWebreplDeviceInterface.__pasteOff

__pasteOff()

Private method to switch 'paste' mode off.

MicroPythonWebreplDeviceInterface.__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

MicroPythonWebreplDeviceInterface.__readAll

__readAll()

Private method to read all data and emit it for further processing.

MicroPythonWebreplDeviceInterface.__readSocket

__readSocket()

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

MicroPythonWebreplDeviceInterface.connectToDevice

connectToDevice(connection)

Public method to connect to the device.

connection (str)
name of the connection to be used in the form of an URL string (ws://password@host:port)
Return:
flag indicating success and an error message
Return Type:
tuple of (bool, str)

MicroPythonWebreplDeviceInterface.disconnectFromDevice

disconnectFromDevice()

Public slot to disconnect from the device.

MicroPythonWebreplDeviceInterface.execute

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

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

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'). This is ignored because webrepl always uses 'paste' mode. (unused)
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)

MicroPythonWebreplDeviceInterface.executeAsync

executeAsync(commandsList, _submitMode)

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

commandsList (list of str)
list of commands to be execute on the device
_submitMode (str (one of 'raw' or 'paste'))
mode to be used to submit the commands (unused)

MicroPythonWebreplDeviceInterface.handlePreferencesChanged

handlePreferencesChanged()

Public slot to handle a change of the preferences.

MicroPythonWebreplDeviceInterface.isConnected

isConnected()

Public method to get the connection status.

Return:
flag indicating the connection status
Return Type:
bool

MicroPythonWebreplDeviceInterface.probeDevice

probeDevice()

Public method to check the device is responding.

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

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

MicroPythonWebreplDeviceInterface.write

write(data)

Public method to write data to the connected device.

data (bytes or bytearray)
data to be written
Up