ソースを参照

Merge branch 'master' into xgo

root 3 年 前
コミット
812c34c848

+ 5 - 5
electron-builder.yml

@@ -1,6 +1,6 @@
-appId: org.CocoRobo.XGOEdu
+appId: org.CocoRobo.CocoRoboXDeskTop
 copyright: Copytright © 2021 CocoRobo LTD
-productName: XGOEdu
+productName: CocoRoboXDeskTop
 npmRebuild: true
 asar: true
 
@@ -32,7 +32,7 @@ mac:
   hardenedRuntime: true
   entitlements: build/entitlements.mac.plist
   entitlementsInherit: build/entitlements.mac.plist
-  artifactName: XGOEdu Installer v${version}.${ext}
+  artifactName: CocoRoboXDeskTop Installer v${version}.${ext}
   extraFiles:
     - from: src/static/mac/tools
       to: tools
@@ -72,7 +72,7 @@ win:
         - x64
         - ia32
   icon: src/static/common/cocorobo.ico
-  artifactName: XGOEdu Installer v${version}.${ext}
+  artifactName: CocoRoboXDeskTop Installer v${version}.${ext}
   extraFiles:
     - from: src/static/win/cp210x_drivers
       to: cp210x_drivers
@@ -101,7 +101,7 @@ linux:
     - deb
     - AppImage
   icon: src/static/common/cocorobo.png
-  artifactName: XGOEdu Installer v${version}.${ext}
+  artifactName: CocoRoboXDeskTop Installer v${version}.${ext}
   extraFiles:
     - from: src/static/linux/tools
       to: tools

+ 2 - 2
package.json

