# eric7.MicroPython.MicroPythonDevices

Module implementing some utility functions and the MicroPythonDevice base class.

### Global Attributes

IgnoredBoards
SupportedBoards

### Classes

MicroPythonDevice | Base class for the more specific MicroPython devices.

### Functions

getDevice | Public method to instantiate a specific MicroPython device interface.
getDeviceIcon | Function to get the icon for the given board.
getFoundDevices | Function to check the serial ports for supported MicroPython devices.
getSupportedDevices | Function to get a list of supported MicroPython devices.

## MicroPythonDevice

Base class for the more specific MicroPython devices.

### Derived from

QObject

### Class Attributes

None

### Class Methods

None

### Methods

MicroPythonDevice | Constructor
addDeviceMenuEntries | Public method to add device specific entries to the given menu.
canRunScript | Public method to determine, if a script can be executed.
canStartFileManager | Public method to determine, if a File Manager can be started.
canStartPlotter | Public method to determine, if a Plotter can be started.
canStartRepl | Public method to determine, if a REPL can be started.
deviceName | Public method to get the name of the device.
downloadFirmware | Public method to download the device firmware.
forceInterrupt | Public method to determine the need for an interrupt when opening the serial connection.
getDeviceType | Public method to get the device type.
getDocumentationUrl | Public method to get the device documentation URL.
getDownloadMenuEntries | Public method to retrieve the entries for the downloads menu.
getFirmwareUrl | Public method to get the device firmware download URL.
getWorkspace | Public method to get the workspace directory.
handleDataFlood | Public slot handling a data floof from the device.
hasDocumentationUrl | Public method to check, if the device has a configured documentation URL.
hasFirmwareUrl | Public method to check, if the device has a configured firmware download URL.
hasFlashMenuEntry | Public method to check, if the device has its own flash menu entry.
hasTimeCommands | Public method to check, if the device supports time commands.
runScript | Public method to run the given Python script.
selectDeviceDirectory | Public method to select the device directory from a list of detected ones.
sendCommands | Public method to send a list of commands to the device.
setButtons | Public method to enable the supported action buttons.
setFileManager | Public method to set the File Manager status and dependent status.
setPlotter | Public method to set the Plotter status and dependent status.
setRepl | Public method to set the REPL status and dependent status.
supportsLocalFileAccess | Public method to indicate file access via a local directory.

### Static Methods

None

#### MicroPythonDevice (Constructor)

MicroPythonDevice(microPythonWidget, deviceType, parent=None)

Constructor

microPythonWidget (MicroPythonWidget)
  reference to the main MicroPython widget
deviceType (str)
  device type assigned to this device interface
parent (QObject)
  reference to the parent object

#### MicroPythonDevice.addDeviceMenuEntries

addDeviceMenuEntries(menu)

Public method to add device specific entries to the given menu.

menu (QMenu)
  reference to the context menu

#### MicroPythonDevice.canRunScript

canRunScript()

Public method to determine, if a script can be executed.

Return:
  tuple containing a flag indicating it is safe to start a Plotter and a reason why it cannot.

Return Type:
  tuple of (bool, str)

#### MicroPythonDevice.canStartFileManager

canStartFileManager()

Public method to determine, if a File Manager can be started.

Return:
  tuple containing a flag indicating it is safe to start a File Manager and a reason why it cannot.

Return Type:
  tuple of (bool, str)

#### MicroPythonDevice.canStartPlotter

canStartPlotter()

Public method to determine, if a Plotter can be started.

Return:
  tuple containing a flag indicating it is safe to start a Plotter and a reason why it cannot.

Return Type:
  tuple of (bool, str)

#### MicroPythonDevice.canStartRepl

canStartRepl()

Public method to determine, if a REPL can be started.

Return:
  tuple containing a flag indicating it is safe to start a REPL and a reason why it cannot.

Return Type:
  tuple of (bool, str)

#### MicroPythonDevice.deviceName

deviceName()

Public method to get the name of the device.

Return:
  name of the device

Return Type:
  str

#### MicroPythonDevice.downloadFirmware

downloadFirmware()

Public method to download the device firmware.

#### MicroPythonDevice.forceInterrupt

forceInterrupt()

Public method to determine the need for an interrupt when opening the serial connection.

Return:
  flag indicating an interrupt is needed

Return Type:
  bool

#### MicroPythonDevice.getDeviceType

getDeviceType()

Public method to get the device type.

Return:
  type of the device

Return Type:
  str

#### MicroPythonDevice.getDocumentationUrl

