# eric7.MicroPython.Devices.STLinkDevices

Module implementing the device interface class for STM32 STLink boards.

### Global Attributes

None

### Classes

STLinkDevice | Class implementing the device for PyBoard boards.

### Functions

createDevice | Function to instantiate a MicroPython device object.

## STLinkDevice

Class implementing the device for PyBoard boards.

### Derived from

BaseDevice

### Class Attributes

DeviceVolumeName

### Class Methods

None

### Methods

STLinkDevice | Constructor
__createSTLinkMenu | Private method to create the STLink submenu.
__deviceVolumeMounted | Private method to check, if the device volume is mounted.
__findWorkspace | Private method to find the workspace directory.
__firmwareVersionResponse | Private slot handling the response of the latest version request.
__flashMicroPython | Private slot to flash a MicroPython firmware.
__resetDevice | Private slot to reset the connected device.
__showDeviceInfo | Private slot to show some information about connected STLink devices.
__showFirmwareVersions | Private slot to show the firmware version of the connected device and the available firmware version.
__stflashAvailable | Private method to check the availability of the 'st-flash' firmware flashing tool.
__stinfoAvailable | Private method to check the availability of the 'st-info' tool.
__stlinkToolAvailable | Private method to check the availability of the given STLink tool.
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.
forceInterrupt | Public method to determine the need for an interrupt when opening the serial connection.
getDocumentationUrl | Public method to get the device documentation URL.
getFirmwareUrl | Public method to get the device firmware download URL.
getWorkspace | Public method to get the workspace directory.
hasFlashMenuEntry | Public method to check, if the device has its own flash menu entry.
runScript | Public method to run the given Python script.
setButtons | Public method to enable the supported action buttons.
supportsLocalFileAccess | Public method to indicate file access via a local directory.

### Static Methods

None

#### STLinkDevice (Constructor)

STLinkDevice(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

#### STLinkDevice.__createSTLinkMenu

__createSTLinkMenu()

Private method to create the STLink submenu.

#### STLinkDevice.__deviceVolumeMounted

__deviceVolumeMounted()

Private method to check, if the device volume is mounted.

Return:
  flag indicated a mounted device

Return Type:
  bool

#### STLinkDevice.__findWorkspace

__findWorkspace(silent=False)

Private method to find the workspace directory.

silent (bool)
  flag indicating silent operations

Return:
  workspace directory used for saving files

Return Type:
  str

#### STLinkDevice.__firmwareVersionResponse

__firmwareVersionResponse(reply)

Private slot handling the response of the latest version request.

reply (QNetworkReply)
  reference to the reply object

#### STLinkDevice.__flashMicroPython

__flashMicroPython()

Private slot to flash a MicroPython firmware.

#### STLinkDevice.__resetDevice

__resetDevice()

Private slot to reset the connected device.

#### STLinkDevice.__showDeviceInfo

__showDeviceInfo()

Private slot to show some information about connected STLink devices.

#### STLinkDevice.__showFirmwareVersions

__showFirmwareVersions()

Private slot to show the firmware version of the connected device and the available firmware version.

#### STLinkDevice.__stflashAvailable

__stflashAvailable()

Private method to check the availability of the 'st-flash' firmware flashing tool.

Return:
  flag indicating the availability of the 'st-flash' firmware flashing tool

Return Type:
  bool

#### STLinkDevice.__stinfoAvailable

__stinfoAvailable()

Private method to check the availability of the 'st-info' tool.

Return:
  flag indicating the availability of the 'st-info' tool

Return Type:
  bool

#### STLinkDevice.__stlinkToolAvailable

__stlinkToolAvailable(toolname)

Private method to check the availability of the given STLink tool.

Note: supported tools are st-info and st-flash

toolname (str)
  name of the tool to be checked

Return:
  flag indicating the availability of the given STLink tool

Return Type:
  bool

Raises ValueError:
  raised to indicate an illegal tool name

#### STLinkDevice.addDeviceMenuEntries

addDeviceMenuEntries(menu)

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

menu (QMenu)
  reference to the context menu

#### STLinkDevice.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)

#### STLinkDevice.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)

#### STLinkDevice.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)

#### STLinkDevice.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)

#### STLinkDevice.deviceName

deviceName()

Public method to get the name of the device.

Return:
  name of the device

Return Type:
  str

#### STLinkDevice.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

#### STLinkDevice.getDocumentationUrl

getDocumentationUrl()

Public method to get the device documentation URL.

Return:
  documentation URL of the device

Return Type:
  str

#### STLinkDevice.getFirmwareUrl

getFirmwareUrl()

Public method to get the device firmware download URL.

Return:
  firmware download URL of the device

Return Type:
  str

#### STLinkDevice.getWorkspace

getWorkspace(silent=False)

Public method to get the workspace directory.

silent (bool)
  flag indicating silent operations

Return:
  workspace directory used for saving files

Return Type:
  str

#### STLinkDevice.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

#### STLinkDevice.runScript

runScript(script)

Public method to run the given Python script.

script (str)
  script to be executed

#### STLinkDevice.setButtons

setButtons()

Public method to enable the supported action buttons.

#### STLinkDevice.supportsLocalFileAccess

supportsLocalFileAccess()

Public method to indicate file access via a local directory.

Return:
  flag indicating file access via local directory

Return Type:
  bool

Up

## createDevice

createDevice(microPythonWidget, deviceType, _vid, _pid, _boardName, _serialNumber)

Function to instantiate a MicroPython device object.

microPythonWidget (MicroPythonWidget)
  reference to the main MicroPython widget
deviceType (str)
  device type assigned to this device interface
_vid (int)
  vendor ID (unused)
_pid (int)
  product ID (unused)
_boardName (str)
  name of the board (unused)
_serialNumber (str)
  serial number of the board (unused)

Return:
  reference to the instantiated device object

Return Type:
  PyBoardDevice

Up