Using i2c with bonescript

I’m trying to access an i2c device via bonescript and I’m getting an error.

Here’s the OS info:

uname -a
Linux yoder-debian-bone 4.4.15-ti-r37 #1 SMP Tue Jul 19 17:04:02 UTC 2016 armv7l GNU/Linux
cat /etc/dogtag Debian Image 2016-08-01

Here’s the code:

var b = require(‘bonescript’);
var bus = ‘/dev/i2c-2’;

var TMP006 = 0x40;

b.i2cOpen(bus, TMP006);
b.i2cReadByte(bus, onReadByte);

function onReadByte(x) {
if(x.event == ‘callback’) {

console.log('onReadByte: ’ + JSON.stringify(x));



Here’s the error:

if(m.ports[args.port[0]].path) path = m.ports[args.port[0]].path;
TypeError: Cannot read property ‘path’ of undefined
at Object.m.doOpen (/usr/local/lib/node_modules/bonescript/src/iic.js:15:29)
at Object.newFunction [as i2cOpen] (/usr/local/lib/node_modules/bonescript/src/my.js:425:31)
at Object. (/root/exercises/sensors/si7021/si7021.js:11:3)
at Module._compile (module.js:460:26)
at Object.Module._extensions…js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3

Here’s the plea:

How do I fix this?



Probably because the /sys directory layout has changed.

I’m not much of an actual Bonescript user, but I’ve been playing with it to help out a friend and I’ve found it very fragile with changes in kernel versions, and various Debian supporting packages.

Honestly I don’t think all the bonescript101 embedded webpage example code has run correctly since the final Angstrom distribution.