The xfer2() method requires the SPI device to be opened first with open().
Step 2: Identify the error
Here, xfer2() is called before open(), causing a runtime error.
Final Answer:
Calling xfer2() before opening SPI device -> Option B
Quick Check:
Open SPI before xfer2() call [OK]
Hint: Always open SPI before using xfer2() [OK]
Common Mistakes:
Calling xfer2() before open()
Forgetting to close SPI device
Confusing method names
5. You want to send the bytes [0x10, 0x20, 0x30] to an SPI device on bus 1, device 0, at 500000 Hz speed, and receive the response. Which code snippet correctly does this using spidev?