readprotocols.m

来自「基于串行接口的GPS驱动程序」· M 代码 · 共 25 行

M
25
字号
function protocols = ReadProtocols(gps)
% READPROTOCOLS Read the Protocol Capability Protocol data from the GPS
% Return a structure with two fields:
%   tag: Character tag identifying protocol family
%   id: Numeric protocol identifier (within family)

global pid_protocol_array pid_ack_byte;
protocols = [];
    
if (get(gps, 'BytesAvailable') > 0)
    
    [id, sz] = ReadPacketHeader(gps);
    
    if (id == pid_protocol_array)
        for i=1:sz
            protocols(i).tag = fread(gps, 1);
            protocols(i).id = fread(gps, 1, 'int16');
        end
    end
    
    cksum = ReadPacketTerminator(gps);
    csum = ComputeChecksum(id, [protocols.tag protocols.id]);
    
    WritePacket(gps, pid_ack_byte, 0);
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?