www.pudn.com > SerialGPS.zip > ReadProtocols.m


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