opening 2 different I2C devices
Greetings,
I have a Cape connected to a BBB board that has an RTC chip connected to I2C2 and an I/O expander that connects to I2C1. If I run the code for each separately in different javascript files things work well. When I combine the two codes together, the software crashes. Here is a snippet of what I have: var b = require("bonescript") // RTC var port = '/dev/i2c-2'; var address = 0x68; var writeArray = []; var readArray = [];
// GPIO var port2 = 'dev/i2c-1'; var gpioAddress = 0x27; var timerOperation; var gpioWriteArray = [];
b.i2cOpen(port, address, {}, setupRTC); readRTCTime(); console.log("UTC Time: " + getTime()); console.log("UTC date: " + getDayAndMonth()); console.log("Alarm is set for 20 seconds from now");
b.i2cOpen(port2, gpioAddress, {}, setupMCP23008); ^^^^^^^^^ crashes here with the following dump ^^^ UTC Time: 22:32:48 UTC date: 11/11/2014 Alarm is set for 20 seconds from now
/usr/local/lib/node_modules/bonescript/iic.js:15
if(m.ports[args.port].path) path = m.ports[args.port].path;
^
TypeError: Cannot read property 'path' of undefined
at Object.m.doOpen (/usr/local/lib/node_modules/bonescript/iic.js:15:26)
at Object.newFunction as i2cOpen
at Object.
ls -l /sys/bus/i2c/devices/i2c-* yields the following output: lrwxrwxrwx 1 root root 0 May 15 03:41 /sys/bus/i2c/devices/i2c-0 -> ../../../devices/ocp.3/44e0b000.i2c/i2c-0 lrwxrwxrwx 1 root root 0 May 15 03:41 /sys/bus/i2c/devices/i2c-1 -> ../../../devices/ocp.3/4819c000.i2c/i2c-1 lrwxrwxrwx 1 root root 0 Nov 11 22:09 /sys/bus/i2c/devices/i2c-2 -> ../../../devices/ocp.3/4802a000.i2c/i2c-2
What am I doing wrong?
Thanks in advance,
Mostafa
Is this issue still relevant on latest @abandonware's fork ?
https://libraries.io/npm/@abandonware%2Fi2c/usage
Relate-to: https://github.com/kelly/node-i2c/issues/97