0

Is it possible to read 3 parameters over Smbus?

First, I say which 8 bit are to read or write:

bus.write_byte_data(0x08, 0x4E, 0x30)

I write follow command (3 parameters):

bus.write_byte_data(0x08, 0x4D, 0x10)

but I can only read all 8 bits out:

bus.read_byte_data(0x08, 0x4C)

This reads all 8 bits, but I need something like:

bus.read_byte_data(address, cmd, data)

This way it makes it hard to program because I get other numbers back if I write something else and then read it again.

David Buck
  • 3,752
  • 35
  • 31
  • 35
Alitai
  • 3
  • 2
  • Can you expand on this a bit more? I'm not sure I understand what you mean. Some code would be good (see: [mcve]). – AMC Nov 24 '19 at 20:31
  • i think i got it. i need read_block_data and then i can read out the array but it crashes. How do i define a array in python? – Alitai Nov 24 '19 at 21:12
  • I got it. To call an array "data" is not a good idea and gave me the error. i changed it to array and now it works. Thanks so much for your post. :) – Alitai Nov 24 '19 at 21:24
  • Uh you're welcome, even though you solved the entire thing yourself ;p – AMC Nov 24 '19 at 21:34
  • @AlexanderCécile Thanks :) Now i got 1 last Problem. This "read_block_data" gives me a decimal number back (51). What i need is an 8bit array (1,2,3,4,5,6,7,8). How can i convert this? At best with one Line. – Alitai Nov 25 '19 at 16:46
  • list((bin(51)[2:].zfill(8)) – Alitai Nov 25 '19 at 19:57
  • edit: list(bin(51)[2:].zfill(8)) – Alitai Nov 25 '19 at 20:04
  • inn = [51] list(bin(inn[0])[2:].zfill(8)) – Alitai Nov 25 '19 at 20:27
  • Add that code to your post, so that it’s easier for people to find :) – AMC Nov 25 '19 at 22:46

0 Answers0