Ok, so, this line of code: *Analogvalue = b.analogRead(AnaloginputPin);* You need to:
1. Check the value of *Analogvalue* 2. If the value is -1, then reread the value until the value is greater than 0( zero means buffer empty ) 3. Once the value is a positive value, then you can process *Analogvalue *accordingly. On Sun, Oct 4, 2015 at 7:45 PM, William Hermans <[email protected]> wrote: > *Error: EAGAIN, resource temporarily unavailable* > > > I can not speak to bonescript, or what you're using javascript wise. But I > can say that this error can happen when the ADC channel in question is not > done updating the "buffer". > > So in the C programming language, what you end up having to do is close > the file descriptor, reopen the file descriptor, then try again. When the > length of the read file descriptor returns -1. How this applies to your > javascript code . . . I could not say, but there you have it. > > On Sun, Oct 4, 2015 at 5:34 PM, alan dussel <[email protected]> > wrote: > >> i am not sure but i think buried somewhere in the BBB service reference >> manual ( i think that is the right name ) it mentions something that made >> me think, there is only one A/D converter and the other inputs are >> multiplexed. Another thing to check might be the pin you are trying to use >> maybe already used by some other device or service. I am using an LCD 7 >> which consumes four of the A/D inputs. >> >> hope that helps ! >> >> >> >> On Thursday, September 24, 2015 4:17 PM, 'Don Terry' via BeagleBoard < >> [email protected]> wrote: >> >> >> I have searched BeagleBoard forums for this answer but only found single >> A/D responses. Since I already have a single A/D channel working this was >> no help. >> >> I am trying to read two analog pins but I get the following error message: >> 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/hw_capemgr.js:214:30) >> at Object.f.analogRead >> (/usr/local/lib/node_modules/bonescript/index.js:229:15) >> >> The code below is from the 'fade' demo example. I can read either one at >> a time but when both are in the loop the error occurs after a while. Is the >> ADC still busy when the second analogRead occurs? >> >> Linux beaglebone 3.8.13-bone47 #1 SMP Fri Apr 11 01:36:09 UTC 2014 armv7l >> GNU/Linux >> BeagleBone Black rev 00C0 running BoneScript 0.2.4 >> >> >> var b = require('bonescript'); >> >> // setup starting conditions >> var awValue = 0.01; >> var awDirection = 1; >> var awPin = "P9_14"; >> var AnaloginputPin = "P9_38"; >> var MyTargetVoltage = 0; >> var PWMAnalogVoltage = "P9_36"; >> var PWMAnalogVoltVal = 0; >> var Analogvalue = 0; >> >> // configure pin >> b.pinMode(awPin, b.ANALOG_OUTPUT); >> >> // call function to update brightness every 10ms >> setInterval(fade, 100); >> >> // function to update brightness >> function fade() { >> b.analogWrite(awPin, awValue); >> awValue = awValue + (awDirection*0.01); >> Analogvalue = b.analogRead(AnaloginputPin); >> MyTargetVoltage = Analogvalue * 1.803; >> console.log(MyTargetVoltage); >> PWMAnalogVoltVal = b.analogRead(PWMAnalogVoltage) * 1.803; >> console.log(PWMAnalogVoltVal); >> if(awValue > 1.0) { awValue = 1.0; awDirection = -1; } >> else if(awValue <= 0.01) { awValue = 0.01; awDirection = 1; >> } >> } >> >> output is >> >> 0.20333833333333334 >> 0.44273666666666667 >> 0.18530833333333332 >> 0.44273666666666667 >> 0.19632666666666665 >> 0.441735 >> 0.18130166666666664 >> 0.44273666666666667 >> 0.23338833333333334 >> 0.441735 >> 0.22136833333333333 >> 0.44273666666666667 >> 0.19332166666666664 … until error message >> >> Thanks >> -- >> 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 [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> >> >> -- >> 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 [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
