readroutes.m
来自「Serial Application of GPS」· M 代码 · 共 54 行
M
54 行
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 + =
减小字号Ctrl + -
显示快捷键?