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

📄 writepacket.m

📁 GPS simulation code
💻 M
字号:
function WritePacket(gps, id, data, type)
% WritePacket Write the a packet with the given id and data
% Since pid_dle_byte is used to delimit packet boundaries, if a data, size
% or checksum value is equal to pid_dle_byte, a second pid_dle_byte is
% immediately sent. This has the effect of "escaping" the first
% pid_dle_byte.

global pid_dle_byte

if (nargin == 3)
    type = 'uchar';
end

WritePacketHeader(gps, id, length(data)*sizeof(type));

% Send the data as a stream of bytes
for i=1:length(data)
    fwrite(gps, data(i), type);
    if (data(i) == pid_dle_byte)
        fwrite(gps, pid_dle_byte);
    end
end

WritePacketTerminator(gps, id, data, type);

   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -