wish help you to fix your issue You want to use an interrupt on the GPIO line which handles your slave's chip-select. Ensure there is enough time for the slave to process this interrupt and load the outgoing data register before the clock starts. Some SPI modules preclude the use of GPIO - you will need to check if your SPI module has a function to handle chip select, or only enable the module based on the GPIO activity.
I hope this helps you . I am trying to interface with my Arduino via Pyserial on OS X. I am controlling LEDs with sending numbers from 0 to 9. The code as in , You were not formatting the string %d but the function call:
arduino.write('%d' % 5)
arduino.write('%d' % (5,))
arduino.write('%d.%d' % (2, 3))
Pyserial string to byte encoding to write to microcontroller