www.pudn.com > SerialGPS.zip > ReadPacketTerminator.m
function cksum = ReadPacketTerminator(gps)
% ReadPacketTerminator Read the three byte sequence terminating a packet
global pid_dle_byte;
global pid_etx_byte;
% Read checksum byte. If it is equal to DLE, read (and discard) the
% following DLE.
cksum = fread(gps, 1);
if (pid_dle_byte == cksum)
d = fread(gps, 1);
if (pid_dle_byte ~= d)
error(['CKSUM == DLE, but DLE not repeated.']);
end
end
% Read the DLE and ETX that terminate this packet
byte = fread(gps, 1);
if (pid_dle_byte ~= byte)
ExpectedDataError(byte, pid_dle_byte);
end
byte = fread(gps, 1);
if (byte ~= pid_etx_byte)
ExpectedDataError(byte, pid_etx_byte);
end