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

Get i2c address #235

Open
rwaldron opened this issue Jun 26, 2017 · 6 comments
Open

Get i2c address #235

rwaldron opened this issue Jun 26, 2017 · 6 comments

Comments

@rwaldron
Copy link
Contributor

Originally filed here: tessel/t2-cli#1257

@opkiler22789:

Hello, Is there any way to get i2c address? In the likeness of i2c_scanner?

@rwaldron
Copy link
Contributor Author

There is no way to scan i2c addresses in the manner that i2c_scanner does, but I'm wondering if provide a similar (possibly simpler) alternative? I'm going to put together a rough sketch this week.

@HipsterBrown
Copy link
Contributor

Is this something that would mostly happen on the SAMD21 (the C firmware) with event messages back to the SoC (Node.js firmware)?

@rwaldron
Copy link
Contributor Author

Yes, that's correct. The JS API would just be a wrapper around some command that is sent to SAMD21, the command would do whatever test is necessary on the SAMD21 and respond with the outcome.

@fivdi
Copy link

fivdi commented Jun 26, 2017

Would it not be possible to loop over all I2C addresses calling i2cConfig and then i2cReadOnce for each address. After calling i2cReadOnce, wait for either an error to be emitted indicating that there is no device at the address or an event to be emitted indicating that a there is a device at the address.

This is probably a bit of hack and it may leave state.i2c full of junk that's not needed. Reading information from a device may also have unwanted side effects on the device. On the other hand it might work!

It's probably of little help, but i2c-bus has scan and scanSync methods that use the SMBus Receive Byte protocol to scan for devices. The Linux i2cdetect -y -r <bus-number> command also uses the SMBus Receive Byte protocol to scan for devices.

@rwaldron
Copy link
Contributor Author

rwaldron commented Jun 27, 2017

@fivdi the JS runs on the mediatek mt7620n and communicates with the samd21 via domain socket. The entire i2c stack exists on samd21 and there is presently no response produced when a program attempts to write (via a message sent over the socket) to a non-existent i2c peripheral address.

const tessel = require('tessel');

const txb = new Buffer([0xff]);
const i2c = new tessel.port.A.I2C(0x01);

i2c.transfer(txb, 1, (error, data) => {
  // Never executed, because no response ever occurs. 
});

@rwaldron
Copy link
Contributor Author

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

3 participants