From: Mike Edwards on
Whenever I call GPSGetPosition, I get error code 87 (Invalid Parameter)
returned. Does anyone have any idea why that might be?

I have defined a global GPS_POSITION structure, and GPSOpenDevice does not
return NULL. Basically my program then has a timer which, when triggered,
increments a counter (which I display so I can see something is happening)
then attempts to call GPSGetPosition. I've tried values of 10000 and 2000
for the maximum age parameter but for now I'd just like to see some data,
regardless of how old it is.

I've configured the device to 'know' about an outgoing COM port to my paired
GPS receiver. I've also tried on two different devices, a Dell x51v and an
XDA EXEC, with the same results.

Code is basically:
GPS_POSITION gpsCurrent;
HANDLE gpsConnection;
bool gpsFirst;
int gpsCount;

In InitInstance:
gpsFirst = true;
gpsCount=0;

In WndProc:

case WM_TIMER:
if (gpsFirst)
{
gpsConnection = GPSOpenDevice(NULL,NULL,NULL,0);
if (gpsConnection == NULL)
{
// alert for failure here
}
gpsFirst = false;
}
else
{
GPSGetPosition(gpsConnection, &gpsPosition, 10000, 0);
gpsCount++;
}
break;

Of course in the real code I check the return code from GPSGetPosition and
display an msgbox if it is not ERROR_SUCCESS.

But I can't get anything other than error 87. I'm using Visual Studio 2005
and the WM5 toolkit, it all compiles without any trouble. I can't find
anything on the web that is similar, other than one unanswered forum thread
that might be relevant.

Thanks,
Mike.


From: Sean McLeod on
Hi

Assuming that the code below is accurate except for some error checking on
return values have you read the documentation on the GPS_POSITION structure?

In particular in your code snippet below I don't see you setting the
dwVersion and dwSize fields.

dwVersion
Version of the GPS Intermediate Driver expected by the application. Must be
set before the structure is passed to GPSGetPosition. Must be GPS_VERSION_1.
dwSize
Size of the structure, in bytes. Must be set before the structure is passed
to GPSGetPosition.

Cheers

"Mike Edwards" <test(a)test.com> wrote in message
news:OaRtcQ6tGHA.4872(a)TK2MSFTNGP02.phx.gbl...
> Whenever I call GPSGetPosition, I get error code 87 (Invalid Parameter)
> returned. Does anyone have any idea why that might be?
>
> I have defined a global GPS_POSITION structure, and GPSOpenDevice does not
> return NULL. Basically my program then has a timer which, when triggered,
> increments a counter (which I display so I can see something is happening)
> then attempts to call GPSGetPosition. I've tried values of 10000 and 2000
> for the maximum age parameter but for now I'd just like to see some data,
> regardless of how old it is.
>
> I've configured the device to 'know' about an outgoing COM port to my
> paired GPS receiver. I've also tried on two different devices, a Dell x51v
> and an XDA EXEC, with the same results.
>
> Code is basically:
> GPS_POSITION gpsCurrent;
> HANDLE gpsConnection;
> bool gpsFirst;
> int gpsCount;
>
> In InitInstance:
> gpsFirst = true;
> gpsCount=0;
>
> In WndProc:
>
> case WM_TIMER:
> if (gpsFirst)
> {
> gpsConnection = GPSOpenDevice(NULL,NULL,NULL,0);
> if (gpsConnection == NULL)
> {
> // alert for failure here
> }
> gpsFirst = false;
> }
> else
> {
> GPSGetPosition(gpsConnection, &gpsPosition, 10000, 0);
> gpsCount++;
> }
> break;
>
> Of course in the real code I check the return code from GPSGetPosition and
> display an msgbox if it is not ERROR_SUCCESS.
>
> But I can't get anything other than error 87. I'm using Visual Studio 2005
> and the WM5 toolkit, it all compiles without any trouble. I can't find
> anything on the web that is similar, other than one unanswered forum
> thread that might be relevant.
>
> Thanks,
> Mike.
>
>


From: Mike Edwards on
Sean,

Thanks for that - it's almost certainly the problem. I don't specifically
set those values. I had read the GPS_POSITION documentation as far as I
thought I needed to - that is, to display the appropriate parts for my
position. Sounds like I should have read the remainder but I was taken up by
the excitement of my project actually compiling (it's my first VS2005 / WM5
project, after evb and evc).

In my (sort of) defence I did a search before posting here to look for more
information and nothing I saw on the web (including a presentation from MS
on advanced c++ with the GPS API from TechEd 2005) suggested that I had to
do this.

Thanks very much for the pointer, I will try it out later and I'm sure it
will sort the problem out.

Mike.

