eric7.MicroPython.Devices.DeviceBase
Module implementing some utility functions and the MicroPythonDevice base
class.
Global Attributes
Classes
BaseDevice |
Base class for the more specific MicroPython devices. |
Functions
BaseDevice
Base class for the more specific MicroPython devices.
It includes a list of commands for general use on the various boards.
If a board needs special treatment, the command should be overwritten
in the board specific subclass. Commands are provided to perform operations
on the file system of a connected MicroPython device, for getting and setting
the time on the board and getting board related data.
Supported file system commands are:
- cd: change directory
- exists: test the existence of a file or directory on the device
- fileSystemInfo: get information about the file system
- get: get a file from the connected device
- getData: read data of a file of the connected device
- lls: directory listing with meta data
- ls: directory listing
- mkdir: create a new directory
- put: copy a file to the connected device
- putData: write data to a file of the connected device
- pwd: get the current directory
- rm: remove a file from the connected device
- rmdir: remove an empty directory
- rmrf: remove a file/directory recursively (like 'rm -rf' in bash)
Supported non file system commands are:
- getBoardData: get information about the connected board
- getDeviceData: get version info about MicroPython and some implementation
information
- getModules: get a list of built-in modules
- getTime: get the current time
- showTime: show the current time of the connected device
- syncTime: synchronize the time of the connected device
- mipInstall: install a MicroPython package with 'mip'
- upipInstall: install a MicroPython package with 'upip'
- getLibPaths: get a list of library paths contained in sys.path
Supported WiFi commands are:
- hasWifi: check, if the board has WiFi functionality
- getWifiData: get WiFi status data
- connectWifi: connect to a WiFi network
- disconnectWifi: disconnect from a WiFi network
- writeCredentials: save the WiFi credentials to the board and create
functionality to auto-connect at boot time
- removeCredentials: remove the saved credentials
- checkInternet: check, if internet access is possible
- scanNetworks: scan for available WiFi networks
- deactivateInterface: deactivate a WiFi interface
- startAccessPoint: start an access point
- stopAccessPoint: stop the access point
- getConnectedClients: get a list of connected WiFi clients
Supported Bluetooth commands are:
- hasBluetooth: check, if the board has Bluetooth functionality
- getBluetoothStatus: get Bluetooth status data
- activateBluetoothInterface: activate a Bluetooth interface
- deactivateBluetoothInterface: deactivate a Bluetooth interface
- getDeviceScan: scan for visible Bluetooth devices
Supported Ethernet commands are:
- hasEthernet: check, if the board has Ethernet functionality
- getEthernetStatus: get Ethernet status data
- connectToLan: connect to an Ethernet network
- disconnectFromLan: disconnect from an Ethernet network
- checkInternetViaLan: check, if internet access via LAN is possible
- deactivateEthernet: deactivate the Ethernet interface
- writeLanAutoConnect: save IPv4 parameters to the board and create a script
to connect the board to the LAN
- removeLanAutoConnect: remove the IPv4 parameters and script from the board
Derived from
QObject
Class Attributes
Class Methods
Methods
BaseDevice |
Constructor |
__getDeviceData |
Private method to get some essential data for the connected board. |
_getSetTimeCode |
Protected method to get the device code to set the time. |
_shortError |
Protected method to create a shortened error message. |
activateBluetoothInterface |
Public method to activate the Bluetooth interface. |
addDeviceBluetoothEntries |
Public method to add device specific entries to the given menu. |
addDeviceEthernetEntries |
Public method to add device specific entries to the given menu. |
addDeviceMenuEntries |
Public method to add device specific entries to the given menu. |
addDeviceWifiEntries |
Public method to add device specific entries to the given menu. |
bool2str |
Public method to generate a yes/no string given a truth value. |
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. |
cd |
Public method to change the current directory on the connected device. |
checkDeviceData |
Public method to check the validity of the device data determined during connecting the device. |
checkInternet |
Public method to check, if the internet can be reached. |
checkInternetViaLan |
Public method to check, if the internet can be reached (LAN variant). |
connectToLan |
Public method to connect the connected device to the LAN. |
connectWifi |
Public method to connect a device to a WiFi network. |
deactivateBluetoothInterface |
Public method to deactivate the Bluetooth interface. |
deactivateEthernet |
Public method to deactivate the Ethernet interface of the connected device. |
deactivateInterface |
Public method to deactivate a given WiFi interface of the connected device. |
deviceName |
Public method to get the name of the device. |
disconnectFromLan |
Public method to disconnect from the LAN. |
disconnectWifi |
Public method to disconnect a device from the WiFi network. |
downloadFirmware |
Public method to download the device firmware. |
ensurePath |
Public method to ensure, that the given target path exists. |
exists |
Public method to check the existence of a file or directory. |
fileSystemInfo |
Public method to obtain information about the currently mounted file systems. |
forceInterrupt |
Public method to determine the need for an interrupt when opening the serial connection. |
get |
Public method to copy a file from the connected device. |
getBluetoothStatus |
Public method to get Bluetooth status data of the connected board. |
getBoardInformation |
Public method to get some information data of the connected board. |
getConnectedClients |
Public method to get a list of connected clients. |
getData |
Public method to read data from the connected device. |
getDeviceData |
Public method to get a copy of the determined device data. |
getDeviceScan |
Public method to perform a Bluetooth device scan. |
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. |
getEthernetStatus |
Public method to get Ethernet status data of the connected board. |
getFirmwareUrl |
Public method to get the device firmware download URL. |
getLibPaths |
Public method to get the list of library paths contained in 'sys.path'. |
getModules |
Public method to show a list of modules built into the firmware. |
getTime |
Public method to get the current time of the device. |
getWifiData |
Public method to get data related to the current WiFi status. |
getWorkspace |
Public method to get the workspace directory. |
handleDataFlood |
Public slot handling a data floof from the device. |
hasBluetooth |
Public method to check the availability of Bluetooth. |
hasCircuitPython |
Public method to check, if the connected device is flashed with CircuitPython. |
hasDocumentationUrl |
Public method to check, if the device has a configured documentation URL. |
hasEthernet |
Public method to check the availability of Ethernet. |
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. |
hasNetworkTime |
Public method to check the availability of network time functions. |
hasTimeCommands |
Public method to check, if the device supports time commands. |
hasWifi |
Public method to check the availability of WiFi. |
lls |
Public method to get a long directory listing of the connected device including meta data. |
ls |
Public method to get a directory listing of the connected device. |
mipInstall |
Public method to install packages using 'mip'. |
mkdir |
Public method to create a new directory. |
put |
Public method to copy a local file to the connected device. |
putData |
Public method to write the given data to the connected device. |
pwd |
Public method to get the current directory of the connected device. |
removeCredentials |
Public method to remove the saved credentials from the connected device. |
removeLanAutoConnect |
Public method to remove the saved IPv4 parameters from the connected device. |
rm |
Public method to remove a file from the connected device. |
rmdir |
Public method to remove a directory. |
rmrf |
Public method to remove a file or directory recursively. |
runScript |
Public method to run the given Python script. |
scanNetworks |
Public method to scan for available WiFi networks. |
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. |
setConnected |
Public method to set the connection state. |
setFileManager |
Public method to set the File Manager status and dependent status. |
setNetworkTime |
Public method to set the time to the network time retrieved from an NTP server. |
setPlotter |
Public method to set the Plotter status and dependent status. |
setRepl |
Public method to set the REPL status and dependent status. |
setWorkspace |
Public method to set the device workspace directory. |
startAccessPoint |
Public method to start the access point interface. |
stopAccessPoint |
Public method to stop the access point interface. |
submitMode |
Public method to get the submit mode of the device. |
supportsLocalFileAccess |
Public method to indicate file access via a local directory. |
syncTime |
Public method to set the time of the connected device to the local computer's time. |
upipInstall |
Public method to install packages using 'upip'. |
writeCredentials |
Public method to write the given credentials to the connected device and modify the start script to connect automatically. |
writeLanAutoConnect |
Public method to generate a script and associated configuration to connect the device to the LAN during boot time. |
Static Methods
BaseDevice (Constructor)
BaseDevice(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
BaseDevice.__getDeviceData
__getDeviceData()
Private method to get some essential data for the connected board.
- Return:
-
dictionary containing the determined data
- Return Type:
-
dict
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice._getSetTimeCode
_getSetTimeCode()
Protected method to get the device code to set the time.
Note: This method must be implemented in the various device specific
subclasses.
- Return:
-
code to be executed on the connected device to set the time
- Return Type:
-
str
BaseDevice._shortError
_shortError(error)
Protected method to create a shortened error message.
- error (bytes)
-
verbose error message
- Return:
-
shortened error message
- Return Type:
-
str
BaseDevice.activateBluetoothInterface
activateBluetoothInterface()
Public method to activate the Bluetooth interface.
- Return:
-
flag indicating the new state of the Bluetooth interface
- Return Type:
-
bool
BaseDevice.addDeviceBluetoothEntries
addDeviceBluetoothEntries(menu)
Public method to add device specific entries to the given menu.
- menu (QMenu)
-
reference to the context menu
BaseDevice.addDeviceEthernetEntries
addDeviceEthernetEntries(menu)
Public method to add device specific entries to the given menu.
- menu (QMenu)
-
reference to the context menu
BaseDevice.addDeviceMenuEntries
addDeviceMenuEntries(menu)
Public method to add device specific entries to the given menu.
- menu (QMenu)
-
reference to the context menu
BaseDevice.addDeviceWifiEntries
addDeviceWifiEntries(menu)
Public method to add device specific entries to the given menu.
- menu (QMenu)
-
reference to the context menu
BaseDevice.bool2str
bool2str(val, capitalized=True)
Public method to generate a yes/no string given a truth value.
- val (bool)
-
truth value to be converted
- capitalized (bool)
-
flag indicating a capitalized variant
- Return:
-
string with 'yes' or 'no'
- Return Type:
-
str
BaseDevice.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)
BaseDevice.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)
BaseDevice.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)
BaseDevice.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)
BaseDevice.cd
cd(dirname)
Public method to change the current directory on the connected device.
- dirname (str)
-
directory to change to
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.checkDeviceData
checkDeviceData(quiet=True)
Public method to check the validity of the device data determined during
connecting the device.
- quiet (bool (optional))
-
flag indicating to not show an info message, if the data is
not available (defaults to True)
- Return:
-
flag indicating valid device data
- Return Type:
-
bool
BaseDevice.checkInternet
checkInternet()
Public method to check, if the internet can be reached.
- Return:
-
tuple containing a flag indicating reachability and an error string
- Return Type:
-
tuple of (bool, str)
BaseDevice.checkInternetViaLan
checkInternetViaLan()
Public method to check, if the internet can be reached (LAN variant).
- Return:
-
tuple containing a flag indicating reachability and an error string
- Return Type:
-
tuple of (bool, str)
BaseDevice.connectToLan
connectToLan(config)
Public method to connect the connected device to the LAN.
- config (str or tuple of (str, str, str, str))
-
configuration for the connection (either the string 'dhcp'
for a dynamic address or a tuple of four strings with the IPv4 parameters.
- Return:
-
tuple containing a flag indicating success and an error message
- Return Type:
-
tuple of (bool, str)
BaseDevice.connectWifi
connectWifi(ssid, password)
Public method to connect a device to a WiFi network.
- ssid (str)
-
name (SSID) of the WiFi network
- password (str)
-
password needed to connect
- Return:
-
tuple containing the connection status and an error string
- Return Type:
-
tuple of (bool, str)
BaseDevice.deactivateBluetoothInterface
deactivateBluetoothInterface()
Public method to deactivate the Bluetooth interface.
- Return:
-
flag indicating the new state of the Bluetooth interface
- Return Type:
-
bool
BaseDevice.deactivateEthernet
deactivateEthernet()
Public method to deactivate the Ethernet interface of the connected device.
- Return:
-
tuple containg a flag indicating success and an error message
- Return Type:
-
tuple of (bool, str)
BaseDevice.deactivateInterface
deactivateInterface(interface)
Public method to deactivate a given WiFi interface of the connected device.
- interface (str)
-
designation of the interface to be deactivated (one of 'AP'
or 'STA')
- Return:
-
tuple containg a flag indicating success and an error message
- Return Type:
-
tuple of (bool, str)
BaseDevice.deviceName
deviceName()
Public method to get the name of the device.
- Return:
-
name of the device
- Return Type:
-
str
BaseDevice.disconnectFromLan
disconnectFromLan()
Public method to disconnect from the LAN.
- Return:
-
tuple containing a flag indicating success and an error message
- Return Type:
-
tuple of (bool, str)
BaseDevice.disconnectWifi
disconnectWifi()
Public method to disconnect a device from the WiFi network.
- Return:
-
tuple containing a flag indicating success and an error string
- Return Type:
-
tuple of (bool, str)
BaseDevice.downloadFirmware
downloadFirmware()
Public method to download the device firmware.
BaseDevice.ensurePath
ensurePath(target)
Public method to ensure, that the given target path exists.
- target (str)
-
target directory
BaseDevice.exists
exists(pathname)
Public method to check the existence of a file or directory.
- pathname (str)
-
name of the path to check
- Return:
-
flag indicating the existence
- Return Type:
-
bool
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.fileSystemInfo
fileSystemInfo()
Public method to obtain information about the currently mounted file
systems.
- Return:
-
tuple of tuples containing the file system name, the total
size, the used size and the free size
- Return Type:
-
tuple of tuples of (str, int, int, int)
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.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
BaseDevice.get
get(deviceFileName, hostFileName=None)
Public method to copy a file from the connected device.
- deviceFileName (str)
-
name of the file to copy
- hostFileName (str)
-
name of the file to copy to
- Return:
-
flag indicating success
- Return Type:
-
bool
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.getBluetoothStatus
getBluetoothStatus()
Public method to get Bluetooth status data of the connected board.
- Return:
-
list of tuples containing the translated status data label and
the associated value
- Return Type:
-
list of tuples of (str, str)
BaseDevice.getBoardInformation
getBoardInformation()
Public method to get some information data of the connected board.
- Return:
-
dictionary containing the determined data
- Return Type:
-
dict
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.getConnectedClients
getConnectedClients()
Public method to get a list of connected clients.
- Return:
-
a tuple containing a list of tuples containing the client MAC-Address
and the RSSI (if supported and available) and an error message
- Return Type:
-
tuple of ([(bytes, int)], str)
BaseDevice.getData
getData(deviceFileName)
Public method to read data from the connected device.
- deviceFileName (str)
-
name of the file to read from
- Return:
-
data read from the device
- Return Type:
-
bytes
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.getDeviceData
getDeviceData(key=None)
Public method to get a copy of the determined device data.
- key (str (optional))
-
name of the data to get (None to get all data) (defaults to None)
- Return:
-
dictionary containing the essential device data
- Return Type:
-
dict
BaseDevice.getDeviceScan
getDeviceScan(timeout=10)
Public method to perform a Bluetooth device scan.
- timeout (int (optional))
-
duration of the device scan in seconds (defaults
to 10)
- Return:
-
tuple containing a dictionary with the scan results and
an error string
- Return Type:
-
tuple of (dict, str)
BaseDevice.getDeviceType
getDeviceType()
Public method to get the device type.
- Return:
-
type of the device
- Return Type:
-
str
BaseDevice.getDocumentationUrl
getDocumentationUrl()
Public method to get the device documentation URL.
- Return:
-
documentation URL of the device
- Return Type:
-
str
BaseDevice.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)
BaseDevice.getEthernetStatus
getEthernetStatus()
Public method to get Ethernet status data of the connected board.
- Return:
-
list of tuples containing the translated status data label and
the associated value
- Return Type:
-
list of tuples of (str, str)
BaseDevice.getFirmwareUrl
getFirmwareUrl()
Public method to get the device firmware download URL.
- Return:
-
firmware download URL of the device
- Return Type:
-
str
BaseDevice.getLibPaths
getLibPaths()
Public method to get the list of library paths contained in 'sys.path'.
- Return:
-
list of library paths
- Return Type:
-
list of str
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.getModules
getModules()
Public method to show a list of modules built into the firmware.
- Return:
-
list of builtin modules
- Return Type:
-
list of str
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.getTime
getTime()
Public method to get the current time of the device.
- Return:
-
time of the device
- Return Type:
-
str
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.getWifiData
getWifiData()
Public method to get data related to the current WiFi status.
- Return:
-
tuple of three dictionaries containing the WiFi status data
for the WiFi client, access point and overall data
- Return Type:
-
tuple of (dict, dict, dict)
BaseDevice.getWorkspace
getWorkspace()
Public method to get the workspace directory.
- Return:
-
workspace directory used for saving files
- Return Type:
-
str
BaseDevice.handleDataFlood
handleDataFlood()
Public slot handling a data floof from the device.
BaseDevice.hasBluetooth
hasBluetooth()
Public method to check the availability of Bluetooth.
- Return:
-
flag indicating the availability of Bluetooth
- Return Type:
-
bool
BaseDevice.hasCircuitPython
hasCircuitPython()
Public method to check, if the connected device is flashed with CircuitPython.
- Return:
-
flag indicating CircuitPython
- Return Type:
-
bool
BaseDevice.hasDocumentationUrl
hasDocumentationUrl()
Public method to check, if the device has a configured documentation
URL.
- Return:
-
flag indicating a configured documentation URL
- Return Type:
-
bool
BaseDevice.hasEthernet
hasEthernet()
Public method to check the availability of Ethernet.
- Return:
-
tuple containing a flag indicating the availability of Ethernet
and the Ethernet type
- Return Type:
-
tuple of (bool, str)
BaseDevice.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
BaseDevice.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
BaseDevice.hasNetworkTime
hasNetworkTime()
Public method to check the availability of network time functions.
- Return:
-
flag indicating the availability of network time functions
- Return Type:
-
bool
BaseDevice.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
BaseDevice.hasWifi
hasWifi()
Public method to check the availability of WiFi.
- Return:
-
tuple containing a flag indicating the availability of WiFi
and the WiFi type (picow or pimoroni)
- Return Type:
-
tuple of (bool, str)
BaseDevice.lls
lls(dirname="", fullstat=False, showHidden=False)
Public method to get a long directory listing of the connected device
including meta data.
- dirname (str)
-
name of the directory to be listed
- fullstat (bool)
-
flag indicating to return the full stat() tuple
- showHidden (bool)
-
flag indicating to show hidden files as well
- Return:
-
list containing the directory listing with tuple entries of
the name and and a tuple of mode, size and time (if fullstat is
false) or the complete stat() tuple. 'None' is returned in case the
directory doesn't exist.
- Return Type:
-
tuple of (str, tuple)
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.ls
ls(dirname="")
Public method to get a directory listing of the connected device.
- dirname (str)
-
name of the directory to be listed
- Return:
-
tuple containg the directory listing
- Return Type:
-
tuple of str
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.mipInstall
mipInstall(package, index=None, target=None, version=None, mpy=True)
Public method to install packages using 'mip'.
- package (str)
-
package name
- index (str (optional))
-
URL of the package index to be used (defaults to None)
- target (str (optional))
-
target directory on the device (defaults to None)
- version (str (optional))
-
package version (defaults to None)
- mpy (bool (optional))
-
flag indicating to install as '.mpy' file (defaults to True)
- Return:
-
tuple of (str, str)
BaseDevice.mkdir
mkdir(dirname)
Public method to create a new directory.
- dirname (str)
-
name of the directory to create
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.put
put(hostFileName, deviceFileName=None)
Public method to copy a local file to the connected device.
- hostFileName (str)
-
name of the file to be copied
- deviceFileName (str)
-
name of the file to copy to
- Return:
-
flag indicating success
- Return Type:
-
bool
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.putData
putData(deviceFileName, content)
Public method to write the given data to the connected device.
- deviceFileName (str)
-
name of the file to write to
- content (bytes)
-
data to write
- Return:
-
flag indicating success
- Return Type:
-
bool
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.pwd
pwd()
Public method to get the current directory of the connected device.
- Return:
-
current directory
- Return Type:
-
str
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.removeCredentials
removeCredentials()
Public method to remove the saved credentials from the connected device.
- Return:
-
tuple containing a flag indicating success and an error message
- Return Type:
-
tuple of (bool, str)
BaseDevice.removeLanAutoConnect
removeLanAutoConnect()
Public method to remove the saved IPv4 parameters from the connected device.
Note: This disables the LAN auto-connect feature.
- Return:
-
tuple containing a flag indicating success and an error message
- Return Type:
-
tuple of (bool, str)
BaseDevice.rm
rm(filename)
Public method to remove a file from the connected device.
- filename (str)
-
name of the file to be removed
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.rmdir
rmdir(dirname)
Public method to remove a directory.
- dirname (str)
-
name of the directory to be removed
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.rmrf
rmrf(name, recursive=False, force=False)
Public method to remove a file or directory recursively.
- name (str)
-
of the file or directory to remove
- recursive (bool)
-
flag indicating a recursive deletion
- force (bool)
-
flag indicating to ignore errors
- Return:
-
flag indicating success
- Return Type:
-
bool
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.runScript
runScript(script)
Public method to run the given Python script.
- script (str)
-
script to be executed
BaseDevice.scanNetworks
scanNetworks()
Public method to scan for available WiFi networks.
- Return:
-
tuple containing the list of available networks as a tuple of 'Name',
'MAC-Address', 'channel', 'RSSI' and 'security' and an error string
- Return Type:
-
tuple of (list of tuple of (str, str, int, int, str), str)
BaseDevice.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
BaseDevice.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
BaseDevice.setButtons
setButtons()
Public method to enable the supported action buttons.
BaseDevice.setConnected
setConnected(connected)
Public method to set the connection state.
Note: This method can be overwritten to perform actions upon connect
or disconnect of the device.
- connected (bool)
-
connection state
BaseDevice.setFileManager
setFileManager(on)
Public method to set the File Manager status and dependent status.
- on (bool)
-
flag indicating the active status
BaseDevice.setNetworkTime
setNetworkTime(server="pool.ntp.org", tzOffset=0, timeout=10)
Public method to set the time to the network time retrieved from an
NTP server.
- server (str (optional))
-
name of the NTP server to get the network time from
(defaults to "0.pool.ntp.org")
- tzOffset (int (optional))
-
offset with respect to UTC (defaults to 0)
- timeout (int)
-
maximum time to wait for a server response in seconds
(defaults to 10)
- Return:
-
tuple containing a flag indicating success and an error string
- Return Type:
-
tuple of (bool, str)
BaseDevice.setPlotter
setPlotter(on)
Public method to set the Plotter status and dependent status.
- on (bool)
-
flag indicating the active status
BaseDevice.setRepl
setRepl(on)
Public method to set the REPL status and dependent status.
- on (bool)
-
flag indicating the active status
BaseDevice.setWorkspace
setWorkspace(workspacePath)
Public method to set the device workspace directory.
- workspacePath (str)
-
directory to be used for saving files
BaseDevice.startAccessPoint
startAccessPoint(ssid, security=None, password=None, ifconfig=None)
Public method to start the access point interface.
- ssid (str)
-
SSID of the access point
- security (int (optional))
-
security method (defaults to None)
- password (str (optional))
-
password (defaults to None)
- ifconfig (tuple of (str, str, str, str))
-
IPv4 configuration for the access point if not default
(IPv4 address, netmask, gateway address, DNS server address)
- Return:
-
tuple containing a flag indicating success and an error message
- Return Type:
-
tuple of (bool, str)
BaseDevice.stopAccessPoint
stopAccessPoint()
Public method to stop the access point interface.
- Return:
-
tuple containg a flag indicating success and an error message
- Return Type:
-
tuple of (bool, str)
BaseDevice.submitMode
submitMode()
Public method to get the submit mode of the device.
- Return:
-
submit mode
- Return Type:
-
str (one of 'raw', 'paste')
BaseDevice.supportsLocalFileAccess
supportsLocalFileAccess()
Public method to indicate file access via a local directory.
- Return:
-
flag indicating file access via local directory
- Return Type:
-
bool
BaseDevice.syncTime
syncTime(deviceType, hasCPy=False)
Public method to set the time of the connected device to the local
computer's time.
- deviceType (str)
-
type of board to sync time to
- hasCPy (bool)
-
flag indicating that the device has CircuitPython loadede
(defaults to False)
- Raises OSError:
-
raised to indicate an issue with the device
BaseDevice.upipInstall
upipInstall(packages)
Public method to install packages using 'upip'.
- packages (list of str)
-
list of package names
- Return:
-
tuple of (str, str)
BaseDevice.writeCredentials
writeCredentials(ssid, password)
Public method to write the given credentials to the connected device and modify
the start script to connect automatically.
- ssid (str)
-
SSID of the network to connect to
- password (str)
-
password needed to authenticate
- Return:
-
tuple containing a flag indicating success and an error message
- Return Type:
-
tuple of (bool, str)
BaseDevice.writeLanAutoConnect
writeLanAutoConnect(config)
Public method to generate a script and associated configuration to connect the
device to the LAN during boot time.
- config (str or tuple of (str, str, str, str))
-
configuration for the connection (either the string 'dhcp'
for a dynamic address or a tuple of four strings with the IPv4 parameters.
- Return:
-
tuple containing a flag indicating success and an error message
- Return Type:
-
tuple of (bool, str)