node-i2c icon indicating copy to clipboard operation
node-i2c copied to clipboard

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

Open Andrewiski opened this issue 9 years ago • 0 comments

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

`

Andrewiski avatar May 31 '16 01:05 Andrewiski