opengps.m
来自「Serial Application of GPS」· M 代码 · 共 35 行
M
35 行
function [gps, pid, version, text, protocols] = OpenGPS(port)
global pid_product_rqst
% Initialize global constants
constants;
%try
gps = serial(port);
fopen(gps);
set(gps, 'BaudRate', 9600, 'DataBits', 8, 'Parity', 'none', 'StopBits', 1);
% Initiate product data protocol, which queries for device
% identifier, firmware version, and optional descriptive text
% strings.
WritePacket(gps, pid_product_rqst, 0);
data = ReadProductDataType(gps);
pid = data{1};
version = data{2};
if (~isempty(data{3}))
text = data(3:end);
end
% Most devices follow the product data protocol with the protocol
% capability protocol, which describes the protocols that the GPS
% device supports.
protocols = ReadProtocols(gps);
% catch
% disp(lasterr);
% fclose(gps);
% delete(gps);
% end
%
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?