kelly / node-i2c

Node.js native bindings for i2c-dev. Plays well with Raspberry Pi and Beaglebone.
Other
216 stars 91 forks source link

Guidance for returning result from read #106

Open Toshiba01 opened 1 year ago

Toshiba01 commented 1 year ago

Hi,

I need a little bit of guidance:

wire.read(length, function(err, res) { // result contains a buffer of bytes });

taking in consideration this function, how can I return result value to be used in the code outside of this function?

something like: var returnedValue = wire.read(length, function(err, res){ return res})

Thank you!

kelly commented 1 year ago

I'd recommend using Promises if you can't use the callback block.