diff -r 4543b7876047 -r 11245ac9c258 src/eric7/MicroPython/MicroPythonFileManager.py --- a/src/eric7/MicroPython/MicroPythonFileManager.py Mon Feb 13 17:53:27 2023 +0100 +++ b/src/eric7/MicroPython/MicroPythonFileManager.py Mon Feb 13 17:55:13 2023 +0100 @@ -38,6 +38,8 @@ copied to the connected device @signal deleteFileDone(deviceFile) emitted after the file has been deleted on the connected device + @signal putDataDone(deviceFile) emitted after data has been save to a file + on the connected device @signal rsyncDone(localName, deviceName) emitted after the rsync operation has been completed @signal rsyncProgressMessage(msg) emitted to send a message about what @@ -57,6 +59,7 @@ getFileDone = pyqtSignal(str, str) putFileDone = pyqtSignal(str, str) deleteFileDone = pyqtSignal(str) + putDataDone = pyqtSignal(str) rsyncDone = pyqtSignal(str, str) rsyncProgressMessage = pyqtSignal(str) removeDirectoryDone = pyqtSignal() @@ -148,6 +151,22 @@ except Exception as exc: self.error.emit("get", str(exc)) + def getData(self, deviceFileName): + """ + Public method to read data from the connected device. + + @param deviceFileName name of the file to read from + @type str + @return data read from the device + @rtype bytes + """ + try: + data = self.__commandsInterface.getData(deviceFileName) + return data + except Exception as exc: + self.error.emit("getData", str(exc)) + return b"" + @pyqtSlot(str) @pyqtSlot(str, str) def put(self, hostFileName, deviceFileName=""): @@ -165,6 +184,21 @@ except Exception as exc: self.error.emit("put", str(exc)) + def putData(self, deviceFileName, data): + """ + Public method to write data to the connected device. + + @param deviceFileName name of the file to write to + @type str + @param content data to write + @type bytes + """ + try: + self.__commandsInterface.putData(deviceFileName, data) + self.putDataDone.emit(deviceFileName) + except Exception as exc: + self.error.emit("putData", str(exc)) + @pyqtSlot(str) def delete(self, deviceFileName): """