Update: WebSocket模式添加对Serial和Arduino编译上传的支持

This commit is contained in:
王立帮
2024-12-01 14:42:25 +08:00
parent d8ceafadbf
commit d245eaf458
21 changed files with 4717 additions and 41 deletions

View File

@@ -0,0 +1,48 @@
import _ from 'lodash';
import Shell from './shell';
import { ARDUINO } from './config';
export default class ShellArduino extends Shell {
constructor() {
super();
}
async compile(config) {
let arduino = _.merge({}, ARDUINO);
arduino = _.merge(arduino, config);
const command = [
`"${arduino.path.cli}"`,
'compile',
'-b', arduino.key,
'--config-file', `"${arduino.path.config}"`,
'--build-cache-path', `"${arduino.path.cache}"`,
'--verbose',
'--libraries', `"${arduino.path.libraries.join('","')}"`,
'--build-path', `"${arduino.path.build}"`,
`"${arduino.path.code}"`,
'--no-color'
].join(' ');
return this.exec(command);
}
async upload(config) {
let arduino = _.merge({}, ARDUINO);
arduino = _.merge(arduino, config);
const command = [
`"${arduino.path.cli}"`,
'compile',
'--upload',
'-p', arduino.port,
'-b', arduino.key,
'--config-file', `"${arduino.path.config}"`,
'--build-cache-path', `"${arduino.path.cache}"`,
'--verbose',
'--libraries', `"${arduino.path.libraries.join('","')}"`,
'--build-path', `"${arduino.path.build}"`,
`"${arduino.path.code}"`,
'--no-color'
].join(' ');
return this.exec(command);
}
}