⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 writepacketterminator.m

📁 基于串行接口的GPS驱动程序
💻 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 + -