readpacketterminator.m
来自「基于串行接口的GPS驱动程序」· M 代码 · 共 28 行
M
28 行
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
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?