Open rwaldron opened 7 years ago
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.
Is this something that would mostly happen on the SAMD21 (the C firmware) with event
messages back to the SoC (Node.js firmware)?
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.
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.
@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.
});
Originally filed here: https://github.com/tessel/t2-cli/issues/1257
@opkiler22789: