Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void parseString(){
- if (strncmp(parseptr, "$GPGGA",6) == 0)
- parseGPGGA();
- if (strncmp(parseptr, "$GPGSA",6) == 0)
- parseGPGSA();
- if (strncmp(parseptr, "$GPRMC",6) == 0 )
- parseGPRMC();
- if (strncmp(parseptr, "$GPVTG",6) == 0 )
- parseGPVTG();
- if (strncmp(parseptr, "$HCHDG",6) == 0)
- parseHCHDG();
- if (strncmp(parseptr, "$WIMDA",6) == 0 )
- parseWIMDA();
- if (strncmp(parseptr, "$PFEC,GPatt",11) == 0 )
- parsePFEC();
- if (strncmp(parseptr, "$WIXDR",6) == 0 )
- parseWIXDR();
- if (strncmp(parseptr, "$RDATA",6) == 0 )
- parseRDATA();
- if (strncmp(parseptr, "$YPR",4) == 0 )
- parseYPR();
- }
- void parseYPR(){
- parseptr = parseptr+5;
- for (int i = 1; i<10;i++){
- if (parseptr[0] != ',') {
- switch (i){
- case 1:
- yaw = atof(parseptr);
- break;
- case 2:
- pitch = atof(parseptr);
- break;
- case 3:
- roll = atof(parseptr);
- break;
- default:
- break;
- }
- parseptr = strchr(parseptr, ',') + 1;
- }
- else
- parseptr = parseptr +1;
- }
- }
- void parseGPGGA(){
- parseptr = parseptr+7;
- float inFloat;
- for (int i = 1; i<10;i++){
- if (parseptr[0] != ',') {
- switch (i){
- case 1:
- inFloat= atof(parseptr);
- timeHHMMSS = (uint32_t)inFloat;
- break;
- case 2:
- lattitude = atof(parseptr);
- break;
- case 4:
- longitude = atof(parseptr);
- case 6:
- fixQuality = atoi(parseptr);
- if(fixQuality == 0)
- gpsFix = false;
- else
- gpsFix = true;
- case 9:
- alt = atof(parseptr);
- default:
- break;
- }
- parseptr = strchr(parseptr, ',') + 1;
- }
- else
- parseptr = parseptr +1;
- }
- }
- void parseGPGSA(){
- parseptr = parseptr+7;
- if (parseptr[9] == 3)
- gpsFix = true;
- else
- gpsFix = false;
- }
- void parseGPRMC(){
- parseptr = parseptr+7;
- float inFloat;
- for (int i = 1; i<9;i++){
- if (parseptr[0] != ',') {
- switch (i){
- case 1:
- inFloat= atof(parseptr);
- timeHHMMSS = (uint32_t)inFloat;
- break;
- case 3:
- lattitude = atof(parseptr);
- break;
- case 5:
- longitude = atof(parseptr);
- break;
- case 7:
- speedKnots = atof(parseptr);
- break;
- case 8:
- trueHeading = atof(parseptr);
- break;
- default:
- break;
- }
- parseptr = strchr(parseptr, ',') + 1;
- }
- else
- parseptr = parseptr +1;
- }
- }
- void parseGPVTG(){
- parseptr = parseptr+7;
- for (int i = 1; i<8;i++){
- if (parseptr[0] != ',') {
- switch (i){
- case 1:
- trueHeading = atof(parseptr);
- break;
- case 3:
- magneticHeading = atof(parseptr);
- break;
- case 5:
- speedKnots = atof(parseptr);
- break;
- case 7:
- speedKMH = atof(parseptr);
- break;
- default:
- break;
- }
- parseptr = strchr(parseptr, ',') + 1;
- }
- else
- parseptr = parseptr +1;
- }
- }
- void parseHCHDG(){
- parseptr = parseptr+7;
- for (int i = 1; i<8;i++){
- if (parseptr[0] != ',') {
- switch (i){
- case 1:
- trueHeading = atof(parseptr);
- break;
- case 3:
- magneticHeading = atof(parseptr);
- break;
- case 5:
- speedKnots = atof(parseptr);
- break;
- case 7:
- speedKMH = atof(parseptr);
- break;
- default:
- break;
- }
- parseptr = strchr(parseptr, ',') + 1;
- }
- else {
- parseptr = parseptr +1;
- }
- }
- }
- void parsePFEC(){
- parseptr = parseptr+12;
- for (int i = 1; i<4;i++){
- if (parseptr[0] != ',') {
- switch (i){
- case 1:
- weatherPitch = atof(parseptr);
- break;
- case 2:
- weatherRoll = atof(parseptr);
- break;
- case 3:
- weatherYaw = atof(parseptr);
- break;
- default:
- break;
- }
- parseptr = strchr(parseptr, ',') + 1;
- }
- else
- parseptr = parseptr +1;
- }
- }
- void parseWIMDA(){
- parseptr = parseptr+7;
- for (int i = 1; i<20;i++){
- if (parseptr[0] != ',') {
- switch (i){
- case 1:
- barometricPressureInches = atof(parseptr);
- break;
- case 3:
- barometricPressureBars= atof(parseptr);
- break;
- case 5:
- airTemp = atof(parseptr);
- break;
- case 9:
- relativeHumidity = atof(parseptr);
- break;
- case 11:
- dewPoint = atof(parseptr);
- break;
- case 13:
- windDirectionTrue = atof(parseptr);
- break;
- case 15:
- windDirectionMagnetic = atof(parseptr);
- break;
- case 17:
- windSpeedKnots = atof(parseptr);
- break;
- case 19:
- windSpeedMetersPerSecond = atof(parseptr);
- break;
- default:
- break;
- }
- parseptr = strchr(parseptr, ',') + 1;
- }
- else
- parseptr = parseptr +1;
- }
- }
- void parseWIXDR(){
- parseptr = parseptr+7;
- for (int i = 1; i<15;i++){
- if (parseptr[0] != ',') {
- switch (i){
- case 2:
- relativeWindChill = atof(parseptr);
- break;
- case 6:
- theoreticalWindChill = atof(parseptr);
- break;
- case 10:
- weatherPitch = atof(parseptr);
- break;
- case 14:
- weatherRoll = atof(parseptr);
- break;
- default:
- break;
- }
- parseptr = strchr(parseptr, ',') + 1;
- }
- else
- parseptr = parseptr +1;
- }
- }
- void parseRDATA(){
- parseptr = parseptr+7;
- for (int i = 1; i<4;i++){
- if (parseptr[0] != ',') {
- switch (i){
- case 1:
- countPerMinute = atoi(parseptr);
- break;
- case 3:
- microSievertPerHour = atof(parseptr);
- break;
- default:
- break;
- }
- parseptr = strchr(parseptr, ',') + 1;
- }
- else {
- parseptr = parseptr +1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement