Archived:RPositioner::NotifyPositionUpdate returns KErrInUse after few minutes (Known Issue)
Trying to use RPositioner::NotifyPositionUpdate() to receive GPS position fails after a certain number of updates have been made, if update options have been omitted. This known issue has been verified by Nokia Developer.
Article Metadata
Tested with
Compatibility
Article
Description
Approximately after 4-5 minutes (255 update cycles), RPositioner::NotifyPositionUpdate() completes with error KErrInUse (-14). This happens when the client has not set valid update options with RPositioner::SetUpdateOptions().
This is not the defined return value for this API. After returning KErrInUse the RPositioner has "died" and always returns KErrInUse.
Note that the problem does not appear when using a Bluetooth GPS through the Location Acquisition API, or on the emulator.
How to reproduce
Header file:
class CMyPositioner : public CActive
{
...
RPositionServer iPositionServer;
RPositioner iPositioner;
TPositionSatelliteInfo iSatelliteInfo;
};
Implementation:
_LIT(KRequestor, "MyPositioner");
void CMyPositioner::ConstructL()
{
...
User::LeaveIfError( iPositionServer.Connect() );
User::LeaveIfError( iPositioner.Open(iPositionServer) );
User::LeaveIfError( iPositioner.SetRequestor( CRequestor::ERequestorService,
CRequestor::EFormatApplication,
KRequestor) );
CActiveScheduler::Add( this );
}
void CMyPositioner::StartL()
{
...
iPositioner.NotifyPositionUpdate( iSatelliteInfo, iStatus );
SetActive();
}
void CMyPositioner::RunL()
{
if (iStatus == KErrNone)
{
// Got iSatelliteInfo successfully, handle it
HandleSatelliteInfo();
// Request next update
iPositioner.NotifyPositionUpdate(iSatelliteInfo, iStatus);
SetActive();
}
else
{
// Fails with KErrInUse (-14) after 255 cycles
_LIT( KDebugMessage, "NotifyPositionUpdate() failed: %d" );
RDebug::Print( KDebugMessage, iStatus.Int() );
}
}
Solution
Set valid update options with RPositioner::SetUpdateOptions() prior to calling RPositioner::NotifyPositionUpdate():
iPositioner.SetUpdateOptions(
TPositionUpdateOptions( '''aInterval''',
TTimeIntervalMicroSeconds(0), /* timeout */
TTimeIntervalMicroSeconds(0), /* max age */
aAcceptPartialUpdates));
iPositioner.NotifyPositionUpdate( iSatelliteInfo, iStatus );
SetActive();
...
Note that the update interval (aInterval) value must be non-zero.


This article has been edited incorrectly when it became official item in Knowledge Base. Note that you have to call SetUpdateOptions periodically. Once is not enough as the edited article now suggests! There is also some overhead (resets some state?) when calling SetUpdateOptions every time before issuing the request.
Hello friends,
I tried this solution, but it didn't work.
So I studied the problem and I've found a real solution, it works fine.
This is my solution:
I have a CActive object that handles GPS asyncronous requests.
When I get KErrInUse error, I destroy my CActive object, and then I create it again.
After that, I can use GPS again for 4-5 minutes or more.
This process is repeated each time KErrInUse occurs.
Hope this helps,
Raffael
A real solution
Hello friends,
I tried this solution, but it didn't work.
So I studied the problem and I've found a real solution, it works fine.
This is my solution:
I have a CActive object that handles GPS asyncronous requests.
When I get KErrInUse error, I destroy my CActive object, and then I create it again.
After that, I can use GPS again for 4-5 minutes or more.
This process is repeated each time KErrInUse occurs.
Hope this helps,
Raffael