Re: NotSupportedException TomTomSDK

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Each of those is a pointer , the first to an enumeration and the second to a
custom structure - you'll be able to tell from the .h files the layout of
this structure. You have two options, if the structures are simple you can
either declare them as a struct in managed code and pass by ref, or declare
as a class and pass directly (classes are byref by nature), the other option
is to use a byte array of the correct size for the native struct layout
(useful if the structure contains inline strings for example) and then use
the BitConverter and Buffer classes to extract the data from the relevant
places in the byte array. My recollection of the LocationV01 struct is that
it's simple with all integer members so you can declare as a struct in
managed code, you'll also need to define the enum in your managed code to
match that in the .h file, then your P/Invoke will look like:-

DllImport("TTNCom.dll", EntryPoint = "TTNCom_GetCurrentPositionV01",
SetLastError=true)]
private static extern int TTNCom_GetCurrentPositionV01( ref EGpsStatus
aStatus, ref TTTnLocationV01 aLocation );

Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://www.peterfoot.net

"Jeroen" <no@xxxxxxxx> wrote in message
news:11l26d71e2tqjd7@xxxxxxxxxxxxxxxxxxxxx
> Do you also know how to declare and use the
>
> TTNCom_GetCurrentPositionV01( CTomTomNavigatorCom::EGpsStatus &aStatus,
> CTomTomNavigatorCom::TTTnLocationV01 &aLocation );
>
> because this one doesn't use "normal" parameters
>
> "Peter Foot [MVP]" <feedback@xxxxxxxxxxxxxxxxxxxx> schreef in bericht
> news:uHuYJkY0FHA.3720@xxxxxxxxxxxxxxxxxxxxxxx
>> In .NETCF you can't marshal a long (Int64) by value, only pass it by
>> reference. However a long in C++ is a 32bit value (Int32 / int in c#) so
> you
>> can change your code to:-
>>
>> DllImport("TTNCom.dll", EntryPoint = "TTNCom_ShowCoordinatesOnMap",
>> SetLastError=true)]
>> public extern static int ShowCoordinatesOnMap(int aLongitude, int
>> aLatitude );
>>
>> Peter
>>
>> --
>> Peter Foot
>> Windows Embedded MVP
>> http://www.inthehand.com | http://www.peterfoot.net
>>
>> "Jeroen" <no@xxxxxxxx> wrote in message
>> news:11l1uqlti40jg43@xxxxxxxxxxxxxxxxxxxxx
>> > Hello,
>> >
>> > I've got some trouble with the tomtom 3 sdk.
>> >
>> > I'm currently trying the possiblities, and i only get the functons that
>> > don't use parameters to work:
>> >
>> > [DllImport("TTNCom.dll", EntryPoint =
>> > "TTNCom_BringNavigatorToForeground")]
>> > public extern static void BringNavigatorToForeground();
>> >
>> > If i call this, it works great.
>> >
>> > But when i call this function:
>> > [DllImport("TTNCom.dll", EntryPoint = "TTNCom_ShowCoordinatesOnMap",
>> > SetLastError=true)]
>> > public extern static int ShowCoordinatesOnMap( long aLongitude, long
>> > aLatitude );
>> > i get an NotSupportedException
>> > i read the documentation and i call it this way:
>> >
>> > long lon = (long)5257996;
>> > long lat = (long)51788699;
>> > try
>> > {
>> > ShowCoordinatesOnMap(lon,lat);
>> > }
>> > catch (Exception ex)
>> > {
>> > MessageBox.Show(ex.Message);
>> > }
>> >
>> > this is what the documentation says for the C++ function:
>> > 6.2.14. INT ShowCoordinateOnMap( long aLongitude, long aLatitude)
>> > Command Parameters:
>> > . long aLongitude: longitude specified in WGS84 format (in millionths
>> > of
>> > degree)
>> > . long aLatitude: latitude specified in WGS84 format (in millionths of
>> > degree)
>> > Returns: 0 if successful, non-zero value otherwise.
>> > Supported Since: TTN 1.42
>> > Centers the map around the given coordinate (zoomed in), specified in
>> > WGS84
>> > format (longitude and
>> > latitude in millionths of degree).
>> > Example:
>> > INT error = CTomTomNavigatorCom::ShowCoordinateOnMap(4860000,
>> > 52380000);
>> > 6. Communicating with TomTom Navigator from C++
>> > 31
>> > if (error)
>> > {
>> > ::AfxMessageBox(TEXT("Failed to center around a point in Amsterdam"));
>> > }
>> >
>> >
>> > So'm pretty sure the parameters itself are correct.
>> > Any ideas as to what i'm doing wrong?
>> >
>> >
>> >
>>
>>
>
>


.



Relevant Pages

  • Re: P/Invoke BYTE *
    ... declare the equivalent managed struct and pass ... declare in as a managed class and pass it by value ... (which is by ref for ref types). ... value to pDataBuffer. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Passing an array of structuresfrom a pointer?
    ... to only declare structs in headers and then define the ... the struct should be declared ... what if you have a simple array like this: ... In the header we would declare? ...
    (microsoft.public.vc.language)
  • Re: Passing an array of structuresfrom a pointer?
    ... to only declare structs in headers and then define the ... the struct should be declared ... what if you have a simple array like this: ... It also returned the value of the pointer. ...
    (microsoft.public.vc.language)
  • Re: IAR linker: too smart
    ... I am using the IAR toolchain for our Renesas M16C based project. ... The compiler is doing exactly the right thing - if you declare variables that are never used, then the compiler and/or linker is free to remove them - they have no effect on the running of your program. ... define a big struct which contains all variables and put that struct into E2PROM_DATA ...
    (comp.arch.embedded)
  • Re: Passing an array of structuresfrom a pointer?
    ... an array of struct. ... You cannot assign a pointer to struct to a long* ... to only declare structs in headers and then define the ...
    (microsoft.public.vc.language)