I've been having problems when doing a lot of bonescript analogRead calls 
successively. For example this code loops through about 7 times and then 
crashes: 

var b = require('bonescript');
var count=0;
while (true){
    console.log(count++);
    a1=b.analogRead('P9_36');
    a2=b.analogRead('P9_33');
    a3=b.analogRead('P9_35');
    a4=b.analogRead('P9_37');
}

*This is the program output, followed by the error message: *

0
1
2
3
4
5
6


fs.js:481
  var r = binding.read(fd, buffer, offset, length, position);
                  ^
Error: EAGAIN, resource temporarily unavailable
    at Object.fs.readSync (fs.js:481:19)
    at Object.fs.readFileSync (fs.js:315:28)
    at Object.exports.readAIN 
(/usr/local/lib/node_modules/bonescript/src/hw_capemgr.js:351:30)
    at Object.f.analogRead 
(/usr/local/lib/node_modules/bonescript/src/index.js:266:19)
    at Object.<anonymous> (/var/lib/cloud9/analogread2.js:8:10)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

*Also tried this:*
I tried doing a function callback and then assigning the value within the 
callback. This code, for example: 
var b = require('bonescript');
var a1=0;
while (true){
 b.analogRead('P9_36',assignValue);
 function assignValue(x){a1=x.value;}
 console.log(a1);
}

But... it doesn't work. The output is just:
0
0
0
0
...

ad nauseum. 

I have checked the x.value directly and it is a non zero number, but for 
some reason the a1 doesn't get assigned the x.value number even though a1 
is global.

Any suggestions? 



-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to