Bird
0
0

You want to read multiple bytes starting from register 0x00 of a device at address 0x60 using smbus2. Which approach correctly reads 4 bytes into a list?

hard🚀 Application Q8 of 15
Raspberry Pi - I2C Communication
You want to read multiple bytes starting from register 0x00 of a device at address 0x60 using smbus2. Which approach correctly reads 4 bytes into a list?
Adata = bus.read_bytes(0x60, 0x00, 4)
Bdata = bus.read_byte_data(0x60, 0x00, 4)
Cdata = [bus.read_byte_data(0x60, reg) for reg in range(0x00, 0x04)]
Ddata = bus.read_i2c_block_data(0x60, 0x00, 4)
Step-by-Step Solution
Solution:
  1. Step 1: Understand methods for reading multiple bytes

    read_i2c_block_data(address, register, length) reads a block of bytes starting at register.
  2. Step 2: Identify correct method usage

    data = bus.read_i2c_block_data(0x60, 0x00, 4) uses read_i2c_block_data with correct parameters to read 4 bytes.
  3. Final Answer:

    data = bus.read_i2c_block_data(0x60, 0x00, 4) -> Option D
  4. Quick Check:

    Use read_i2c_block_data for multiple bytes [OK]
Quick Trick: Use read_i2c_block_data to read multiple bytes at once [OK]
Common Mistakes:
MISTAKES
  • Trying to pass length to read_byte_data
  • Using non-existent read_bytes method
  • Reading bytes one by one inefficiently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes