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.
https://e2e.ti.com/support/sensors-group/sensors/f/sensors-forum/978925/iwr6843aopevm-iwr6843aopevm
器件型号:IWR6843AOPEVM大家好、
我正在尝试使用 Python 解析 IWR6843AOPEVM 串行端口读取的数据。 我想获取距离剖面。
您好,Ukeme,
尽管此 python 脚本读取数据文件、但不会从 AOP EVM 读取数据串行端口、但您可以轻松地对其进行修改。 此脚本会解析数据、您可以获取由 parseRangeProfile 函数定义的范围配置文件。
导入结构 导入 sys 导入数学 # TODO 1:(现已修复)查找第一次出现的魔术并从此处开始 # TODO 2:如果我们无法解析特定段并尝试恢复 # TODO 3、则发出警告: 如果我们只有 TLV # def tlvHeaderDecode (data)片段、请删除文件末尾的错误: tlvType、tlvLength = struct.unpack('2I'、data ) 返回 tlvType、tlvLength def parseDetectedObjects (data、tlvLength): numDetectedObj、xyzQFormat = struct.unpack('2H'、data[:4]) 打印("\tDetect 对象:\t%d "%(numDetectedObj)) 对于 I IN 范围(numDetectedObj): 打印("\tObjId:\t%d "%(i)) rangeIdx、dopplerIdx、peakVal、x、y、 z = struct.unpack('3H3h',data[4+12*i:4+12*i+12]) 打印("\t\tDopplerIdx:\t%d "%(dopplerIdx)) 打印("\t\tRangeIdx:\t%d "%(rangeIdx)) 打印("\t\tPeakVal:\t%d "%(peakVal)) 打印("\t\t\TX:\t\t%07.3f "%(x*1.0/(1 << xyzQFormat))) 打印("\t\t\Ty:\t\t%07.3f "%(y*1.0/(1 <<xyzQFormat))) 打印("\t\t\TZ:\t\t%07.3f "%(z*1.0/(1 <<xyzQFormat))) 打印("\t\t\t\thring:\t%07.3fm"%(math.sqrt (pow ((x*1.0/(1 << xyzQFormat)))、2)+ pow ((y*1.0/(1 << xyzQFormat))、2)))) ) parseRangeProfile (data、tlvLength): 对于 I IN 范围(256): rangeProfile = struct.unpack('H'、data[2*i:2*i+2]) 打印("\tRangeProx[%d]:\t%07.3f "%(i、rangeProfile[0]* 1.0 * 6/8 /(1 <<8))) 打印("\tTLVType:\t%d "%(2)) def parseStats (数据、tlvLength): 进程间、传输输出、帧裕量、线性调频脉冲裕量、模拟 CPULoad、 interCPULoad = struct.unpack('6i'、data[:24]) 打印("\tOutputMsgStats:\t%d "%(6)) 打印("\t\tChirpMargin:\t%d "%"(线性调频脉冲裕量)) 打印("\t\tFrameMargin:\t%d "%(frameMargin)) 打印("\t\tInterCPULoad:\t%d "%(interCPULoad)) 打印("\t\tActiveCPULoad:\t%d "%(activeCPULoad)) 打印("\t\tTransmitOut:\t%d "%(transmitOut)) 打印("\t\tInterprocess:\t%d "%(interprocess)) def tlvHeader (data): while 数据: HeaderLength = 36 尝试: Magic、version、length、platform、frameNum、 cpuCycles、numObj、numTLV = struct.unpackt ('Q7I'、data[:headerLength ]) 除了: 打印"发现不正确的 TLV 结构:"、(数据、) 中断 打印("数据包 ID:\t%d "%(frameNum)") 打印("版本:\t%x "%(版本)) 打印("TLV:\t\t%d "%(numTLV)) 打印("检测对象:\t%d "%(numObj)) 如果 版本> 0x01000005、则打印("平台:\t%X "%(平台)"): subFrameNum = struct.unpack('I'、data[36:40])[0] HeaderLength = 40 打印("子帧:\t%d "%(subFrameNum)") pendingBytes =长度-头长度 数据=数据[头长度:] 对于 I IN 范围(numTLV): tlvType、tlvLength = tlvHeaderDecode (data[:8]) 数据=数据[8:] 如果(tlvType==1): parseDetectedObjects (数据、tlvLength) Elif (tlvType == 2): parseRangeProfile (数据、tlvLength) Elif (tlvType == 6): parseStats (数据、tlvLength) 否则: 打印("未识别的 tlv 类型%d"%(tlvType)) 数据=数据[tlvLength:] 挂起字节-=(8+tlvLength) 数据=数据[挂起字节:] 产量长度、frameNum if __name__="__main__": 如果 len(sys.argv)!= 2: Print ("用法:parseTLV.py InputFile.bin") sys.exit() 文件名= sys.argv[1] rawDataFile = open (文件名、"rb") RawData = rawDataFile.read() rawDataFile.close() 魔术= b'\x02\x01\x04\x03\x06\x05\x08\x07' 偏移= RawData.Find (魔术) RawData = RawData[偏移量:] 对于长度,tlvHeader (RawData)中的 frameNum: 打印