Open jadonk opened 10 years ago
I get a null array when I have a device at 0x20 (I get a null array on /dev/i2c-1 & 2, 2 the same null output the i2cdetect has), I get [52,80] on dev/i2c-0, but i2cdetect reports devices at 24,34,50,70
root@beaglebone:/var/lib/cloud9/demo# cat i2c.js var i2c = require('i2c'); var wire = new i2c(null, {device: '/dev/i2c-0'}); wire.scan(function(err, data) { if(err) console.log('ERROR: ' + JSON.stringify(err)); console.log(JSON.stringify(data)); root@beaglebone:/var/lib/cloud9/demo# node i2c.js [52,80] root@beaglebone:/var/lib/cloud9/demo# i2cdetect -y -r 0 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: UU -- -- -- -- -- -- --
root@beaglebone:/var/lib/cloud9/demo# i2cdetect -y -r 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- UU UU UU UU -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@beaglebone:/var/lib/cloud9/demo# node i2c.js
[]
Internally node-i2c uses the SMBus quick command (i2c_smbus_write_quick) to scan for devices, so it's similar to:
i2cdetect -y -q 1
On the BeagleBone the following is typically used for device detection:
i2cdetect -y -r 1
Note that -r is being used rather -q, so i2cdetect uses SMBus receive byte rather than the SMBus quick command for device detection. The BeagleBone doesn't support the SMBus quick command so node-i2c scan doesn't find anything
root@beaglebone:~# i2cdetect -F 1
Functionalities implemented by /dev/i2c-1:
I2C yes
SMBus Quick Command no
SMBus Send Byte yes
SMBus Receive Byte yes
SMBus Write Byte yes
SMBus Read Byte yes
SMBus Write Word yes
SMBus Read Word yes
SMBus Process Call yes
SMBus Block Write yes
SMBus Block Read no
SMBus Block Process Call no
SMBus PEC yes
I2C Block Write yes
I2C Block Read yes
root@beaglebone:~# i2cdetect -y -q 1
Error: Can't use SMBus Quick Write command on this bus
root@beaglebone:~# i2cdetect -y -r 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- 39 -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- UU UU UU UU -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
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
It is unclear to me why i2cdetect and node-i2c would return different results, but this is what I'm seeing...
root@beaglebone:/var/lib/cloud9# i2cdetect -y -r 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- 1d -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- UU UU UU UU -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- 6b -- -- -- -- 70: -- -- -- -- -- -- -- --
So, it seems these don't line up. To see if the delta is due to the wrapper I have in BoneScript or the node-i2c library I pull in, I tried out this:
debian@beaglebone:/var/lib/cloud9$ cat i2c-scan-native.js var i2c = require('i2c'); var wire = new i2c(null, {device: '/dev/i2c-1'}); wire.scan(function(err, data) { if(err) console.log('ERROR: ' + JSON.stringify(err)); console.log(JSON.stringify(data)); }); debian@beaglebone:/var/lib/cloud9$ node i2c-scan-native.js [87]