eric7.MicroPython.MicroPythonSerialDeviceInterface

Module implementing an interface to talk to a connected MicroPython device via a serial link.

Global Attributes

None

Classes

MicroPythonSerialDeviceInterface Class implementing an interface to talk to a connected MicroPython device via a serial link.

Functions

None


MicroPythonSerialDeviceInterface

Class implementing an interface to talk to a connected MicroPython device via a serial link.

Derived from

MicroPythonDeviceInterface

Class Attributes

None

Class Methods

None

Methods

MicroPythonSerialDeviceInterface Constructor
__executeAsyncPaste Private method to execute a series of commands over a period of time without returning any result (asynchronous execution).
__executeAsyncRaw Private method to execute a series of commands over a period of time without returning any result (asynchronous execution).
__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 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

MicroPythonSerialDeviceInterface (Constructor)

MicroPythonSerialDeviceInterface(parent=None)

Constructor

parent (QObject)
reference to the parent object

MicroPythonSerialDeviceInterface.__executeAsyncPaste

__executeAsyncPaste(commandsList)

Private 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

MicroPythonSerialDeviceInterface.__executeAsyncRaw

__executeAsyncRaw(commandsList)

Private 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

MicroPythonSerialDeviceInterface.__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)

MicroPythonSerialDeviceInterface.__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)

MicroPythonSerialDeviceInterface.__pasteOff

__pasteOff()

Private method to switch 'paste' mode off.

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

MicroPythonSerialDeviceInterface.__rawOff

__rawOff()

Private method to switch 'raw' mode off.

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

MicroPythonSerialDeviceInterface.__readSerial

__readSerial()

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

MicroPythonSerialDeviceInterface.connectToDevice

connectToDevice(connection)

Public method to connect to the device.

connection (str)
name of the connection to be used
Return:
flag indicating success and an error message
Return Type:
tuple of (bool, str)

MicroPythonSerialDeviceInterface.disconnectFromDevice

disconnectFromDevice()

Public slot to disconnect from the device.

MicroPythonSerialDeviceInterface.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

MicroPythonSerialDeviceInterface.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
Raises ValueError:
raised to indicate an unknown submit mode

MicroPythonSerialDeviceInterface.handlePreferencesChanged

handlePreferencesChanged()

Public slot to handle a change of the preferences.

MicroPythonSerialDeviceInterface.isConnected

isConnected()

Public method to get the connection status.

Return:
flag indicating the connection status
Return Type:
bool

MicroPythonSerialDeviceInterface.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

MicroPythonSerialDeviceInterface.write

write(data)

Public method to write data to the connected device.

data (bytes or bytearray)
data to be written
Up