@@ -1,6 +1,6 @@
 {
-  "name": "XGOEdu",
-  "version": "1.0.1",
+  "name": "CocoRoboXDeskTop",
+  "version": "1.0.2",
   "description": "cocorobo",
   "repository": "https://github.com/CocoRoboLabs/CocoBlockly-desktop.git",
   "scripts": {

+ 1 - 1
src/main/main.js

@@ -43,7 +43,7 @@ if (platform === 'darwin') {
 	const sudo = require('sudo-prompt');
 	const AutoLaunch = require('auto-launch');
 	const opts = {
-		name: "XGOEdu",
+		name: "CocoRoboXDeskTop",
 		isHidden: false,
 		mac: { useLaunchAgent: true }
 	};

+ 32 - 32
src/renderer/index.js

@@ -6,8 +6,8 @@ import { clearCache, upload, pythonupload, pythonuploadfile, pythonreset, getmcn
 import errHandler from './error_handle';
 import SerialPort from 'serialport';
 
-//var request = require('request');
-//var querystring = require('querystring');
+var request = require('request');
+var querystring = require('querystring');
 
 /* ************ Functions ************ */
 
@@ -423,7 +423,7 @@ app.post('/pythonuploadfilebyfile', (req, res) => {
     //     res.status(401).send('disconnection');
 });
 
-//获取参数使用
+// //获取参数使用
 // us.getParm = function (req, cb) {
 
 // }
@@ -528,37 +528,37 @@ app.post('/testSerialPort', (req, res) => {
 
 });
 
-//clearCache();
+clearCache();
 
 //codingagent
-function CodingAlive() {
-    // setInterval(function () {
-    //     netRequest('/plugin/alive', { "PluginID": "CocoRoboX" })
-    // }, 1500)
-    // netRequest('/plugin/alive', { "PluginID": "CocoRoboX" });
-}
-
-//CodingAlive();
-
-function netRequest(p, j) {
-    // var contents = querystring.stringify(j);
-    // var contents = JSON.stringify(j)
-    // var options = {
-    //     url: "http://127.0.0.1:8991" + p,
-    //     method: 'POST',
-    //     headers: {
-    //         'Content-Type': 'text/plain'
-    //     },
-    //     body: contents
-    // }
-    // try {
-    //     request(options, function (error, response) {
-    //         if (error) throw new Error(error);
-    //     });
-    // }
-    // catch (e) {
+// function CodingAlive() {
+//     setInterval(function () {
+//         netRequest('/plugin/alive', { "PluginID": "CocoRoboX" })
+//     }, 1500)
+//     netRequest('/plugin/alive', { "PluginID": "CocoRoboX" });
+// }
 
-    // }
-}
+// CodingAlive();
+
+// function netRequest(p, j) {
+//     var contents = querystring.stringify(j);
+//     var contents = JSON.stringify(j)
+//     var options = {
+//         url: "http://127.0.0.1:8991" + p,
+//         method: 'POST',
+//         headers: {
+//             'Content-Type': 'text/plain'
+//         },
+//         body: contents
+//     }
+//     try {
+//         request(options, function (error, response) {
+//             if (error) throw new Error(error);
+//         });
+//     }
+//     catch (e) {
+
+//     }
+// }
 
 window.serial = debugTool();

+ 73 - 66
src/renderer/uploader.js

@@ -173,7 +173,7 @@ function getpythoval() {
                 for (let i = 0; i < results.length; i++) {
                     const val = results[i];
                     const mf = val.manufacturer;
-                    if (mf && mf.toLocaleLowerCase().indexOf('silicon') > -1) {
+                    if (mf && (mf.toLocaleLowerCase().indexOf('silicon') > -1 || mf.toLocaleLowerCase().indexOf('wch.cn') > -1)) {
                         resolve(val);
                         break;
                     }
@@ -358,12 +358,12 @@ export function pythonupload(code, val, socket) {
     return new Promise(async (resolve, reject) => {
         try {
             if (_childexec && !_childexec.killed) {
-                // try {
-                //     _childexec.stdin.write('\r\x1D');
-                // }
-                // catch (e) {
-                //     console.log(e);
-                // }
+                try {
+                    _childexec.stdin.write('\x03\x02\x03\x1D');
+                }
+                catch (e) {
+                    console.log(e);
+                }
                 _childexec.kill('SIGKILL');
                 _childexec.killed = true;
             }
@@ -385,7 +385,7 @@ export function pythonupload(code, val, socket) {
                 var _timeout = null;
                 var _strout = "";
                 var _strerr = "";
-                var arr = ["-m", "there", '--reset', "run", "-t", "6000", `${_pythonpath}`, "-p", `${val}`, "-i"];//
+                var arr = ["-m", "there", "--reset", "run", `${_pythonpath}`, "-p", `${val}`, "-i"];//
                 // exec(`cd "${pythonpath}" && /usr/local/bin/python3.8 -m there run "${_pythonname}" -p ${val} -i`, (err, stdout, stderr) =>
                 //     console.log(stderr)
                 // );
@@ -397,7 +397,7 @@ export function pythonupload(code, val, socket) {
                                 // 使用循环确保我们读取所有的可用数据。
                                 while ((chunk = _childexec.stdin.read()) !== null) {
                                     console.log(`数据: ${chunk}`);
-                                    _childexec.stdout.write('\r\x1D');
+                                    _childexec.stdout.write('\x03\x02\x03\x1D');
                                 }
                             });
                 
@@ -465,7 +465,7 @@ export function pythonupload(code, val, socket) {
                 resolve();
             }
             //resolve();
-        }, 3000);
+        }, 1000);
     });
 }
 
@@ -474,7 +474,7 @@ export function pythonupload(code, val, socket) {
 //         try {
 //             if (_childexec && !_childexec.killed) {
 //                 // try {
-//                 //     _childexec.stdin.write('\r\x1D');
+//                 //     _childexec.stdin.write('\x03\x02\x03\x1D');
 //                 // }
 //                 // catch (e) {
 //                 //     console.log(e);
@@ -498,7 +498,7 @@ export function pythonupload(code, val, socket) {
 //             var _timeout = null;
 //             var _strout = "";
 //             var _strerr = "";
-//             var arr = ["-m", "there", '--reset', "run", "-t", "6000", `${_pythonpath}`, "-p", `${val}`, "-i"];
+//             var arr = ["-m", "there",  "run", "-t", "6000", `${_pythonpath}`, "-p", `${val}`, "-i"];
 //             _childexec = spawn(_python, arr, { encoding: 'utf-8', timeout: 0 });
 //             /*
 //                         _childexec.stdin.on('readable', () => {
@@ -506,7 +506,7 @@ export function pythonupload(code, val, socket) {
 //                             // 使用循环确保我们读取所有的可用数据。
 //                             while ((chunk = _childexec.stdin.read()) !== null) {
 //                                 console.log(`数据: ${chunk}`);
-//                                 process.stdout.write('\r\x1D');
+//                                 process.stdout.write('\x03\x02\x03\x1D');
 //                             }
 //                         });
 
@@ -571,7 +571,7 @@ export function pythonupload(code, val, socket) {
 //         try {
 //             if (_childexec && !_childexec.killed) {
 //                 try {
-//                     _childexec.stdin.write('\r\x1D');
+//                     _childexec.stdin.write('\x03\x02\x03\x1D');
 //                 }
 //                 catch (e) {
 //                     console.log(e);
@@ -667,12 +667,12 @@ export function pythonuploadfile(code, namepath, val, socket) {
     return new Promise(async (resolve, reject) => {
         try {
             if (_childexec && !_childexec.killed) {
-                // try {
-                //     _childexec.stdin.write('\r\x1D');
-                // }
-                // catch (e) {
-                //     console.log(e);
-                // }
+                try {
+                    _childexec.stdin.write('\x03\x02\x03\x1D');
+                }
+                catch (e) {
+                    console.log(e);
+                }
                 _childexec.kill('SIGKILL');
                 _childexec.killed = true;
             }
@@ -710,7 +710,7 @@ export function pythonuploadfile(code, namepath, val, socket) {
                         socket.emit('repl', { code: _strout });
                     }
                     _strout = "";
-                }, 10);
+                }, 30);
             });
 
             //错误处理
@@ -725,7 +725,7 @@ export function pythonuploadfile(code, namepath, val, socket) {
                     }
                     _strerr = "";
                     //socket.emit('repl', { code: _strout });
-                }, 10);
+                }, 30);
             });
 
             //关闭处理
