Node.js函数不能用于isr galileo板

我想使用伽利略的node.js mraa库。 我需要设置一个中断。 我通过以下方式来实现

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 *)' 

此function的文档状态

  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 

我不知道如何设置function的参数…

这是一个开放的问题。 当前的响应是isr方法当前不工作。

链接: https : //github.com/intel-iot-devkit/mraa/issues/110

正如在这个问题中指出的,你现在可以做到:

 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

Interesting Posts