I want to read bytes from the spi bus. Writing a byte is simple by just using
file = open("/dev/spidev1.0", 'wb')
file.write('#')
I tried using the read(1) command, but this makes the spi clock way longer than just for one byte.
Example:
file = open("/dev/spidev1.0", 'rb')
file.read(1)
Does anyone have a clue why it just doenst clock 8 times when I try to read one byte?
(I am using a Carambola2 by the way and the spi over gpio)
I solved the Problem on my own. You have to use the os library
Example:
import os
file = os.open('filename', os.O_RDWR)
#Write byte 0x1 to SPI Bus
os.write(file, chr(0x1))
#Read one byte from SPI Bus
print(str(ord(os.read(file, 1))))