Update: WebSocket支持MicroPython板卡烧录固件及上传程序

This commit is contained in:
王立帮
2024-12-02 21:50:56 +08:00
parent 4008e1aab5
commit a5c1ef4269
14 changed files with 379 additions and 521 deletions

View File

@@ -30,6 +30,7 @@ goog.require('Mixly.Web.Serial');
goog.require('Mixly.WebSocket.File');
goog.require('Mixly.WebSocket.Serial');
goog.require('Mixly.WebSocket.ArduShell');
goog.require('Mixly.WebSocket.BU');
goog.provide('Mixly.App');
const {
@@ -181,7 +182,7 @@ class App extends Component {
id: 'arduino-compile-btn',
displayText: Msg.Lang['nav.btn.compile'],
preconditionFn: () => {
if (!goog.isElectron && !Env.hasSocketServer && !env.hasCompiler) {
if (!goog.isElectron && !Env.hasSocketServer && !Env.hasCompiler) {
return false;
}
if (!SELECTED_BOARD?.nav?.compile || !SELECTED_BOARD?.nav?.upload) {
@@ -209,7 +210,7 @@ class App extends Component {
id: 'arduino-upload-btn',
displayText: Msg.Lang['nav.btn.upload'],
preconditionFn: () => {
if (!goog.isElectron && !Env.hasSocketServer && !env.hasCompiler) {
if (!goog.isElectron && !Env.hasSocketServer && !Env.hasCompiler) {
return false;
}
if (!SELECTED_BOARD?.nav?.compile || !SELECTED_BOARD?.nav?.upload) {

View File

@@ -244,7 +244,9 @@ Boards.changeTo = (boardName) => {
outObj.volume = "CIRCUITPY";
}
}
outObj.filePath = MString.tpl(outObj.filePath, pathObj);
if (!Env.hasSocketServer) {
outObj.filePath = MString.tpl(outObj.filePath, pathObj);
}
break;
case 'command':
let pyToolsPath = "{srcPath}/tools/python/";
@@ -256,8 +258,10 @@ Boards.changeTo = (boardName) => {
'stm32bl': 'stm32bl.py',
'ampy': 'ampy/cli.py'
};
for (let key in pyTools) {
obj[key] = Env.python3Path + "\" \"" + pyToolsPath + pyTools[key];
if (!Env.hasSocketServer) {
for (let key in pyTools) {
obj[key] = Env.python3Path + "\" \"" + pyToolsPath + pyTools[key];
}
}
if (outObj.reset) {
let resetStr = '{}';
@@ -270,7 +274,9 @@ Boards.changeTo = (boardName) => {
}
}
outObj.command = MString.tpl(outObj.command, obj);
outObj.command = MString.tpl(outObj.command, pathObj);
if (!Env.hasSocketServer) {
outObj.command = MString.tpl(outObj.command, pathObj);
}
if (outObj.special && outObj.special instanceof Array) {
for (let key in outObj.special) {
if (!outObj.special[key]?.name
@@ -278,23 +284,31 @@ Boards.changeTo = (boardName) => {
continue;
}
outObj.special[key].command = MString.tpl(outObj.special[key].command, obj);
outObj.special[key].command = MString.tpl(outObj.special[key].command, pathObj);
if (!Env.hasSocketServer) {
outObj.special[key].command = MString.tpl(outObj.special[key].command, pathObj);
}
}
}
break;
}
if (value.type === 'upload' && (goog.isElectron || Env.hasSocketServer) && outObj.copyLib) {
if (outObj.libPath) {
let libPath = [];
for (let dirPath of outObj.libPath) {
libPath.push(MString.tpl(dirPath, pathObj));
if (!Env.hasSocketServer) {
let libPath = [];
for (let dirPath of outObj.libPath) {
libPath.push(MString.tpl(dirPath, pathObj));
}
outObj.libPath = libPath;
}
outObj.libPath = libPath;
} else {
outObj.libPath = [ path.join(Env.boardDirPath, 'build/lib/') ];
if (Env.hasSocketServer) {
outObj.libPath = [ 'build/lib/' ];
} else {
outObj.libPath = [ path.join(Env.boardDirPath, 'build/lib/') ];
}
}
}
if (value.type === 'upload' && (goog.isElectron || Env.hasSocketServer)) {
if (value.type === 'upload' && (goog.isElectron && !Env.hasSocketServer)) {
if (outObj.filePath) {
outObj.filePath = MString.tpl(outObj.filePath, pathObj);
} else {

View File

@@ -264,7 +264,11 @@ class StatusBarSerial extends PageBase {
this.stopRead();
this.#timer_ && clearTimeout(this.#timer_);
this.#timer_ = null;
if (this.isDisposed() || !this.isOpened()) {
if (this.isDisposed()) {
return;
}
if (!this.isOpened()) {
this.setValue(`${String(error)}\n`);
return;
}
this.setValue(`${this.getValue() + this.#valueTemp_}\n${String(error)}\n`);