1

I have working C & Python3 code, based upon simple examples from the internet, where I can correctly send data from my Raspberry Pi4 to an Atmel SAM-E70 dev kit board. I've got a logic analyzer connected to look at the data being sent, and for every i2c_write_data_block() from my Python3 code, the smbus2 code sends the 7-bit address, followed by 0x00, followed by the byte stream that I want to send. My C code, sending the same byte streams, doesn't have the 0x00 between the address and the data. Finally, sending the byte stream using i2ctransfer() from the shell also works as expected: no extra byte.

Hypothetically, it could be that the smbus2 package is trying to use a 10-bit address, but I cannot find any documentation supporting this supposition. In fact, what I've found indicates that the I2C bus configuration is performed via config file(s) which would lead me to the believe that the language used to communicate on the I2C bus shouldn't matter - it would have the same configuration.

Has anyone else encountered this?

PfunnyGuy
  • 750
  • 9
  • 22
  • It's the difference between I²C and SMBus protocols AFAIR. But in case of 10-bit address you should have some bit somewhere set or reset to trigger that. I would suggest to read documentation. – 0andriy Feb 12 '21 at 14:33
  • The devices, as far as I can tell, are both set to 7 bit addressing. But it could be I2C & SMBUS differences. I'll give it a go with an different, I2C, package. – PfunnyGuy Feb 12 '21 at 18:42

1 Answers1

3

I noticed the same thing using the smbus2 i2c_write_data_block() function. To avoid sending the 0x00 start byte, use the i2c_rdwr() function.

Example:

bus = SMBus(1)
address = 4
data = 'Some message'.encode()
msg = i2c_msg.write(address, data)
bus.i2c_rdwr(msg)
Zero
  • 355
  • 1
  • 4
  • 12
  • 1
    I'm no longer working for the company where I had this issue, so I don't have the hardware setup to verify your answer - But I'm going to check your answer as the best. – PfunnyGuy Dec 06 '21 at 21:50