Using i2c with bonescript

280 views
Skip to first unread message

Mark A. Yoder

unread,
Aug 2, 2016, 12:52:22 PM8/2/16
to BeagleBoard
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 
BeagleBoard.org 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:
/usr/local/lib/node_modules/bonescript/src/iic.js:15
    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.<anonymous> (/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?

Thanks...

--Mark

Wally Bkg

unread,
Aug 5, 2016, 12:14:49 AM8/5/16
to BeagleBoard
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.
Reply all
Reply to author
Forward
0 new messages