@@ -738,7 +738,7 @@ export function pythonuploadfile(code, namepath, val, socket) {
                 //console.log('exit code : ' + code);
             });
             resolve();
-        }, 3000);
+        }, 1000);
 
         // var cmd = `python -m there --reset push ${_pythonpath} /${_filename} -p ${val.comName}`;
         // //执行ampy
@@ -765,6 +765,12 @@ export function pythonuploadfilebyfile(file, namepath, val, socket) {
     return new Promise(async (resolve, reject) => {
         try {
             if (_childexec && !_childexec.killed) {
+                try {
+                    _childexec.stdin.write('\x03\x02\x03\x1D');
+                }
+                catch (e) {
+                    console.log(e);
+                }
                 _childexec.kill('SIGKILL');
                 _childexec.killed = true;
             }
@@ -802,7 +808,7 @@ export function pythonuploadfilebyfile(file, namepath, val, socket) {
                         socket.emit('repl', { code: _strout });
                     }
                     _strout = "";
-                }, 10);
+                }, 30);
             });
 
             //错误处理
@@ -817,7 +823,7 @@ export function pythonuploadfilebyfile(file, namepath, val, socket) {
                     }
                     _strerr = "";
                     //socket.emit('repl', { code: _strout });
-                }, 10);
+                }, 30);
             });
 
             //关闭处理
@@ -830,7 +836,7 @@ export function pythonuploadfilebyfile(file, namepath, val, socket) {
                 //console.log('exit code : ' + code);
             });
             resolve();
-        }, 3000);
+        }, 1000);
     });
 }
 
@@ -846,12 +852,12 @@ export function uploadfile(code, namepath, val, socket) {
     return new Promise(async (resolve, reject) => {
         try {
             if (_childexec && !_childexec.killed) {
-                // try {
-                //     _childexec.stdin.write('\r\x1D');
-                // }
-                // catch (e) {
-                //     console.log(e);
-                // }
+                try {
+                    _childexec.stdin.write('\x03\x02\x03\x1D');
+                }
+                catch (e) {
+                    console.log(e);
+                }
                 _childexec.kill('SIGKILL');
                 _childexec.killed = true;
             }
@@ -888,7 +894,7 @@ export function uploadfile(code, namepath, val, socket) {
                         socket.emit('repl', { code: _strout });
                     }
                     _strout = "";
-                }, 10);
+                }, 30);
             });
 
             //错误处理
