Commit 1591ab36 authored by lyong's avatar lyong

增加lcd返回tp版本号

parent 7eef828e
......@@ -140,7 +140,9 @@ function doLcd(fd) {
autoUtil.initUI();
autoUtil.setAutoModeUI("LCD");
// autoUtil.ledTimerOut();
send(fd, '+OK');
var tpId = "+" + autoUtil.getTPVersion()
send(fd, tpId);
}
......
......@@ -784,7 +784,71 @@ function calculateSumChecksum(dataString) {
return "0X00"; // 或返回错误码/None
}
}
function getTPVersion() {
var versionVal = getTPVersionNew();
console.log("getTPVersion 1: " + versionVal);
if (versionVal == "FAIL") {
versionVal = getTPVersionOld();
console.log("getTPVersion 2: " + versionVal);
}
return versionVal;
}
function getTPVersionNew() {
// 执行系统命令,将设备信息保存到临时文件
var checkVersionPath = "../../../../.." + "/sys/devices/platform/soc@3000000/2502800.twi/i2c-2/2-0055/stinform";
console.log("checkVersionPath: " + checkVersionPath);
if (!fs.exists(checkVersionPath)) {
return "FAIL";
}
system("cat " + checkVersionPath + " > /tmp/tp_version1.txt");
// 读取临时文件内容
const infoStr = fs.read("/tmp/tp_version1.txt", "r");
if (infoStr) {
// 按行分割文件内容
const infoLines = infoStr.split('\n');
for (let i = 0; i < infoLines.length; i++) {
const line = infoLines[i].trim();
// 检查是否包含 "FW Version" 信息
if (line.startsWith("FW Version")) {
// 提取版本号
const version = line.split('=')[1].trim();
// 转换为10进制
const decimalValue = parseInt(version, 16);
return decimalValue.toString();
}
}
}
return "FAIL"; // 如果未找到版本信息,返回 "NG"
}
function getTPVersionOld() {
// 执行系统命令,将设备信息保存到临时文件
var checkVersionPath = "../../../../.." + "/proc/gt1x_debug";
console.log("checkVersionPath: " + checkVersionPath);
if (!fs.exists(checkVersionPath)) {
return "FAIL";
}
console.log("getTPVersion 1");
system("cat " + checkVersionPath + " > /tmp/gt1x_debug.txt");
// 读取临时文件内容
const debugStr = fs.read("/tmp/gt1x_debug.txt", "r");
if (debugStr) {
// 按行分割文件内容
const debugLines = debugStr.split('\n');
for (let i = 0; i < debugLines.length; i++) {
const line = debugLines[i].trim();
// 检查是否包含有效数据
if (line.startsWith("0x")) {
// 提取第一个值
const firstValue = line.split(',')[0].trim();
const decimalValue = parseInt(firstValue, 16);
return decimalValue.toString();
}
}
}
return "FAIL"; // 如果未找到有效数据,返回 "NG"
}
function system(cmd) {
systemCtrl.executeSystemCommand(cmd)
......@@ -826,5 +890,6 @@ module.exports = {
getHostid: getHostid,
readHostIdData: readHostIdData,
gotoWriteHostIdData: gotoWriteHostIdData,
verifyHostIDChecksum: verifyHostIDChecksum
verifyHostIDChecksum: verifyHostIDChecksum,
getTPVersion: getTPVersion
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment