fix(display): use execSync shell pipe instead of fs.writeFileSync to avoid EINVAL

Made-with: Cursor
This commit is contained in:
stswangzhiping
2026-03-18 21:11:22 +08:00
parent 9da4cd0aa1
commit a737101c2e

View File

@@ -1,7 +1,8 @@
'use strict'; 'use strict';
const fs = require('fs'); const fs = require('fs');
const log = require('./logger'); const { execSync } = require('child_process');
const log = require('./logger');
/** /**
* 前面板指示灯控制 * 前面板指示灯控制
@@ -110,9 +111,10 @@ class Display {
_write(val) { _write(val) {
try { try {
fs.writeFileSync(DISPLAY_PATH, val); // 用 shell 管道写入,与 echo "..." | tee ... 行为完全一致
execSync(`echo "${val}" | tee ${DISPLAY_PATH} > /dev/null`, { timeout: 3000 });
} catch (e) { } catch (e) {
log.warn('display', `写入失败 (${DISPLAY_PATH}): ${e.message}`); log.warn('display', `写入失败: ${e.message}`);
} }
} }
} }