Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i2cdetect and node-i2c scans returning different results #27

Open
jadonk opened this issue Mar 30, 2014 · 3 comments
Open

i2cdetect and node-i2c scans returning different results #27

jadonk opened this issue Mar 30, 2014 · 3 comments

Comments

@jadonk
Copy link

jadonk commented Mar 30, 2014

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]

@snidera
Copy link

snidera commented Jul 22, 2014

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
[]

@fivdi
Copy link
Contributor

fivdi commented Dec 20, 2014

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: -- -- -- -- -- -- -- --                         

@rzr
Copy link

rzr commented Oct 20, 2020

Is this issue still relevant on latest @abandonware's fork ?

https://libraries.io/npm/@abandonware%2Fi2c/usage

Relate-to: #97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants