2

I want to use node.js mraa library for Galileo. I need to set up an interrupt. I achieve this by:

 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 );

i get this errors

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

The documentation for this function states

 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

I don't know how to set up the params of function...

0andriy
  • 4,183
  • 1
  • 24
  • 37
Val Valli
  • 55
  • 5
  • I am not familiar with the capabilities of the mraa library but have you considered using Johnny-Five and Galileo-IO for reading your sensor? – Tim Cavanaugh Nov 05 '14 at 14:35

2 Answers2

0

There is an open issue about this. The current response is that the isr method is not currently working.

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

0

As pointed out in the issue, you can now do:

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

You'll need to be on v0.5.4-134-gd6891e8 or later from the master branch. You can use npm to get the correct version installed on your board or just compile form sources (you'll need SWIG 3.x)

npm install mraa