"Sean McLeod" <seanmcleod(a)newsgroups.nospam> wrote in message
news:e8f9VF7tGHA.2392(a)TK2MSFTNGP05.phx.gbl...
> Hi
>
> Assuming that the code below is accurate except for some error checking on
> return values have you read the documentation on the GPS_POSITION
> structure?
>
> In particular in your code snippet below I don't see you setting the
> dwVersion and dwSize fields.
>
> dwVersion
> Version of the GPS Intermediate Driver expected by the application. Must
> be set before the structure is passed to GPSGetPosition. Must be
> GPS_VERSION_1.
> dwSize
> Size of the structure, in bytes. Must be set before the structure is
> passed to GPSGetPosition.
>
> Cheers
>
> "Mike Edwards" <test(a)test.com> wrote in message
> news:OaRtcQ6tGHA.4872(a)TK2MSFTNGP02.phx.gbl...
>> Whenever I call GPSGetPosition, I get error code 87 (Invalid Parameter)
>> returned. Does anyone have any idea why that might be?
>>
>> I have defined a global GPS_POSITION structure, and GPSOpenDevice does
>> not return NULL. Basically my program then has a timer which, when
>> triggered, increments a counter (which I display so I can see something
>> is happening) then attempts to call GPSGetPosition. I've tried values of
>> 10000 and 2000 for the maximum age parameter but for now I'd just like to
>> see some data, regardless of how old it is.
>>
>> I've configured the device to 'know' about an outgoing COM port to my
>> paired GPS receiver. I've also tried on two different devices, a Dell
>> x51v and an XDA EXEC, with the same results.
>>
>> Code is basically:
>> GPS_POSITION gpsCurrent;
>> HANDLE gpsConnection;
>> bool gpsFirst;
>> int gpsCount;
>>
>> In InitInstance:
>> gpsFirst = true;
>> gpsCount=0;
>>
>> In WndProc:
>>
>> case WM_TIMER:
>> if (gpsFirst)
>> {
>> gpsConnection = GPSOpenDevice(NULL,NULL,NULL,0);
>> if (gpsConnection == NULL)
>> {
>> // alert for failure here
>> }
>> gpsFirst = false;
>> }
>> else
>> {
>> GPSGetPosition(gpsConnection, &gpsPosition, 10000, 0);
>> gpsCount++;
>> }
>> break;
>>
>> Of course in the real code I check the return code from GPSGetPosition
>> and display an msgbox if it is not ERROR_SUCCESS.
>>
>> But I can't get anything other than error 87. I'm using Visual Studio
>> 2005 and the WM5 toolkit, it all compiles without any trouble. I can't
>> find anything on the web that is similar, other than one unanswered forum
>> thread that might be relevant.
>>
>> Thanks,
>> Mike.
>>
>>
>
>


From: Mike Edwards on
Huh, not sure how I managed to miss these, as they are the first entries
defined in the document. How embarrassing.

Mike.

"Mike Edwards" <test(a)test.com> wrote in message
news:%236T1lL7tGHA.2392(a)TK2MSFTNGP05.phx.gbl...
> Sean,
>
> Thanks for that - it's almost certainly the problem. I don't specifically
> set those values. I had read the GPS_POSITION documentation as far as I
> thought I needed to - that is, to display the appropriate parts for my
> position. Sounds like I should have read the remainder but I was taken up
> by the excitement of my project actually compiling (it's my first VS2005 /
> WM5 project, after evb and evc).
>
> In my (sort of) defence I did a search before posting here to look for
> more information and nothing I saw on the web (including a presentation
> from MS on advanced c++ with the GPS API from TechEd 2005) suggested that
> I had to do this.
>
> Thanks very much for the pointer, I will try it out later and I'm sure it
> will sort the problem out.
>
> Mike.
>
> "Sean McLeod" <seanmcleod(a)newsgroups.nospam> wrote in message
> news:e8f9VF7tGHA.2392(a)TK2MSFTNGP05.phx.gbl...
>> Hi
>>
>> Assuming that the code below is accurate except for some error checking
>> on return values have you read the documentation on the GPS_POSITION
>> structure?
>>
>> In particular in your code snippet below I don't see you setting the
>> dwVersion and dwSize fields.
>>
>> dwVersion
>> Version of the GPS Intermediate Driver expected by the application. Must
>> be set before the structure is passed to GPSGetPosition. Must be
>> GPS_VERSION_1.
>> dwSize
>> Size of the structure, in bytes. Must be set before the structure is
>> passed to GPSGetPosition.
>>
>> Cheers
>>
>> "Mike Edwards" <test(a)test.com> wrote in message
>> news:OaRtcQ6tGHA.4872(a)TK2MSFTNGP02.phx.gbl...
>>> Whenever I call GPSGetPosition, I get error code 87 (Invalid Parameter)
>>> returned. Does anyone have any idea why that might be?
>>>
>>> I have defined a global GPS_POSITION structure, and GPSOpenDevice does
>>> not return NULL. Basically my program then has a timer which, when
>>> triggered, increments a counter (which I display so I can see something
>>> is happening) then attempts to call GPSGetPosition. I've tried values of
>>> 10000 and 2000 for the maximum age parameter but for now I'd just like
>>> to see some data, regardless of how old it is.
>>>
>>> I've configured the device to 'know' about an outgoing COM port to my
>>> paired GPS receiver. I've also tried on two different devices, a Dell
>>> x51v and an XDA EXEC, with the same results.
>>>
>>> Code is basically:
>>> GPS_POSITION gpsCurrent;
>>> HANDLE gpsConnection;
>>> bool gpsFirst;
>>> int gpsCount;
>>>
>>> In InitInstance:
>>> gpsFirst = true;
>>> gpsCount=0;
>>>
>>> In WndProc:
>>>
>>> case WM_TIMER:
>>> if (gpsFirst)
>>> {
>>> gpsConnection = GPSOpenDevice(NULL,NULL,NULL,0);
>>> if (gpsConnection == NULL)
>>> {
>>> // alert for failure here
>>> }
>>> gpsFirst = false;
>>> }
>>> else
>>> {
>>> GPSGetPosition(gpsConnection, &gpsPosition, 10000, 0);
>>> gpsCount++;
>>> }
>>> break;
>>>
>>> Of course in the real code I check the return code from GPSGetPosition
>>> and display an msgbox if it is not ERROR_SUCCESS.
>>>
>>> But I can't get anything other than error 87. I'm using Visual Studio
>>> 2005 and the WM5 toolkit, it all compiles without any trouble. I can't
>>> find anything on the web that is similar, other than one unanswered
>>> forum thread that might be relevant.
>>>
>>> Thanks,
>>> Mike.
>>>
>>>
>>
>>
>
>


 | 
Pages: 1
Prev: DeviceIOControl
Next: Datagrid