getDocumentationUrl()

Public method to get the device documentation URL.

Return:
  documentation URL of the device

Return Type:
  str

#### MicroPythonDevice.getDownloadMenuEntries

getDownloadMenuEntries()

Public method to retrieve the entries for the downloads menu.

Return:
  list of tuples with menu text and URL to be opened for each entry

Return Type:
  list of tuple of (str, str)

#### MicroPythonDevice.getFirmwareUrl

getFirmwareUrl()

Public method to get the device firmware download URL.

Return:
  firmware download URL of the device

Return Type:
  str

#### MicroPythonDevice.getWorkspace

getWorkspace()

Public method to get the workspace directory.

Return:
  workspace directory used for saving files

Return Type:
  str

#### MicroPythonDevice.handleDataFlood

handleDataFlood()

Public slot handling a data floof from the device.

#### MicroPythonDevice.hasDocumentationUrl

hasDocumentationUrl()

Public method to check, if the device has a configured documentation URL.

Return:
  flag indicating a configured documentation URL

Return Type:
  bool

#### MicroPythonDevice.hasFirmwareUrl

hasFirmwareUrl()

Public method to check, if the device has a configured firmware download URL.

Return:
  flag indicating a configured firmware download URL

Return Type:
  bool

#### MicroPythonDevice.hasFlashMenuEntry

hasFlashMenuEntry()

Public method to check, if the device has its own flash menu entry.

Return:
  flag indicating a specific flash menu entry

Return Type:
  bool

#### MicroPythonDevice.hasTimeCommands

hasTimeCommands()

Public method to check, if the device supports time commands.

The default returns True.

Return:
  flag indicating support for time commands

Return Type:
  bool

#### MicroPythonDevice.runScript

runScript(script)

Public method to run the given Python script.

script (str)
  script to be executed

#### MicroPythonDevice.selectDeviceDirectory

selectDeviceDirectory(deviceDirectories)

Public method to select the device directory from a list of detected ones.

deviceDirectories (list of str)
  list of directories to select from

Return:
  selected directory or an empty string

Return Type:
  str

#### MicroPythonDevice.sendCommands

sendCommands(commandsList)

Public method to send a list of commands to the device.

commandsList (list of str)
  list of commands to be sent to the device

#### MicroPythonDevice.setButtons

setButtons()

Public method to enable the supported action buttons.

#### MicroPythonDevice.setFileManager

setFileManager(on)

Public method to set the File Manager status and dependent status.

on (bool)
  flag indicating the active status

#### MicroPythonDevice.setPlotter

setPlotter(on)

Public method to set the Plotter status and dependent status.

on (bool)
  flag indicating the active status

#### MicroPythonDevice.setRepl

setRepl(on)

Public method to set the REPL status and dependent status.

on (bool)
  flag indicating the active status

#### MicroPythonDevice.supportsLocalFileAccess

supportsLocalFileAccess()

Public method to indicate file access via a local directory.

Return:
  flag indicating file access via local directory

Return Type:
  bool

Up

## getDevice

getDevice(deviceType, microPythonWidget, vid, pid)

Public method to instantiate a specific MicroPython device interface.

deviceType (str)
  type of the device interface
microPythonWidget (MicroPythonWidget)
  reference to the main MicroPython widget
vid (int)
  vendor ID (only used for deviceType 'generic')
pid (int)
  product ID (only used for deviceType 'generic')

Return:
  instantiated device interface

Return Type:
  MicroPythonDevice

Up

## getDeviceIcon

getDeviceIcon(boardName, iconFormat=True)

Function to get the icon for the given board.

boardName (str)
  name of the board
iconFormat (bool)
  flag indicating to get an icon or a pixmap

Return:
  icon for the board (iconFormat == True) or a pixmap (iconFormat == False)

Return Type:
  QIcon or QPixmap

Up

## getFoundDevices

getFoundDevices()

Function to check the serial ports for supported MicroPython devices.

Return:
  tuple containing a list of tuples with the board type, the port description, a description, the serial port it is connected at, the VID and PID for known device types, a list of tuples with VID, PID and description for unknown devices and a list of tuples with VID, PID, description and port name for ports with missing VID or PID

Return Type:
  tuple of (list of tuples of (str, str, str, str, int, int), list of tuples of (int, int, str), list of tuples of (int, int, str, str)

Up

## getSupportedDevices

getSupportedDevices()

Function to get a list of supported MicroPython devices.

Return:
  set of tuples with the board type and description

Return Type:
  set of tuples of (str, str)

Up