www.pudn.com > SerialGPS.zip > OpenGPS.m
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
%