I am trying to use file-based SPI communication from my Raspberry Pi to an Arduino (328p based). The weird thing is that when I write it out one byte at a time and flush the buffer between each write it works, but I cannot just send it a large buffer all at once. What's really weird about it is that when I do, some of the data goes through until there is a 0 in the byte array being sent and then it just ignores everything after that. So I don't think it's a speed issue. See python code below with both what works and what doesn't. Arduino side has SPI handling code that I know to work perfectly between it and another Arduino, so I'll exclude that for brevity.
dev = '/dev/spidev0.0'
spi = open(dev, "wb")
buffer = bytearray()
#fill the buffer here
#this works
for i in range(len(buffer)):
spi.write(struct.pack("B", buffer[i]))
spi.flush()
#this does NOT work
spi.write(buffer)
spi.flush()
Any thoughts as to why, when writing multiple bytes at once, it just gives up once it sees a 0?