Hi all,

I am using the following C++ code to read values from an ADC. 
HandleOKCallback is properly called and adc and volt arrays are being 
filled with data.


 class ReadWorker : public Nan::AsyncWorker {
    public:
      ReadWorker(Nan::Callback *callback, int channel): 
Nan::AsyncWorker(callback), channel(channel) { }

      void Execute() {
        ...
      }

      void HandleOKCallback() {
        Nan:: HandleScope scope;

        Local<Value> argv[3];
        argv[1] = Nan::New<Array>(*adc),
        argv[2] = Nan::New<Array>(*volt);

        if (!initialized) {
          argv[0] = Nan::Error("failed to initialize ADC");
        } else if (failed) {
          argv[0] = Nan::Error("failed to read ADC");
        } else {
          argv[0] = Nan::Null();
        }

        callback->Call(3, argv);
      }
   private:
    int channel;
    int32_t adc[8];
    int32_t volt[8];
    ...


However the following Javascript yields an error under node.js telling me 
that adc and volt are not available.

ad.read(channel, function(err, adc, volt) {
   end = new Date().getTime();
    if (err) {
      console.warn('' + err);
    } else {
      var elapsed = end - start;
      console.log("adc: %s, volt: %s%%, time: %dms", adc[7].toFixed(2), 
volt[7].toFixed(2), end - start);
    }
  });

I assume that there is something wrong with the code highlighted in red 
above but I don't get it. Any help is appreciated!

Thanks,
Martin. 

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/44486850-64d3-43a1-af84-fc0e2bc5d91d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to