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.
Dependents: 2-1_GMS6-CR6 5_flightmode 5-2_thrustermode 5-3_thruster_depressmode ... more
GMS6_CR6.cpp
- Committer:
- rary
- Date:
- 2020-07-13
- Revision:
- 1:cefba0edfdd3
- Parent:
- 0:e504e33078a7
- Child:
- 2:98e44a8cca1d
File content as of revision 1:cefba0edfdd3:
#include "mbed.h" #include "GMS6_CR6.h" #include "math.h" GMS6_CR6::GMS6_CR6(PinName tx, PinName rx) : gps(tx, rx) { } GMS6_CR6::~GMS6_CR6() { } float GMS6_CR6::_DMS2DEG(float raw_data) { int d = (int)(raw_data/100); float m = (raw_data - (float)d * 100); return (float) d + m /60; } void GMS6_CR6::read(float *G) { char gps_data[256]; memset(gps_data, '\0', 256); int cnt_gps = 0; float world_time; int rlock, sat_num; char lat, lon; float lon_east = 0; float lat_north = 0; int i = 0; while(lat_north < 20 && i < 100000) //緯度が20度以上と測定されるまたは一定回数ループが回ると抜ける { if(gps.readable()) { gps_data[cnt_gps] = gps.getc(); if(gps_data[cnt_gps] == '$' || cnt_gps == 256) { cnt_gps = 0; memset(gps_data, '\0', 256); //この関数なんや } else if(gps_data[cnt_gps] == '\r') { if(sscanf(gps_data, "GPGGA,%f,%f,%c,%f,%c,%d,%d", &world_time, &lat_north, &lat, &lon_east, &lon, &rlock, &sat_num) >= 1) { if (rlock == 1) { lat_north = _DMS2DEG(lat_north); lon_east = _DMS2DEG(lon_east); } } } else { cnt_gps++; } } i++; } if(lat_north > 20 && lat_north < 90 && lon_east > 90 && lon_east < 180) //緯度が正常な値のときのみ値を返す { *G = lat_north; *(G+1) = lon_east; } else { *G = 4; *(G+1) = 4; } }