Commit 1261225a authored by lyong's avatar lyong

feat:产测rtc检测条件增加基于osf寄存器

parent 1591ab36
......@@ -218,6 +218,29 @@ function getRtcTime() {
return { err: 1, msg: 'RTC device not found', time: 'NA' };
}
// 检测驱动信号
var rtcEnPath = "/sys/devices/platform/soc@3000000/2502000.twi/i2c-0/0-0051/osf";
console.log("rtcEnPath: " + rtcEnPath);
if (fs.exists("../../../../.." + rtcEnPath)) {
// return { err: 1, msg: 'RTC enable file not found', time: 'NA' };
system("cat " + rtcEnPath + " > /tmp/rtc_en.txt");
var debugStr = fs.read("/tmp/rtc_en.txt", "r");
console.log("debugStr: " + debugStr);
if (debugStr === null || debugStr === undefined) {
console.log("Failed to read data from file.");
return { err: 1, msg: 'Failed to read RTC enable file', time: 'NA' };
}
var stateStr = debugStr.trim();
if (stateStr == "1") {
return { err: 1, msg: 'RTC is disabled by driver', time: 'NA' };
}
}
// 1. 执行 hwclock
system('hwclock -f /dev/rtc1 > /tmp/hwRtc.txt 2>&1'); // 把 stderr 也重定向
const raw = fs.read('/tmp/hwRtc.txt');
......
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