英特尔Edison MRAA模块不工作

我最近下载了英特尔XDK IOT版本,并使用LED引脚13闪烁示例。 然后我把程序上传到爱迪生上,但是出现了一些错误; 其中之一就是无法findMRAA模块。 随附的示例代码是:main.js:

var mraa = new require("mraa"); //require mraa console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the Intel XDK console var myOnboardLed = new mraa.Gpio(13); //LED hooked up to digital pin 13 (or built in pin on Galileo Gen1 & Gen2) myOnboardLed.dir(mraa.DIR_OUT); //set the gpio direction to output var ledState = true; //Boolean to hold the state of Led periodicActivity(); //call the periodicActivity function function periodicActivity() { myOnboardLed.write(ledState?1:0); //if ledState is true then write a '1' (high) otherwise write a '0' (low) ledState = !ledState; //invert the ledState setTimeout(periodicActivity,1000); //call the indicated function after 1 second (1000 milliseconds) } 

的package.json:

 { "name": "Onboard LED Blink App", "description": "", "version": "0.0.0", "main": "main.js", "engines": { "node": ">=0.10.0" }, "dependencies": { } } 

echo“src mraa-upm http://iotdk.intel.com/repos/1.1/intelgalactic ”> /etc/opkg/mraa-upm.conf opkg update opkg install libmraa0

上面的答案有错别字应该是“mraa”而不是“maa”而opkg不是okpg

根据您拥有的Edison固件版本,Node.js的mraa模块可能没有正确安装。 要安装最新版本的mraa,请将爱迪生连接到互联网(通过wifi),并通过ssh或串行terminal运行以下命令

 echo "src mraa-upm http://iotdk.intel.com/repos/1.1/intelgalactic" > /etc/opkg/mraa-upm.conf okpg update opkg upgrade 

echo“src mraa-upm http://iotdk.intel.com/repos/1.1/intelgalactic ”> /etc/opkg/mraa-upm.conf opkg update opkg install libmraa0

SRC https://github.com/intel-iot-devkit/mraa

您也可以从npm中获取最新版本(它将使用git master HEAD中预先生成的SWIG包装器并将其构build在您的主板上)。

npm安装mraa

这里是关于如何在这里工作的更多细节 – http://iotdk.intel.com/docs/master/mraa/npmpkg.html

在XDK IDE中,在右侧的串行/terminal区域上方有一个下拉设置控制。 如果你下拉这个列表,它可以select更新所有的库和节点守护进程。 这是一个更简单的方法,以确保MRAA和所有其他板上的最新和configuration正确。