Hello,
What is the format of the data after the magic word has been detected on the SPI port?
Thanks.
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
What is the format of the data after the magic word has been detected on the SPI port?
Thanks.
My partners and I are trying to read the IWR1443BOOST using a Jetson Nano's Spidev library, which reads it one byte at a time. But we are not able to get through the magic word. When we used pySerial on a Windows 10 laptop, we were able to get the magic number fine, but it doesn't seem to work with the Nano.
What are we doing wrong? Any suggestions?
Thanks.
Hi,
Have you checked to ensure this is not a problem with byte order or endianness? Can you check if you are perhaps just getting the magic word slightly jumbled due to this?
Best Regards,
Alec
Hi,
Could you do a data capture of the serial stream on both devices and provide them here so we can do some comparisons? This may help us narrow down exactly what differences there are.
Best Regards,
Alec
Here's the .py file we ran on the Jetson Nano:
import spidev import time #vital signs output status class vsos: rangeBinIndexMax = 0 rangeBinIndexPhase = 0 maxVal = float(0.0) processingCyclesOut = 0 processingCyclesOut1 = 0 rangeBinStartIndex = 0 rangeBinEndIndex = 0 unwrapPhasePeak_mm = float(0.0) outputFilterBreathOut = float(0.0) outputFilterHeartOut = float(0.0) heartRateEst_FFT = float(0.0) heartRateEst_FFT_4Hz = float(0.0) heartRateEst_xCorr = float(0.0) heartRateEst_peakCount = float(0.0) breathingRateEst_FFT = float(0.0) breathingEst_xCorr = float(0.0) breathingEst_peakCount = float(0.0) confidenceMetricBreathOut = float(0.0) confidenceMetricBreathOut_xCorr = float(0.0) confidenceMetricHeartOut = float(0.0) confidenceMetricHeartOut_4Hz = float(0.0) confidenceMetricHeartOut_xCorr = float(0.0) sumEnergyBreathWfm = float(0.0) sumEnergyHeartWfm = float(0.0) motionDetectedFlag = float(0.0) rsv = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] class header: version = "" totalPackLen =0 tvlHeaderLen = 8 platform = "" frameNumber = 0 timeCpuCycles = 0 numDetectedObj = 0 numTLVs = 0 rsv = 0 class HeartAttack: def __init__(self): self.__spi = spidev.SpiDev() self.__spi.open(0,0) #Note: 0,0 @ pin 24 -> J6.6, mosi, miso, clk @ 19, 21, 23 self._config = [line.rstrip('\r\n') for line in open('1443config.cfg')] self._magicWord = [b'\x02',b'\x01',b'\x04',b'\x03',b'\x06',b'\x05',b'\x08',b'\x07',b'\0x99'] #b'\0x99 self._hdr = header self._vs = vsos() '''for s in self._config: data = (s+'\n').encode() print(data) self.__spi.xfer(data) ''' #mock_data = [0x01,0x02] #spi.xfer(mock_data) #send mock data time.sleep(1) def vitalSignsOutputStats(self,buf): try: (self._vs.rangeBinIndexMax, self._vs.rangeBinIndexPhase, self._vs.maxVal, self._vs.processingCyclesOut, self._vs.processingCyclesOut1, self._vs.rangeBinStartIndex, self._vs.rangeBinEndIndex, self._vs.unwrapPhasePeak_mm, self._vs.outputFilterBreathOut, self._vs.outputFilterHeartOut, self._vs.heartRateEst_FFT, self._vs.heartRateEst_FFT_4Hz, self._vs.heartRateEst_xCorr, self._vs.heartRateEst_peakCount, self._vs.breathingRateEst_FFT, self._vs.breathingEst_xCorr, self._vs.breathingEst_peakCount, self._vs.confidenceMetricBreathOut, self._vs.confidenceMetricBreathOut_xCorr, self._vs.confidenceMetricHeartOut, self._vs.confidenceMetricHeartOut_4Hz, self._vs.confidenceMetricHeartOut_xCorr, self._vs.sumEnergyBreathWfm, self._vs.sumEnergyHeartWfm, self._vs.motionDetectedFlag, self._vs.rsv[0],self._vs.rsv[1],self._vs.rsv[2], self._vs.rsv[3],self._vs.rsv[4],self._vs.rsv[5], self._vs.rsv[6],self._vs.rsv[7],self._vs.rsv[8], self._vs.rsv[9]) = struct.unpack('2Hf2H2H28f', buf) except: print("vsos error found:") return (False,self._vs) return (True,self._vs) def readData(self): state = 'idle' idx = 0 rangeProfile = "" sbuf = "" vsdata = vsos mmWaveType2 = 0 while(True): byte = int([hex(v) for v in self.__spi.readbytes(1)][0],16).to_bytes(1,'little') #print(received_data) if byte == None: byte = b'\x00' if state == 'idle': print(byte, " == ", self._magicWord[idx], " which is magic word #", idx, " ?") if byte == self._magicWord[idx]: idx += 1 if idx == 8: idx = 0 state = 'header' rangeProfile = b"" sbuf = b"" else: idx = 0 rangeProfile = b"" #return (False,vsdata,rangeProfile) elif state == 'header': #read header print("HEADER STATE REACHED!!! :D ") idx += 1 if idx == 40: state == 'vsos' #return (True,vsdata,rangeProfile) #case 'vsos': elif state == 'vsos': print("Vital Signs Output Stats (VSOS) reached!!!!"); sbuf += byte idx += 1 if idx == 128: vflag, vsdata = self.vitalSignsOutputStats(sbuf) if not vflag: state == 'idle' #return false idx == 0 lstate = 'mTLVh' sbuf = b"" elif idx > 128: idx = 0 state = 'idle' #return false elif state == 'mTLVh': sbuf += byte idx += 1 if idx == 8: idx = 0 try: mmWaveType2, length2 = struct.unpack('2I',sbuf) except: return (False, vsdata, rangeProfile) if length2 > 252: length2 = 252 state = 'rangeProfile' rangeProfile = b"" elif idx > 8: idx = 0 state = 'idle' elif state == 'rangeProfile': rangeProfile += byte idx += 1 if idx == length2: idx = 0 try: fmt = '{:d}h'.format(int(length2/2)) xd = struct.unpack(fmt,rangeProfile) except: return (False, vsdata, rangeProfile) return (True, vsdata, list(xd)) elif idx > length2: idx = 0 state = 'idle' else: print("INVALID STATE: ", state) time.sleep(0.1) if __name__ == '__main__': ha = HeartAttack() ha.readData()
We used these pin configs to connect the EVM to the Nano, shown below
The sample bytes that resulted, compared to the first byte of the magic word are shown below:
For the PC (Windows 10), we ran vitalsign.py file, and resulted with this:
Hi,
You may find more helpful advice on forums targeted at the Jetson, since the issue seems to be related to inconsistent SPI behavior when compared to a windows environment. I will be happy to answer any remaining mmWave queries related to this, but I don't think I can provide much more specific advice since I do not have a Jetson Nano onhand to test with.
Best Regards,
Alec