kelly / node-i2c

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

constructor callback for wrapped Open in constructor to get err and make async #76

Open Andrewiski opened 8 years ago

Andrewiski commented 8 years ago

given the code block below from your source there is no way to pass in a callback to get the Err on the constructor either via options or third param of Callbak

`constructor: (@address, @options = {}) -> _.defaults @options, debug: false device: "/dev/i2c-1"

if @options.debug 
  require('repl').start(
    prompt: "i2c > "
  ).context.wire = @
  process.stdin.emit 'data', '' # trigger repl

process.on 'exit', => @close()

@on 'data', (data) => 
  @history.push data

@on 'error', (err) ->
  console.log "Error: #{error}"

@open @options.device, (err) =>
  unless err then @setAddress @address

`