TomTom SDK 6

  • Thread starter Thread starter kjetila
  • Start date Start date
K

kjetila

Hi,
Is there a .dll that is possible to Pinvok in TomTom SDK 6,
( like "TTSDK5Link.dll" in SDK 5)

regards Kjetil Andersen
 
If it's a native DLL that exports some functions, you can P/Invoke it.
You'll have to know what the call names are and what the parameters are,
etc., of course.

Paul T.
 
Hi,
Is there a .dll that is possible to Pinvok in TomTom SDK 6,
( like "TTSDK5Link.dll" in SDK 5)

regards Kjetil Andersen

As Peter Foot mentioned, you can't call the functions directly since
the TomTom decided to make change SDK architecture to use C++ classes.
If you want to access functions in the TomTom SDK in .NETCF then you
will have to make a native wrapper that exports C type functions. You
can then P/Invoke those functions that you wrapper through the native
wrapper that you made.

Regards,
Christian R. Helle
 
As Peter Foot mentioned, you can't call the functions directly since
the TomTom decided to make change SDK architecture to use C++ classes.
If you want to access functions in the TomTom SDK in .NETCF then you
will have to make a native wrapper that exports C type functions. You
can then P/Invoke those functions that you wrapper through the native
wrapper that you made.

Regards,
Christian R. Helle
 
As Peter Foot mentioned, you can't call the functions directly since
the TomTom decided to make change SDK architecture to use C++ classes.
If you want to access functions in the TomTom SDK in .NETCF then you
will have to make a native wrapper that exports C type functions. You
can then P/Invoke those functions that you wrapper through the native
wrapper that you made.

Regards,
Christian R. Helle
 
As Peter Foot mentioned, you can't call the functions directly since
the TomTom decided to make change SDK architecture to use C++ classes.
If you want to access functions in the TomTom SDK in .NETCF then you
will have to make a native wrapper that exports C type functions. You
can then P/Invoke those functions that you wrapper through the native
wrapper that you made.

Regards,
Christian R. Helle
 
Here's some sample code snippets of how to accomplish this task of
calling functions in the TomTom SDK 6 in a .NETCF application

In your native wrapper, lets say we want to wrap TTSDK function:
- GetApplicationVersion(TError * err, TVersion* ver)
- FlashMessage(TError * err, char * msg, int ms)


[C++ CODE]

#include "sdkconstants.h"
#include "TomTomAPI.h"
#include "TomTomGoFileLayer.h"
#include "TTN6SDK.h"

#define CLIENT_NAME "client"

CTomTomAPI::TError err;
int res = 0;

BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call,
LPVOID lpReserved )
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

extern "C" __declspec(dllexport) int TTN_GetApplicationVersion( int*
iError, LPTSTR szVersion, int *iBuildNumber )
{
MTomTomCommunicationLayerInterface *comms =
DEFAULT_TRANSPORTATION_LAYER(CLIENT_NAME,2005,TOMTOM_TCPIP_PORT);

CTomTomAPI api(*comms);
CTomTomAPI::TVersion version;
res = api.GetApplicationVersion(&err, &version);
*iError = err.iError;

TCHAR str[16];
_stprintf(str, TEXT("%S"), version.iVersion);
lstrcpy( szVersion, (LPTSTR)str );
*iBuildNumber = version.iBuildNumber;

delete comms;
return res;
}

extern "C" __declspec(dllexport) int TTN_FlashMessage( int* iError,
char* aMessage, int aMilliSeconds )
{
char message[256];
sprintf(message, "%S", aMessage);

MTomTomCommunicationLayerInterface *comms =
DEFAULT_TRANSPORTATION_LAYER(CLIENT_NAME,2005,TOMTOM_TCPIP_PORT);

CTomTomAPI api(*comms);
res = api.FlashMessage(&err, message, aMilliSeconds);
*iError = err.iError;

delete comms;
return res;
}


And now to access the native wrapper DLL from .NETCF

[C# CODE]

[DllImport("TTSDK6.dll", EntryPoint="TTN_GetApplicationVersion")]
static extern int TTN_GetApplicationVersion(ref int iError,
StringBuilder szVersion, ref int iBuildNumber);

[DllImport("TTSDK6.dll", EntryPoint="TTN_FlashMessage")]
static extern int TTN_FlashMessage(ref int iError, string aMessage,
int aMilliseconds);

public struct TVersion
{
public string iVersion;
public int iBuildNumber;
}

public static TVersion GetApplicationVersion()
{
TVersion version = new TVersion();
StringBuilder szVersion = new StringBuilder();
int iBuildNumber = 0;

if (0 != Native.TTN_GetApplicationVersion(ref iError, szVersion, ref
iBuildNumber))
throw new Exception("An Unexpected Error occured while trying to
retrieve Application Version information...");
else {
version.iVersion = szVersion.ToString();
version.iBuildNumber = iBuildNumber;
}

return version;
}

public static void FlashMessage(string aMessage, int aMilliseconds)
{
if (0 != Native.TTN_FlashMessage(ref iError, aMessage,
aMilliseconds)) {
throw new Exception("An Unexpected Error occurred while trying to
Flash a Message ('" + aMessage + "') on the Navigator screen...");
}
}


By the way, the version 6 of the TomTom SDK is very very very buggy!
TomTom has already released 2 versions of the SDK 6, but it still
doesn't work very well. This is actually very typical for the TomTom
SDK. I wish they would do something about these problems...


Regards,
Christian R. Helle
 
Back
Top