spot2000 / Volkswagen-MEB-EV-CAN-parameters

27 stars 2 forks source link

Equation for Latitude/Longitude? #3

Closed MatinF closed 2 years ago

MatinF commented 2 years ago

Hi - thanks for this great repo!

I wanted to check if anyone had success identifying the equation for Latitude/Longitude?

Below is an example of the multiframe response where the latitude should be around 47-48 and the longitude should be between 8-9.

image

spot2000 commented 2 years ago

Hi. Yes we have decoded it. See source code for evDash.

It’s very easy. It’s encoded as ascii. ;)

Mvh Conny Nikolaisen

Skickat från min iPhone 11 Pro Max

6 sep. 2022 kl. 11:47 skrev Martin Falch @.***>:



Hi - thanks for this great repo!

I wanted to check if anyone had success identifying the equation for Latitude/Longitude?

Below is an example of the multiframe response where the latitude should be around 47-48 and the longitude should be between 8-9.

[image]https://user-images.githubusercontent.com/26184427/188603230-4f193a41-9f80-4b38-8258-9b5c8909c422.png

— Reply to this email directly, view it on GitHubhttps://github.com/spot2000/Volkswagen-MEB-EV-CAN-parameters/issues/3, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASNPIBLDLJJARVL42UJ35I3V44HJFANCNFSM6AAAAAAQFU3FXA. You are receiving this because you are subscribed to this thread.Message ID: @.***>

MatinF commented 2 years ago

Hi Conny, thanks for the quick response!

I tried looking through the source code, but I was unable to specifically find the Skoda Enyaq Latitude/Longitude details. Are you able to specify where to look for it? Thanks a lot!

MatinF commented 2 years ago

I think I may have found it via below:

if (liveData->commandRequest.equals("222430")) // LAT/LON/ALT
      {
        // 6224303138B0333627362E3022450000003438B031322733342E33224E000002A1AA
        //       ^^^^

        // Parse latitude
        uint8_t b;
        float val;
        String tmp = "";
        for (uint16_t i = 0; i < 14; i++)
        {
          b = liveData->hexToDecFromResponse(6 + (i * 2), 6 + (i * 2) + 2, 1, false);
          if (b == 0)
            break;
          tmp += char((b > 100) ? 95 : b);
        }
        // 18_36'6.0"E
        val = convertLatLonToDecimal(tmp);
        if (val != 0)
          liveData->params.gpsLon = val;

        // Parse logitude
        tmp = "";
        for (uint16_t i = 0; i < 14; i++)
        {
          b = liveData->hexToDecFromResponse(34 + (i * 2), 34 + (i * 2) + 2, 1, false);
          if (b == 0)
            break;
          tmp += char((b > 100) ? 95 : b);
        }

        // 48_12'34.3"N
        val = convertLatLonToDecimal(tmp);

        if (val != 0)
          liveData->params.gpsLat = val;
        // altitude
        int16_t alt = liveData->hexToDecFromResponse(62, 66, 2, false) - 501;
        if (alt > -500)
          liveData->params.gpsAlt = alt;
      }

I'm a bit unfamiliar with the syntax, though. Can you clarify what the bit start and length is for the bits related to Latitude and Longitude? And what would be the scale/offset?

Thanks a ton again for all your work on this!

spot2000 commented 2 years ago

Yes. That’s the correct code.

Mvh Conny Nikolaisen

Skickat från min iPhone 11 Pro Max

6 sep. 2022 kl. 12:28 skrev Martin Falch @.***>:



I think I may have found it via below:

if (liveData->commandRequest.equals("222430")) // LAT/LON/ALT { // 6224303138B0333627362E3022450000003438B031322733342E33224E000002A1AA // ^^^^

    // Parse latitude
    uint8_t b;
    float val;
    String tmp = "";
    for (uint16_t i = 0; i < 14; i++)
    {
      b = liveData->hexToDecFromResponse(6 + (i * 2), 6 + (i * 2) + 2, 1, false);
      if (b == 0)
        break;
      tmp += char((b > 100) ? 95 : b);
    }
    // 18_36'6.0"E
    val = convertLatLonToDecimal(tmp);
    if (val != 0)
      liveData->params.gpsLon = val;

    // Parse logitude
    tmp = "";
    for (uint16_t i = 0; i < 14; i++)
    {
      b = liveData->hexToDecFromResponse(34 + (i * 2), 34 + (i * 2) + 2, 1, false);
      if (b == 0)
        break;
      tmp += char((b > 100) ? 95 : b);
    }

    // 48_12'34.3"N
    val = convertLatLonToDecimal(tmp);

    if (val != 0)
      liveData->params.gpsLat = val;
    // altitude
    int16_t alt = liveData->hexToDecFromResponse(62, 66, 2, false) - 501;
    if (alt > -500)
      liveData->params.gpsAlt = alt;
  }

I'm a bit unfamiliar with the syntax, though. Can you clarify what the bit start and length is for the bits related to Latitude and Longitude? And what would be the scale/offset?

Thanks a ton again for all your work on this!

— Reply to this email directly, view it on GitHubhttps://github.com/spot2000/Volkswagen-MEB-EV-CAN-parameters/issues/3#issuecomment-1237965862, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASNPIBP3GYLAZZ32WUOF4DLV44MGJANCNFSM6AAAAAAQFU3FXA. You are receiving this because you commented.Message ID: @.***>

MatinF commented 2 years ago

Thanks I think I see the logic now of converting the bytes to ASC, then back. That's unfortunately beyond the domain of simple DBC files it seems :-P Appreciate the fast support!