Home Lepton and Windows › Forums › Lepton maker community › General discussion › Raw SPI read with Lepton 3.5 and Raspberry Pi 3
Tagged: Breakout Board v2.0, Lepton 3.5, Raspberry Pi, SPI
This topic contains 0 replies, has 1 voice, and was last updated by Eduardo 1 month, 2 weeks ago.
Viewing 1 post (of 1 total)
-
Author
Posts
-
Participant
Hello,
I am working with a Lepton 3.5 module and a Breakout Board v2.0 with a Raspberry Pi 3B. The goal is to get RAW14 video output with telemetry enabled. Right now, I am trying to make the SPI communication using Python 3.7 with spidev library, but I am facing some issues. I am using the Flir Lepton Engineering Datasheet 203 to guide me.
Attached is my code, initially the SPI port is opened and I am reading 164 bytes at a time, since the video format is RAW14 with telemetry disabled, but the raw values I’m getting from SPI does not seem right, below are some output messages. By checking the packet number and ttt values from the header ID I got around 35% of valid frames for a SPI speed of 2.2MHz, but when I check the segmentation value at packet number 20, I hardly get a valid segmentation value. When I switch to SPI speed of 20MHz I receive around 9% of valid frames.
Some “valid” packets received have the header with only zeros. May you help me with some future steps or some information of what is needed to receive correct data from the SPI port? Is my approach of getting 164 bytes at a time correct? How to make sure the packets do not get out of sync?
I have tried the SDKs, but they do not work properly. I tried pylepton, but I cannot get any image from it, tried LeptonModule from groupgets and I can get a video stream in RGB888, but I need RAW14 data. I would like to work with python, but if you have a solution in other language I would appreciate.My code:
import spidev import time spi = spidev.SpiDev() spi.open(0, 0) spi.max_speed_hz = 2200000 spi.mode = 0b01 # mode = 3 segmentation=[] discard = 0 valid = 0 counter = 0 counter2 = 0 for i in range(1000): #while True: data = spi.readbytes(164) print("Packet:", data) header = data[:4] h1 = format(header[0], '08b') h2 = format(header[1], '08b') h3 = format(header[2], '08b') h4 = format(header[3], '08b') header_bits = h1 + h2 + h3 + h4 id_field = h1 + h2 crc = h3 + h4 first = id_field[0] ttt = id_field[1:4] packet_number = id_field[4:16] print("first: {}, TTT: {}, packet number: {}, CRC: {}". format(first, ttt, packet_number, crc)) if packet_number == '000000010100': segmentation.append(ttt) if first != '0': print("Priemrio Bit diferente de 0. Repeticoes: {}", counter) counter2 = counter2 + 1 elif packet_number[0:4] == '1111': print("------------- Discard Package ------------------\n") discard = discard + 1 else: print("------------- Valid Package --------------------\n") valid = valid + 1 counter = counter + 1 #break print("Valid: {}, Errors: {}".format(valid, discard)) print("Valid percentage: {:.2f}%".format(valid/(discard+valid+counter2) * 100)) print(counter2) print("Segmentation: ", segmentation)
Output(thorically “valid”): 164 bytes red from SPI port
Packet: [0, 0, 0, 0, 0, 0, 0, 0, 245, 155, 251, 193, 52, 17, 160, 225, 128, 64, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] first: 0, TTT: 000, packet number: 000000000000, CRC: 0000000000000000 ------------- Valid Package --------------------
Output(not valid): 164 bytes read from SPI port
Packet: [63, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 214, 113, 113, 130, 128, 121, 29, 36, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] first: 0, TTT: 011, packet number: 111111111111, CRC: 1111111111111111 ------------- Discard Package ------------------
resume of valid/not valid from 1000 packets:
Valid: 321, Errors: 646 Valid percentage: 32.10%
Sorry for long post.
-
Author
Posts
Viewing 1 post (of 1 total)
You must be logged in to reply to this topic.