writepacketterminator.m
来自「基于串行接口的GPS驱动程序」· M 代码 · 共 25 行
M
25 行
function WritePacketTerminator(gps, id, data, type)
% WRITEPACKETTERMINATOR Send the two byte packet terminator: (DLE, ETX)
global pid_dle_byte pid_etx_byte pid_ack_byte pid_nak_byte
% Checksum: 2s complement of sum of data
cksum = ComputeChecksum(id, data, type);
fwrite(gps, cksum);
if (pid_dle_byte == cksum)
fwrite(gps, pid_dle_byte);
end
% Send the terminating characters
fwrite(gps, pid_dle_byte);
fwrite(gps, pid_etx_byte);
% Wait for the acknowledgement packet. Don't wait if this was
% an ACK or NAK packet
if ((pid_ack_byte ~= id) && (pid_nak_byte ~= id))
[pid, data] = ReadPacket(gps);
if (pid_ack_byte ~= pid)
error(['Write packet (id: ', num2str(id), ') failed.']);
end
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?