Other Parts Discussed in Thread: IWR1443, IWR6843
Hey all,
I wish to read the UART data from IWR1443 demo project. The code I'm referencing is the zone occupancy lab from industrial toolbox 3.3.1.
In the file named 'mmv_demo_zone_occupancy', the following code seems to be the reading-UART part:
%Read bytes readUartCallbackFcn(hDataSerialPort, 0); if BYTES_AVAILABLE_FLAG == 1 BYTES_AVAILABLE_FLAG = 0; %fprintf('bytevec_cp_len, bytevecAccLen = %d %d \n',bytevec_cp_len, bytevecAccLen) if (bytevec_cp_len + bytevecAccLen) < bytevec_cp_max_len bytevec_cp(bytevec_cp_len+1:bytevec_cp_len + bytevecAccLen) = bytevecAcc(1:bytevecAccLen); bytevec_cp_len = bytevec_cp_len + bytevecAccLen; bytevecAccLen = 0; else fprintf('Error: Buffer overflow, bytevec_cp_len, bytevecAccLen = %d %d \n',bytevec_cp_len, bytevecAccLen) end end bytevecStr = char(bytevec_cp); magicOk = 0; startIdx = strfind(bytevecStr', char([2 1 4 3 6 5 8 7])); if ~isempty(startIdx) if startIdx(1) > 1 bytevec_cp(1: bytevec_cp_len-(startIdx(1)-1)) = bytevec_cp(startIdx(1):bytevec_cp_len); bytevec_cp_len = bytevec_cp_len - (startIdx(1)-1); end if bytevec_cp_len < 0 fprintf('Error: %d %d \n',bytevec_cp_len, bytevecAccLen) bytevec_cp_len = 0; end totalPacketLen = sum(bytevec_cp(8+4+[1:4]) .* [1 256 65536 16777216]'); if bytevec_cp_len >= totalPacketLen magicOk = 1; else magicOk = 0; end end byteVecIdx = 0; if(magicOk == 1) %fprintf('OK, bytevec_cp_len = %d\n',bytevec_cp_len); if debugFlag fprintf('Frame Interval = %.3f sec, ', toc(tStart)); end tStart = tic; [Header, byteVecIdx] = getHeader(bytevec_cp, byteVecIdx); detObj.numObj = 0; for tlvIdx = 1:Header.numTLVs [tlv, byteVecIdx] = getTlv(bytevec_cp, byteVecIdx); switch tlv.type case MMWDEMO_UART_MSG_DETECTED_POINTS if tlv.length >= OBJ_STRUCT_SIZE_BYTES [detObj, byteVecIdx] = getDetObj(bytevec_cp, ... byteVecIdx, ... tlv.length, ... Params.dataPath.rangeIdxToMeters, ... Params.dataPath.dopplerResolutionMps, ... Params.dataPath.numDopplerBins); end case MMWDEMO_UART_MSG_RANGE_PROFILE [rp, byteVecIdx] = getRangeProfile(bytevec_cp, ... byteVecIdx, ... tlv.length); case MMWDEMO_UART_MSG_NOISE_PROFILE [np, byteVecIdx] = getRangeProfile(bytevec_cp, ... byteVecIdx, ... tlv.length); case MMWDEMO_UART_MSG_AZIMUT_STATIC_HEAT_MAP [Q, byteVecIdx] = getAzimuthStaticHeatMap(bytevec_cp, ... byteVecIdx, ... Params.dataPath.numTxAzimAnt, ... Params.dataPath.numRxAnt,... Params.dataPath.numRangeBins,... NUM_ANGLE_BINS); case MMWDEMO_UART_MSG_RANGE_DOPPLER_HEAT_MAP [rangeDoppler, byteVecIdx] = getRangeDopplerHeatMap(bytevec_cp, ... byteVecIdx, ... Params.dataPath.numDopplerBins, ... Params.dataPath.numRangeBins); case MMWDEMO_UART_MSG_STATS [StatsInfo, byteVecIdx] = getStatsInfo(bytevec_cp, ... byteVecIdx); %fprintf('StatsInfo: %d, %d, %d %d \n', StatsInfo.interFrameProcessingTime, StatsInfo.transmitOutputTime, StatsInfo.interFrameProcessingMargin, StatsInfo.interChirpProcessingMargin); displayUpdateCntr = displayUpdateCntr + 1; interFrameCPULoad = [interFrameCPULoad(2:end); StatsInfo.interFrameCPULoad]; activeFrameCPULoad = [activeFrameCPULoad(2:end); StatsInfo.activeFrameCPULoad]; guiCPULoad = [guiCPULoad(2:end); 100*guiProcTime/Params.frameCfg.framePeriodicity]; if displayUpdateCntr == 40 UpdateDisplayTable(Params); displayUpdateCntr = 0; end otherwise end end byteVecIdx = Header.totalPacketLen; if ((Header.frameNumber - packetNumberPrev) ~= 1) && (packetNumberPrev ~= 0) fprintf('Error: Packets lost: %d, current frame num = %d \n', (Header.frameNumber - packetNumberPrev - 1), Header.frameNumber) end packetNumberPrev = Header.frameNumber;
If that is correct, my question is:
The zone occupancy lab right now is only compatible with IWR1443EV2, and my product is EV3. But the transmitProcessingOutput function in the zone_occup lab does not look different from that of the newest visualizer demo (toolbox 3.3). So does it mean I can use the same MATLAB code (from zone_occup GUI) to read UART data from the IWR1443 programmed with that new visualizer demo?
I am aware that there had been several threads discussing the reading of UART data. But they are a bit outdated and does not say about compatibility issues.
Many thanks in advance!
Ziheng