How to extract only '$GPGGA' string real-time from Garmin gps device on matlab ?

3 visualizzazioni (ultimi 30 giorni)
Hello, I am trying to extract GPS signals real-time from a Garmin 18x device by using serial communication. But every time I run the program using a 'while' loop, there are other strings namely '$GPVTG' and '$PGRME' also being read. I just need '$GPGGA' string for my use case which I'm not able to extract.
I did try using 'textscan' and 'strtok' but nothing worked as there are 3 different string types and lengths. The command window showing the string data being read is as shown in the image.
The code I used is below:
% Extraction of data from GPS
garmin_gps = serial('COM4','Baudrate', 19200); %Create serial port object 'garmin_gps' to connect Garmin device
set(garmin_gps, 'InputBufferSize', 512000);
set(garmin_gps, 'terminator', '*')
fopen(garmin_gps);
Z = isempty('InputBufferSize')
while Z == 0
D = fscanf(garmin_gps, '%s')
end

Risposte (1)

Mark McBroom
Mark McBroom il 15 Mar 2018
Have you tried regexp?
  1 Commento
Prajwal Ramakrishna
Prajwal Ramakrishna il 16 Mar 2018
Yes, But then it returns just the index values of the expression I require. In my case, I only need the '$GPGGA' string omitting the other two when the 'while' loop iterates every time. Please help me with this.

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by