2014-11-03 53 views
2

我想为伽利略使用node.js mraa库。 我需要设置一个中断。 我通过实现这一点:Node.js函数不能用于isr galileo板

var param=1; 

var myLed = new mraa.Gpio(2); 

myLed.dir(mraa.DIR_IN); //set the gpio direction to input 

myLed.isr(mraa.EDGE_BOTH,function f(x){},param); 

我得到这个错误

in method 'Gpio_isr', argument 3 of type 'void (*)(void *)' 

这个函数的文档指出

mraa_result_t isr ( Edge mode, 
    void(*)(void *) fptr, 
    void * args 
    )   

Sets a callback to be called when pin value changes 

Parameters 
mode The edge mode to set 
fptr Function pointer to function to be called when interupt is triggered 
args Arguments passed to the interrupt handler (fptr) 
Returns 
Result of operation 

我不知道如何设置的功能PARAMS ...

+0

我不熟悉的功能mraa库,但是你有没有考虑使用Johnny-Five和Galileo-IO来读取你的传感器? – 2014-11-05 14:35:27

回答

0

正如问题所指出的,你现在可以做的:

var m = require('mraa') 
function h() { 
    console.log("HELLO!!!!") 
} 
x = new m.Gpio(14) 
x.isr(m.EDGE_BOTH, h) 

你需要上v0.5.4-134-gd6891e8或以后从主科。您可以使用NPM让您的主板安装了正确的版本,或只是编译形式源(你需要SWIG 3.X)

NPM安装mraa