Dependents: Lab3_Surveillance 6adcSerial
Diff: GPS.cpp
- Revision:
- 4:c5d054086f2c
- Parent:
- 3:ad00bddd493f
--- a/GPS.cpp Tue Feb 01 16:08:08 2011 +0000 +++ b/GPS.cpp Fri Feb 04 13:13:32 2011 +0000 @@ -11,14 +11,14 @@ while(1){ getline(); - if(scanf(msg, "GPGGA,%f,%f,%c,%f,%c,%d",&time, &latitude, &ns, &longitude, &ew, &lock) >=1) { + if(sscanf(msg, "GPGGA,%f,%f,%c,%f,%c,%d",&time, &latitude, &ns, &longitude, &ew, &lock) >=1) { if(!lock) { longitude = 0.0; latitude = 0.0; return 0; } else { - if(ns =='s') { latitude *= -1.0; } - if(ew =='w') { longitude *= -1.0; } + if(ns =='S') { latitude *= -1.0; } + if(ew =='W') { longitude *= -1.0; } float degrees = trunc(latitude / 100.0f); float minutes = latitude - (degrees * 100.0f); latitude = degrees + minutes / 60.0f;