该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
% close all;clear all; clc
fid = fopen('SMARTLINK 1H', 'rt');
rows = 10;2^19;
Num1057_Counter=0;
Num1058_Counter=0;
Mes_LenBin=zeros(1,10);%分配空间
Data_Feild=zeros(1,12);%分配空间
CRC_base=[1 1 0 0 0 0 1 1 0 0 1 0 0 1 1 0 0 1 1 1 1 1 0 1 1];%生成多项式
% 获取数据长度
% while(1)
% Line = fgetl(fid);
% answer = strfind(Line,'+---------+---------------+----------+');
%
% if ~isempty(answer)
% rows= rows +1;
% end
%
% if ~ischar(Line); %文件已经读完
% rows
% break;
% end
% end
% rows =231441;
rows =4; %行数
num = 16 * rows; %总数据,每行16个数据
hang = 0; %读数起始行相比实际的少一行
%-------进度条------%
hwb = waitbar(0,'Please wait...','Name','RTCM data reading...');
Line = fread(fid,1232,'ubit1');
rtcmDate = zeros(1,length(Line));
rtcmBin = zeros(1,length(Line));
%-----------读取数据-----------%
frewind(fid); %回到文件起始位置
k =0;
for i = 0: (length(Line)-1)
waitbar(i/(length(Line)),hwb,['Completed ',int2str(i),' of ', int2str(length(Line)),'.']);
rtcmDate(i+1) =Line(k+1);
k = k+1;
end
for i = 1:(length(Line))/8
for j=0:7
rtcmBin((i-1)*8+j+1)=rtcmDate(i*8-j);%提取每个二进制位上的数据
end
end
close(hwb);
fclose(fid);
i=1;
while i
if rtcmBin(i:i+7)==[1 1 0 1 0 0 1 1]
Mes_LenBin=rtcmBin(i+14:i+23);%提取的二进制的信息长度
L=bin2dec(num2str(Mes_LenBin));%提取的信息长度
Mes_Data=zeros(1,8*L);%为提取数据分配空间
for j=1:8*L
Mes_Data(1,j)=rtcmBin(i+24+j-1);%提取的二进制数据包
end
[q,r]=deconv(Mes_Data,CRC_base);%CRC校验
r=mod(r(end-23:end),2);
if r==0
Data_Feild=rtcmBin(i+24:i+35);%提取十二位数据类型
Mes_Dec=bin2dec(num2str(Data_Feild));%数据类型(1001,1002,...)
switch Mes_Dec
case 1004
Num1057_Counter=Num1057_Counter+1;
case 1005
Num1058_Counter=Num1058_Counter+1;
otherwise
disp('其他数据格式:');
disp(Mes_Dec);
end
else
i=(L+6)*8;
end
else
i=i+8;
end
end
disp('Messager number is1004');
disp('Num1057_Counter=');
disp(Num1057_Counter);
disp('Messager number is1005');
disp('Num1058_Counter=');
disp(Num1058_Counter);