debug(shell-micropython): 添加详细调试日志以定位引号错误
This commit is contained in:
@@ -25,6 +25,13 @@ export default class ShellMicroPython extends Shell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async upload(config) {
|
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 字符串
|
// 正确处理 reset 参数:如果是数组则序列化为 JSON 字符串
|
||||||
let resetValue = config.reset;
|
let resetValue = config.reset;
|
||||||
if (Array.isArray(resetValue)) {
|
if (Array.isArray(resetValue)) {
|
||||||
@@ -32,6 +39,7 @@ export default class ShellMicroPython extends Shell {
|
|||||||
} else if (resetValue === undefined || resetValue === null) {
|
} else if (resetValue === undefined || resetValue === null) {
|
||||||
resetValue = '[]';
|
resetValue = '[]';
|
||||||
}
|
}
|
||||||
|
console.log('Processed resetValue:', resetValue);
|
||||||
|
|
||||||
const info = {
|
const info = {
|
||||||
indexPath: path.resolve(CLIENT_PATH, config.boardDirPath),
|
indexPath: path.resolve(CLIENT_PATH, config.boardDirPath),
|
||||||
@@ -39,11 +47,18 @@ export default class ShellMicroPython extends Shell {
|
|||||||
com: config.port,
|
com: config.port,
|
||||||
reset: resetValue
|
reset: resetValue
|
||||||
};
|
};
|
||||||
|
console.log('Info object:', JSON.stringify(info));
|
||||||
|
|
||||||
// 兼容性处理:移除模板中可能存在的冗余引号
|
// 兼容性处理:移除模板中可能存在的冗余引号
|
||||||
let cmdTemplate = config.command || "";
|
let cmdTemplate = config.command || "";
|
||||||
|
console.log('Original cmdTemplate:', cmdTemplate);
|
||||||
cmdTemplate = cmdTemplate.replace(/"{ampy}"/g, '{ampy}');
|
cmdTemplate = cmdTemplate.replace(/"{ampy}"/g, '{ampy}');
|
||||||
|
console.log('After quote cleanup:', cmdTemplate);
|
||||||
|
|
||||||
const command = MString.tpl(cmdTemplate, info);
|
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);
|
return this.execUntilClosed(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user