📄 writepacketterminator.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -