diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.m b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.m index 416f9aca9..ccd35fac4 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.m +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.m @@ -50,6 +50,7 @@ $(ALLOCATIONCODE) fid = fopen(logfile); correctMsgByte=hex2dec('20'); correctSyncByte=hex2dec('3C'); +unknownObjIDList=zeros(1,2); % Parse log file, entry by entry prebuf = fread(fid, 12, 'uint8'); @@ -99,7 +100,12 @@ while (1) switch objID $(SWITCHCODE) otherwise - disp(['Unknown object ID: 0x' dec2hex(objID)]); + unknownObjIDListIdx=find(unknownObjIDList(:,1)==objID, 1, 'first'); + if isempty(unknownObjIDListIdx) + unknownObjIDList=[unknownObjIDList; objID 1]; + else + unknownObjIDList(unknownObjIDListIdx,2)=unknownObjIDList(unknownObjIDListIdx,2)+1; + end msgBytesLeft = datasize - 1 - 1 - 2 - 4; if msgBytesLeft > 255 msgBytesLeft = 0; @@ -114,6 +120,10 @@ $(SWITCHCODE) prebuf = fread(fid, 12, 'uint8'); end +for i=2:size(unknownObjIDList,1) %Don't show the first one, as it was simply a dummy placeholder + disp(['Unknown object ID: 0x' dec2hex(unknownObjIDList(i,1),8) ' appeared ' int2str(unknownObjIDList(i,2)) ' times.']); +end + %% Clean Up and Save mat file fclose(fid); diff --git a/ground/uavobjgenerator/generators/matlab/uavobjectgeneratormatlab.cpp b/ground/uavobjgenerator/generators/matlab/uavobjectgeneratormatlab.cpp index 217aca12a..01564e712 100644 --- a/ground/uavobjgenerator/generators/matlab/uavobjectgeneratormatlab.cpp +++ b/ground/uavobjgenerator/generators/matlab/uavobjectgeneratormatlab.cpp @@ -137,14 +137,14 @@ bool UAVObjectGeneratorMatlab::process_object(ObjectInfo* info) matlabSwitchCode.append("\t\t\t\tFieldNames= fieldnames(" + objectTableName +");\n"); matlabSwitchCode.append("\t\t\t\tfor i=1:length(FieldNames) %Grow structure\n"); matlabSwitchCode.append("\t\t\t\t\t" + objectTableName + ".(FieldNames{i})(:," + tableIdxName + "*2+1) = 0;\n"); - matlabSwitchCode.append("\t\t\t\tend;\n"); + matlabSwitchCode.append("\t\t\t\tend\n"); matlabSwitchCode.append("\t\t\tend\n"); //============================================================// // Generate 'Cleanup:' code (will replace the $(CLEANUP) tag) // //============================================================// - matlabCleanupCode.append(objectTableName + "=PruneStructOfArrays(" + objectTableName + "," + tableIdxName +"); %#ok\n" ); + matlabCleanupCode.append(objectTableName + "=PruneStructOfArrays(" + objectTableName + "," + tableIdxName +");\n" ); //========================================================================//