@@ -903,7 +909,7 @@ export function uploadfile(code, namepath, val, socket) {
                     }
                     _strerr = "";
                     //socket.emit('repl', { code: _strout });
-                }, 10);
+                }, 30);
             });
 
             //关闭处理
@@ -916,7 +922,7 @@ export function uploadfile(code, namepath, val, socket) {
                 //console.log('exit code : ' + code);
             });
             resolve();
-        }, 3000);
+        }, 1000);
     });
 }
 
@@ -926,12 +932,12 @@ export function pythonreset(val, socket) {
     return new Promise(async (resolve, reject) => {
         try {
             if (_childexec && !_childexec.killed) {
-                // try {
-                //     _childexec.stdin.write('\r\x1D');
-                // }
-                // catch (e) {
-                //     console.log(e);
-                // }
+                try {
+                    _childexec.stdin.write('\x03\x02\x03\x1D');
+                }
+                catch (e) {
+                    console.log(e);
+                }
                 _childexec.kill('SIGKILL');
                 _childexec.killed = true;
             }
@@ -959,7 +965,7 @@ export function pythonreset(val, socket) {
                         socket.emit('repl', { code: _strout });
                     }
                     _strout = "";
-                }, 10);
+                }, 30);
             });
 
             //错误处理
@@ -974,7 +980,7 @@ export function pythonreset(val, socket) {
                     }
                     _strerr = "";
                     //socket.emit('repl', { code: _strout });
-                }, 10);
+                }, 30);
             });
 
             //关闭处理
@@ -987,7 +993,7 @@ export function pythonreset(val, socket) {
                 //console.log('exit code : ' + code);
             });
             resolve();
-        }, 3000);
+        }, 1000);
 
 
         // //发送文件给micropython板子
@@ -1006,12 +1012,12 @@ export function getmcnty(val, socket) {
     return new Promise(async (resolve, reject) => {
         try {
             if (_childexec && !_childexec.killed) {
-                // try {
-                //     _childexec.stdin.write('\r\x1D');
-                // }
-                // catch (e) {
-                //     console.log(e);
-                // }
+                try {
+                    _childexec.stdin.write('\x03\x02\x03\x1D');
+                }
+                catch (e) {
+                    console.log(e);
+                }
                 _childexec.kill('SIGKILL');
                 _childexec.killed = true;
             }
@@ -1049,7 +1055,7 @@ export function getmcnty(val, socket) {
                         }
                         socket.emit('repl', { code: _strout });
                         _strout = "";
-                    }, 10);
+                    }, 30);
                 });
 
                 //错误处理
@@ -1061,11 +1067,11 @@ export function getmcnty(val, socket) {
                             resolve("AI");
                         }
                         else {
-                            reject(_strerr);
+                            resolve("");
                         }
                         _strerr = "";
                         //socket.emit('repl', { code: _strout });
-                    }, 10);
+                    }, 30);
                 });
 
                 //关闭处理
@@ -1078,7 +1084,7 @@ export function getmcnty(val, socket) {
                     //console.log('exit code : ' + code);
                 });
             }
-        }, 3000);
+        }, 1000);
     });
 }
 
@@ -1099,12 +1105,12 @@ export function pythoncmd(code, val, socket) {
     return new Promise(async (resolve, reject) => {
         try {
             if (_childexec && !_childexec.killed) {
-                // try {
-                //     _childexec.stdin.write('\r\x1D');
-                // }
-                // catch (e) {
-                //     console.log(e);
-                // }
+                try {
+                    _childexec.stdin.write('\x03\x02\x03\x1D');
+                }
+                catch (e) {
+                    console.log(e);
+                }
                 _childexec.kill('SIGKILL');
                 _childexec.killed = true;
             }
@@ -1113,12 +1119,11 @@ export function pythoncmd(code, val, socket) {
             console.log(e);
         }
         //发送文件给micropython板子
-        //var val = await getpythoval().catch(e => err = e);
         setTimeout(function () {
             var _timeout = null;
             var _strout = "";
             var _strerr = "";
-            var arr = ["-m", "there", '--reset', "-c", `${code}`, "-p", `${val}`];
+            var arr = ["-m", "there", "-c", `${code}`, "-p", `${val}`];
             _childexec = spawn(_python, arr, { encoding: 'utf-8', timeout: 0 });
             //成功执行获取值处理
             _childexec.stdout.on('data', function (chunk) {
@@ -1135,8 +1140,9 @@ export function pythoncmd(code, val, socket) {
                         socket.emit('repl', { code: _strout });
                     }
                     //
+                    // resolve(_strout);
                     _strout = "";
-                }, 100);
+                }, 30);
             });
 
             //错误处理
@@ -1150,8 +1156,9 @@ export function pythoncmd(code, val, socket) {
                         socket.emit('upload', { ProgrammerStatus: 'Error', Error: error });
                     }
                     _strerr = "";
+                    // resolve(_strerr);
                     //socket.emit('repl', { code: _strout });
-                }, 10);
+                }, 30);
             });
 
             //关闭处理
