kelly / node-i2c

Node.js native bindings for i2c-dev. Plays well with Raspberry Pi and Beaglebone.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

debug causes RangeError: toString() radix argument

mgold opened this issue · comments

If one passes debug: true in the second argument of the i2c constructor, the program crashes with a very strange error.

$ node debug_error.js 
i2c > 
string_decoder.js:109
  charStr += buffer.toString(this.encoding, 0, end);
                    ^
RangeError: toString() radix argument must be between 2 and 36
    at Number.toString (native)
    at StringDecoder.write (string_decoder.js:109:21)
    at ReadStream.onData (readline.js:839:39)
    at ReadStream.EventEmitter.emit (events.js:95:17)
    at new i2c (/home/pi/i2c/node_modules/i2c/lib/i2c.coffee:30:23)
    at Object.<anonymous> (/home/pi/i2c/debug_error.js:3:7)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

To reproduce:

$ cat debug_error.js 
i2c = require('i2c');

bus = new i2c(0x08, {
    device: '/dev/i2c-1',
    debug: true
});

This bug has been reported on this forum.

This has been fixed in the master branch.

Sorry for the dupe. Maybe cut a new release?

npm updated