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

📄 readroutes.m

📁 基于串行接口的GPS驱动程序
💻 M
字号:
function routes = ReadRoutes(gps)
% READROUTES Read all the route data from the GPS

global pid_command_data cmd_transfer_rte pid_xfer_cmplt

routes = [];

% Tell the GPS to send the route data to us
WritePacket(gps, pid_command_data, cmd_transfer_rte);

% Read standard beginning packet -- count is the number of waypoints in the
% route
[id, sz] = ReadPacket(gps);

% Until the transfer is complete
routeCount = 0;
while (1)

   [id, sz] = ReadPacketHeader(gps);
   csum = -1;
   
   if (pid_rte_hdr == id)
       % Start a new route
       routeCount = routeCount + 1;
       waypoints = 0;
       
       % Read the header data
       
       % Compute the checksum
       csum = ComputeChecksum(id, 
       
   elseif (pid_rte_wpt_data == id)
       % Read waypoint data into the current route
       waypoints = waypoints+1;
       
       % Read the waypoint data
       
       % Compute the checksum
         csum = ComputeChecksum(id, 
     
   end
   cksum = ReadPacketTerminator(gps);
   if (csum ~= cksum)
       error(['Checksum mismatch in ReadRoutes. Expected: ' num2str(csum) ', Received: ' num2str(cksum)]);
   end
   
end

% Read the standard ending packet
[id, cmd] = ReadPacket(gps);
if (pid_command_data ~= cmd)
    error
end

⌨️ 快捷键说明

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