getting " stack smashing detected" when using pyA20lime2 SPI read() function

Started by frm, October 14, 2017, 08:55:42 PM

Previous topic - Next topic

frm

Hi,
I have enabled SPI #2 of my Olimex. I can successfully transmit data toward my slave device (I can see it receives data using a debugger attached to the slave).
This is the testing python script I'm using:


#!/usr/bin/env python

from pyA20Lime2 import spi
import time
spi.open("/dev/spidev2.0", mode=0, delay=0, bits_per_word=8, speed=10000)
while True:
                print "WRITING BYTES 1, 2, 3"
                spi.write([0x01, 0x02, 0x03]) #Write 3 bytes to slave device
                print "READING 16 BYTES"
                tmp = spi.read(16)     # if this is enabled, PYthon crashes
                print tmp
                time.sleep(0.1)

However when I enable to use the read() function I get:

root@lime2:~# ./lime2_spi.py
WRITING BYTES 1, 2, 3
READING 16 BYTES
*** stack smashing detected ***: python terminated
Aborted


What I'm doing wrong?