2014-10-02 54 views
7

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

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": { 
    } 
} 

回答

3

回声“SRC mraa-UPM http://iotdk.intel.com/repos/1.1/intelgalactic”>的/ etc/opkg/mraa运行以下命令-upm.conf opkg更新 opkg安装libmraa0

以上回答具有错别字 它应该是 “mraa” 而不是 “MAA” 和opkg不okpg

+0

这个工作完全谢谢 – 2014-10-10 03:27:40

5

取决于你有什么版本的爱迪生的固件,使用Node.js语言的mraa模块可能没有正确安装。要安装最新版本的mraa您爱迪生连接到互联网(通过WiFi),并通过ssh或串行终端

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

在XDK IDE,有一个下拉菜单设置控制正上方右侧的串行/航站区。如果你下拉这个列表,它可以选择更新所有的库和节点守护进程。这是确保MRAA和板上所有其他代码都是最新且配置正确的更简单的方法。