我试图从DS18B20读取执行digitem的node.js温度传感器,但输出中没有温度值。以下是代码:
var exec = require('child_process').exec;
child = exec('/usr/bin/digitemp_DS9097 -s /dev/ttyUSB0 -a',
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});产出:
stdout: DigiTemp v3.5.0 Copyright 1996-2007 by Brian C. Lane
GNU Public License v2.0 - http://www.digitemp.com如果在linux中执行命令/usr/bin/digitemp_DS9097 -s /dev/ttyUSB0 -a,就会得到结果。我可以在node.js中获得带有node.js选项的传感器列表,所以问题不在于读取传感器。
发布于 2013-11-29 20:42:13
问题是从node.js执行的数字项目。Digitemp使用主文件夹中的.digitemprc配置文件,但node.js不尊重它,忽略或不查看用户主文件夹。我必须手动定义混合文件,以便在与node.js文件相同的文件夹中使用或生成/复制配置文件。
https://stackoverflow.com/questions/20275915
复制相似问题