@@ -1164,7 +1171,7 @@ export function pythoncmd(code, val, socket) {
                 //console.log('exit code : ' + code);
             });
 
-        }, 3000);
+        }, 1000);
     });
 }
 
@@ -1175,7 +1182,7 @@ function spawnlisten(spawnObj) {
         // 使用循环确保我们读取所有的可用数据。
         while ((chunk = _childexec.stdin.read()) !== null) {
             console.log(`数据: ${chunk}`);
-            process.stdout.write('\r\x1D');
+            process.stdout.write('\x03\x02\x03\x1D');
         }
     });
 

BIN
src/static/common/cocorobo.ico


BIN
src/static/common/cocorobo.png


BIN
src/static/common/cocorobo_.ico


BIN
src/static/common/cocorobo_.png


+ 2 - 2
src/static/win/installer.nsh

@@ -7,7 +7,7 @@
 !macroend
 
 !macro customInstall
-    ; WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run""XGOEdu" "$INSTDIR\XGOEdu.exe"
+    ; WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run""CocoRoboXDeskTop" "$INSTDIR\CocoRoboXDeskTop.exe"
     nsExec::Exec ".\resources\ca.bat"
     ${ifNot} ${isUpdated}
         ; ${If} ${RunningX64}
@@ -31,5 +31,5 @@
     #nsExec::Exec 'cmd.exe /c del "$INSTDIR\resources\ca.bat" "$INSTDIR\resources\ca.crt" "$INSTDIR\python\python-3.8.0-amd64.bat" "$INSTDIR\python\python-3.8.0.bat" "$INSTDIR\cp210x_drivers\CP210xVCPInstaller_x64.bat" "$INSTDIR\cp210x_drivers\CP210xVCPInstaller_x86.bat"'
 !macroend
 !macro customUnInstall
-    DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "XGOEdu"
+    DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "CocoRoboXDeskTop"
 !macroend

+ 1 - 1
src/static/win/python/python-3.7.3-embed-win32/Lib/site-packages/there/repl_connection.py

@@ -136,7 +136,7 @@ class MicroPythonRepl(object):
         self.serial.rts = False
         self.serial.dsrdtr = False
         self.serial.rtscts = False
-        self.serial.readlines()
+        self.serial.read(99999)
         if user is not None:
             time.sleep(0.1)
             self.serial.read_until(b'Login as: ')

+ 1 - 1
src/static/win/python/python-3.8.3-embed-amd64/Lib/site-packages/there/repl_connection.py

@@ -136,7 +136,7 @@ class MicroPythonRepl(object):
         self.serial.rts = False
         self.serial.dsrdtr = False
         self.serial.rtscts = False
-        self.serial.readlines()
+        self.serial.read(99999)
         if user is not None:
             time.sleep(0.1)
             self.serial.read_until(b'Login as: ')

+ 1 - 1
webpack.config.renderer.js

@@ -84,7 +84,7 @@ let config = {
         }),
         new CopyPlugin({
             patterns: [
-                { from: __dirname + "/src/renderer/cocoblockly-x", to: "cocoblockly-x" }]
+                { from: __dirname + "/src/renderer/cocoblockly-x/", to: "cocoblockly-x/" }]
         }),
         new CopyPlugin({
             patterns: [