diff --git a/src/common/shell-micropython.js b/src/common/shell-micropython.js index 91634534..303ac0ac 100755 --- a/src/common/shell-micropython.js +++ b/src/common/shell-micropython.js @@ -25,6 +25,13 @@ export default class ShellMicroPython extends Shell { } async upload(config) { + // 调试:打印接收到的原始配置 + console.log('=== UPLOAD DEBUG START ==='); + console.log('Received config.command:', JSON.stringify(config.command)); + console.log('Received config.reset:', JSON.stringify(config.reset)); + console.log('Received config.port:', config.port); + console.log('Received config.boardDirPath:', config.boardDirPath); + // 正确处理 reset 参数:如果是数组则序列化为 JSON 字符串 let resetValue = config.reset; if (Array.isArray(resetValue)) { @@ -32,6 +39,7 @@ export default class ShellMicroPython extends Shell { } else if (resetValue === undefined || resetValue === null) { resetValue = '[]'; } + console.log('Processed resetValue:', resetValue); const info = { indexPath: path.resolve(CLIENT_PATH, config.boardDirPath), @@ -39,11 +47,18 @@ export default class ShellMicroPython extends Shell { com: config.port, reset: resetValue }; + console.log('Info object:', JSON.stringify(info)); + // 兼容性处理:移除模板中可能存在的冗余引号 let cmdTemplate = config.command || ""; + console.log('Original cmdTemplate:', cmdTemplate); cmdTemplate = cmdTemplate.replace(/"{ampy}"/g, '{ampy}'); + console.log('After quote cleanup:', cmdTemplate); + const command = MString.tpl(cmdTemplate, info); - console.log('DEBUG CMD UPLOAD:', command); + console.log('Final command:', command); + console.log('=== UPLOAD DEBUG END ==='); + return this.execUntilClosed(command); } } \ No newline at end of file