Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ConfigFile SDFileSystem mbed
Fork of LAURUS_program by
GMS6_CR6.cpp
00001 #include "mbed.h" 00002 #include "GMS6_CR6.h" 00003 00004 GMS6_CR6::GMS6_CR6(Serial* ps, Serial* pc): p_port(ps), p_pc(pc) { 00005 p_port->baud(4800); 00006 pointer = 0; 00007 INT_flag = 0; 00008 p_port->attach(this, &GMS6_CR6::INT_Rx, Serial::RxIrq); 00009 } 00010 00011 GMS6_CR6::~GMS6_CR6() { 00012 p_port = NULL; 00013 } 00014 00015 void GMS6_CR6::read() { 00016 while(INT_flag); 00017 int ret = sscanf(buff2, "$GPGGA,%f,%f,%c,%f,%c,%d,%d", 00018 &time, &raw_latitude, &lat_hem, &raw_longitude, &lng_hem, &mode, &Ns); 00019 if(!ret) { 00020 p_pc->printf("sscanf Error\r\n"); 00021 return; 00022 } 00023 00024 int deg_lat = (int)raw_latitude / 100; 00025 float min_lat = (raw_latitude - (float)(deg_lat*100)) / 60.0f; 00026 latitude = (float)deg_lat + min_lat; 00027 00028 int deg_lng = (int)raw_longitude / 100; 00029 float min_lng = (raw_longitude - (float)(deg_lng*100)) / 60.0f; 00030 longitude = (float)deg_lng + min_lng; 00031 00032 00033 } 00034 00035 void GMS6_CR6::INT_Rx() { 00036 char *sp; 00037 buff1[pointer] = p_port->getc(); 00038 00039 if(buff1[pointer] != '\r') { 00040 if(pointer<(BuffSize-1)){ 00041 pointer = pointer+1; 00042 } 00043 } else { 00044 if((sp=strstr(buff1, "$GPGGA")) != NULL) { 00045 buff1[pointer] = '\0'; 00046 INT_flag = 1; 00047 strcpy(buff2, sp); 00048 INT_flag = 0; 00049 } 00050 pointer = 0; 00051 } 00052 }
Generated on Tue Jul 12 2022 22:15:02 by
1.7.2
