ublox NEO 7M und das UBX Protokoll

Hi,

ich bin ganz frisch dabei und habe mir ein GPS Modul und einen Uno zum lernen gekauft.
Gute Infos und einen Beispielquelltext gab es hier zum Video dazu:

Ich verwende den Beispielquelltext von ihm und benutze nur die NAV_POSLLH (ein Teil aus dem Ublox eigenen UBX Protokoll). Das funktioniert auch alles wunderbar und mit 10hz Updaterate.

Nun habe ich via u-center (Konfigurationssoftware) noch weitere Protokollteile freigeschaltet.
NAV_TIMEUTC mit ID 0x21 und NAV_VELNED mit ID 0x12

Ich denke ich habe verstanden was ein struct ist. Diesen werde ich für die beiden anderen NAV_ erstellen müssen.
Was mir noch etwas Schwierigkeiten bereitet ist der processGPS wo er (so verstehe ich es zumindest) das eingelesene NAV_POSLLH zerlegt.

#include <SoftwareSerial.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h> 


LiquidCrystal_I2C  lcd(0x27,2,1,0,4,5,6,7,3,POSITIVE);
// Connect the GPS RX/TX to arduino pins 3 and 5
SoftwareSerial myserial = SoftwareSerial(3,5);

const unsigned char UBX_HEADER[] = { 0xB5, 0x62};

struct NAV_POSLLH {
  unsigned char cls;
  unsigned char id;
  unsigned short len;
  unsigned long iTOW;
  long lon;
  long lat;
  long height;
  long hMSL;
  unsigned long hAcc;
  unsigned long vAcc;
};

NAV_POSLLH posllh;

void calcChecksum(unsigned char* CK) {
  memset(CK, 0, 2);
  for (int i = 0; i < (int)sizeof(NAV_POSLLH); i++) {
    CK[0] += ((unsigned char*)(&posllh))[i];
    CK[1] += CK[0];
  }
}

bool processGPS() {
  static int fpos = 0;
  static unsigned char checksum[2];
  const int payloadSize = sizeof(NAV_POSLLH);

  while ( myserial.available() ) {
    byte c = myserial.read();
    if ( fpos < 2 ) {
      if ( c == UBX_HEADER[fpos] )
        fpos++;
      else
        fpos = 0;
    }
    else {
      if ( (fpos-2) < payloadSize )
        ((unsigned char*)(&posllh))[fpos-2] = c;

      fpos++;

      if ( fpos == (payloadSize+2) ) {
        calcChecksum(checksum);
      }
      else if ( fpos == (payloadSize+3) ) {
        if ( c != checksum[0] )
          fpos = 0;
      }
      else if ( fpos == (payloadSize+4) ) {
        fpos = 0;
        if ( c == checksum[1] ) {
          return true;
        }
      }
      else if ( fpos > (payloadSize+4) ) {
        fpos = 0;
      }
    }
  }
  return false;
}

void setup() 
{
  Serial.begin(9600);
  myserial.begin(9600);
  lcd.begin(20,4);
}

void loop() {

  if ( processGPS() ) {
    Serial.print(posllh.id); 
   // Serial.print(velned.id);
    //Serial.print(velned.speed3d);

    Serial.print("iTOW:");      Serial.print(posllh.iTOW);
    Serial.print(" lat/lon: "); Serial.print(posllh.lat/10000000.0f); Serial.print(","); Serial.print(posllh.lon/10000000.0f);
    Serial.print(" height: ");  Serial.print(posllh.height/1000.0f);
    Serial.print(" hMSL: ");    Serial.print(posllh.hMSL/1000.0f);
    Serial.print(" hAcc: ");    Serial.print(posllh.hAcc/1000.0f);
    Serial.print(" vAcc: ");    Serial.print(posllh.vAcc/1000.0f); 
    Serial.println();
    
  }
/*
  lcd.setCursor(0, 0);
  lcd.print("iTOW: "); lcd.print(posllh.iTOW);
  lcd.setCursor(0, 1);
  lcd.print("lat: "); lcd.print(posllh.lat/10000000.0f);
  lcd.setCursor(0, 2);
  lcd.print("lon: "); lcd.print(posllh.lon/10000000.0f);
  lcd.setCursor(0, 3);
  lcd.print("hMSL: "); lcd.print(posllh.hMSL/1000.0f);
  */
}

Ich hatte schon ein NAV_VELNED drin und habe alles soweit angepasst.
Auch hatte ich const unsigned char UBX_HEADER[] = { 0xB5, 0x62}; erweitert auf const unsigned char UBX_HEADER[] = { 0xB5, 0x62, 0x01, 0x02}; weil ich dachte hier ist definiert welche Daten er verarbeiten soll. Hat aber leider nicht funktioniert.

Anbei noch Screenshots aus der PDF des Herstellers.
Seite 159ff LINK!

Ich würde mich freuen wenn jemand Kommentare in den Code setzt oder mir 2-3 Sätzen versucht einen Erklärung zu verfassen.

Vielen Dank

nav_posllh.JPG

nav_velned.JPG

Ich werd ich mal mit NeoGPS beschäftigen.

Das hier ließt sich interessant: GPS U-Blox Neo M8N parser - #5 by dev_1 - Networking, Protocols, and Devices - Arduino Forum