AnsweredAssumed Answered

SPI Read Data Problem

Question asked by syed bukhari on Oct 10, 2019
Latest reply on Oct 16, 2019 by syed bukhari

Hi hope you all are doing good.  i'm already done with spidev_test and thats working well, i can send and receive the data. but the problem is when i read the data from arduino uno r3 or Lora (SPI interface module). all receive data is currupted or damaged. i don't know whats going on is it hardware problem or a coding problem. 

 

please share your experience. 


here is the Pyhton code:

===========================================

import spidev
import time
spi = spidev.SpiDev()
spi.open(0, 0)
spi.max_speed_hz = 500000
spi.mode = 0b11
try:
while True:

resp = spi.readbytes(3) #spi.xfer([0xAA])#readbytes(3)
if (resp[0] != 255):
#print(''.join(["0x%02X " % x for x in resp]).strip())
value = resp[1] + resp[2]
print(value)
byte1 = bin(resp[0])[2:].rjust(8,'0')
byte2 = bin(resp[1])[2:].rjust(8,'0')
byte3 = bin(resp[2])[2:].rjust(8,'0')
bits = byte1 + byte2 + byte3
print(bits)
time.sleep(0.05)
except KeyboardInterrupt:
spi.close()

========================================================

OUTPUT :
510
111111011111111111111111
=========================================================================

and if i use linux spidev_test to read data from arduino i get 

 

FF FF FF 7F FF FF FD FF
FF FF 7F FF FF FE FF FF
FF DF FF FF FF FF FF FF
CF FF FF FF FF FF FF FB
FF FF FF FF FF FF

THANKS 

Outcomes