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.

IWR1443BOOST: Reading via Serial with Python

Part Number: IWR1443BOOST


Hi,

I'm currently trying to get the breath and heart rate outputs via USB without using the vital signs visualiser. I have parsed the configuration code via the command line interface and the EVM is flashed with the pre-built vital-signs detection binary file.

As mentioned in other threads, this is my python code:

import serial
import time
import numpy as np

# Change the configuration file name
configFileName = 'profile_2d_VitalSigns_20fps.cfg'

CLIport = {}
Dataport = {}
byteBuffer = np.zeros(2**15,dtype = 'uint8')
byteBufferLength = 0;
dataBin = [None] * 288

magicWord = [2, 1, 4, 3, 6, 5, 8, 7]
magicWord = [bytes(i) for i in magicWord]

# Byte sizes for different values
magicWord  = 8
fftOrPeak  = 4

# ------------------------------------------------------------------

# Function to configure the serial ports and send the data from
# the configuration file to the radar
def serialConfig(configFileName):
    
    global CLIport
    global Dataport
    # Open the serial ports for the configuration and the data ports
    
    # Raspberry pi
    #CLIport = serial.Serial('/dev/ttyACM0', 115200)
    #Dataport = serial.Serial('/dev/ttyACM1', 921600)
    
    # Windows
    CLIport = serial.Serial('COM4', 115200)
    Dataport = serial.Serial('COM5', 921600)

    # Read the configuration file and send it to the board
    config = [line.rstrip('\r\n') for line in open(configFileName)]
    for i in config:
        CLIport.write((i+'\n').encode())
        print(i)
        time.sleep(0.01)
        
    return CLIport, Dataport


def processData(dataBin):
    # Alter to 4-byte data in array form 1 byte/element
    breathFFT = dataBin[52:56]
    breathFFT = breathFFT[::-1]
    heartFFT  = dataBin[56:60]
    heartFFT = heartFFT[::-1]
    
    # Remove b value in hex
    breathFFT = [s.hex() for s in breathFFT]
    heartFFT  = [s.hex() for s in heartFFT]

    # Join arrays together to form 4 byte value
    breathFFT = float.fromhex("".join(breathFFT))
    heartFFT  = float.fromhex("".join(heartFFT))

    return breathFFT, heartFFT

def readAndParseData(dataBin, Dataport):
    readBuffer = Dataport.read(Dataport.in_waiting)
    dataBin = dataBin[Dataport.in_waiting:]
    dataBin.append(readBuffer)

    



# -------------------------    MAIN   -----------------------------------------  

# Configurate the serial port
CLIport, Dataport = serialConfig(configFileName)

print(CLIport)
print(Dataport)

print("reading")

while True:
    if Dataport.in_waiting > 0:
        try:
            readAndParseData(dataBin, Dataport)

            if dataBin[0:8] == magicWord:
                breathFFT, heartFFT = processData(dataBin)
            
                print(breathFFT,heartFFT)
        
        except KeyboardInterrupt:
            CLIport.write(('sensorStop\n').encode())
            CLIport.close()
            Dataport.close()



However, I am not getting any outputs from the evaluation module. When running the vitalSignsDemo_GUI.exe visualiser with the same cfg file, the GPIO_1 LED lights up and the data is transmitted to the visualiser without any problems, using the same COM ports.
The cfg parameters are as follows:
sensorStop
flushCfg
dfeDataOutputMode 1
channelCfg 15 1 0
adcCfg 2 1
adcbufCfg 0 1 0 1
profileCfg 0 77 7 6 57 0 0 70 1 200 4000 0 0 48
chirpCfg 0 0 0 0 0 0 0 1
frameCfg 0 0 2 0 50 1 0
guiMonitor 0 0 0 0 1
vitalSignsCfg 0.3 1.0 256 512 4 0.1 0.05 100000 100000
motionDetection 1 20 3.0 0
sensorStart

Any assistance is greatly appreciated!



  • Hi Xavier,

    I am sorry but we cannot review and provide support for your python code. However, I can provide you the following pointers which may help you troubleshoot the problem:

    1. After your python code sends the config, open the DATA com port in TeraTerm using the correct baud rate (921600) and see if you get any output on the Terminal window. If you see data coming out, then the error could be in the part that opens the Data port and/or parses the data. If you don't see any output, then it's possible that the configuration was not sent correctly to the device and hence it hasn't started.

    2. Add inter-character delay (e.g. 10ms) and inter-line delay (e.g. 100ms) in your code which sends/writes the config commands to the control UART. It's possible that you're sending the config too fast causing the UART buffer to overrun.

    You can refer to the Matlab source code for the Vital signs GUI which is provided in the Lab directory and structure your Python code accordingly.

    Thanks

    -Nitin