Active Objects not executing (for IMEI number)

Login to reply to this topic.
Fri, 2004-12-10 00:12
Joined: 2004-05-29
Forum posts: 149
Hi all, I'm trying to use the third-party CTelephony library (a part of the Beta Series 80 SDK).  Using code off of a Nokia website, I am getting the IMEI number of a phone.  The request is asynchronous.  Here is the code:
Code:
TRequestStatus iStatus;
CTelephony::TPhoneIdV1 iPhoneId;
CTelephony* telephony = NULL;

TRAPD(err2, telephony = CTelephony::NewL());
if (telephony)
{
if (pSerialNumber)
{
CTelephony::TPhoneIdV1Pckg phoneInfo(iPhoneId);
telephony->GetPhoneId(iStatus, phoneInfo);

// User::WaitForRequest(iStatus) will hang the device, so wait manually
//
int safety = 0;
while(safety < 5000)
{
safety++;
if (iStatus.Int() != KRequestPending)
safety = 6000;

// the following causes a KernExec 3
// CActiveScheduler::RunIfReady(err, CActive::EPriorityIdle);

// doesn't work
CCoeEnv::Flush();
}

TPtrC theIMEI(iPhoneId.iSerialNumber);
}
}

I should be able to use User::WaitForRequest(iStatus), but that simply hangs forever.  I tried flushing the system with CCoeEnv::Flush(), still no avail.  How can I get this to work?  And I have no idea how RunIfReady could cause a Kern Exec 3, anybody out there ever experience this?

One thing that may be of interest, this code is located in a DLL.  At some point, when the control flow returns to the calling APP (I think right after a dialog is displayed), I get a E32USER-CBase 46 (stray signal).  Sounds like the active object is finally executed, albeit too late.

Has anyone run into a problem like this before?  I've been working on it all day and I'm flustered beyond belief!

Fri, 2004-12-10 14:23
Joined: 2004-09-24
Forum posts: 64
Active Objects not executing (for IMEI number)
Is that code part of your Active Object?

If yes, are you defining a local iStatus instead of using the iStatus Object defined in the CActive baseclass?
Fri, 2004-12-10 16:34
Joined: 2004-05-29
Forum posts: 149
Active Objects not executing (for IMEI number)
Quote from: Eibwen
Is that code part of your Active Object?

No, the only active object is in the telephony class, that I presume is activated with the GetPhoneId call.  The method you see above is not in an active object at all.
Fri, 2004-12-10 17:12
Joined: 2004-05-21
Forum posts: 42
Active Objects not executing (for IMEI number)
Hi Eibwen,
I had the same problem with MobInfo.
(symbiandev.net: feedback.api / [MobInfo] CMobileInfo::GetIMSI(TMobileIMSI& aImsi, TRequestStatus& aStatus))

That api hangs too, if calling User::Wait...()
The only way is to "be" a ActiveObject.
You have to inherit from CActive and support a RunL() and all the other stuff.
A synchronous wait seems not be possible with MobInfo.
Don't know way, maybe a bug.
Perhaps it's the same feature in CTelephony Wink
--
Tobias
www.HBufC.com

Tobias.Stoeger

Fri, 2004-12-10 19:24
Joined: 2004-07-10
Forum posts: 364
Active Objects not executing (for IMEI number)
Hi
Is this code part of an app, exe, dll etc.?
If GetPhoneID() is using active objects and you don't have an active scheduler installed then it'll hang.

You're calling CActiveScuduler::RunIFReady() yet you say you're not using an active object, so what RunL are you trying to execute?

P.S.
What has flushing the window server buffer got to do with anything?
Fri, 2004-12-10 22:11
Joined: 2004-05-29
Forum posts: 149
Active Objects not executing (for IMEI number)
Quote from: mungbeans
Is this code part of an app, exe, dll etc.?
Part of an app

Quote
If GetPhoneID() is using active objects and you don't have an active scheduler installed then it'll hang.
Isn't there a "default" active scheduler?  CActiveScheduler::Current() is not NULL, so I figure there is one installed when any Symbian app is run. (I'm no expert though)

Quote
You're calling CActiveScuduler::RunIfReady() yet you say you're not using an active object, so what RunL are you trying to execute?
I was just trying a method to get the GetPhoneID()'s active object to finish.

Quote
What has flushing the window server buffer got to do with anything?
Just another method to try to get the active object in CTelephony to run.
Fri, 2004-12-10 22:12
Joined: 2003-11-12
Forum posts: 68
Active Objects not executing (for IMEI number)
Not sure if this is available in Series 80 or not but it seems to work fine in Series 60 and is very simple:

TPlpVariantMachineId imei;
PlpVariant::GetMachineIdL(imei);
Fri, 2004-12-10 22:41
Joined: 2004-07-10
Forum posts: 364
Active Objects not executing (for IMEI number)
Hi
Yes if its an app there should be an active scheduler installed for you as part of the framework stuff.

You won't be able to force it.

I'm sorry I don't know why its not completing if you call User::WaitForRequest(), though doing it this way will cause your app to appear to hang anyway so you might want to consider using an active object anyway.
Tue, 2005-03-08 01:04
Joined: 2005-02-17
Forum posts: 16
Active Objects not executing (for IMEI number)
For some reason User::WaitForRequest simply hangs on the CTelephony API (at least on the S80), but the following workaround uses a CActive object (found it on the developer library and modified it a little). Hope this helps someone:

//=============================================
// Filename: Phoneutils.h
//=============================================

#include <etel3rdparty.h>

/* Declare the client class */
class CIMEI : public CActive
{
public:
CIMEI();

// Construction
void ConstructL();

// Destruction
~CIMEI();

static CIMEI* NewL();

// Issue request: retrieve IMEI
void GetIMEI(TRequestStatus &aStatus);

// Cancel request
void DoCancel();

// Service completed request
void RunL();

private:
CTelephony* iTelephony; // telephony object we own
CTelephony::TPhoneIdV1 iV1;
CTelephony::TPhoneIdV1Pckg* iPkg;
TRequestStatus *iIMEIStatus;

public:
TBuf<50> retrievedIMEI;
};


/* Define the client class */

CIMEI::CIMEI() : CActive(EPriorityStandard) {}

CIMEI* CIMEI::NewL()
{
CIMEI* self =new(ELeave) CIMEI();
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(self);
return self;
}

void CIMEI::ConstructL()
{
iPkg = new (ELeave) CTelephony::TPhoneIdV1Pckg(iV1);
iTelephony = CTelephony::NewL();
CActiveScheduler::Add(this);
}

CIMEI::~CIMEI()
{
Cancel(); // if any request outstanding, calls DoCancel() to cleanup
delete iTelephony;
delete iPkg;
}

void CIMEI::GetIMEI(TRequestStatus& aStatus)
{
aStatus=KRequestPending;
iIMEIStatus = &aStatus;
iTelephony->GetPhoneId( iStatus, *iPkg );
SetActive();
CActiveScheduler::Start();
}

void CIMEI::RunL()
{
if ( (iStatus == KErrNone) )
{
retrievedIMEI = (*iPkg)().iSerialNumber; // Read IMEI from package buffer
}
CActiveScheduler::Stop();

//Signal complete and pass back result of CActive object
User::RequestComplete(iIMEIStatus,iStatus.Int());
}

void CIMEI::DoCancel()
{
Cancel();
}


//=============================================
// Filename: testapp.cpp
//=============================================
#include "Phoneutils.h"

void CTestApp::test()
{
CIMEI* imei = CIMEI::NewL();
CleanupStack::PushL(imei);

TRequestStatus status;
imei->GetIMEI(status);

// wait for request to complete
User::WaitForRequest(status);

// Check if IMEI retrieved correctly
if (status==KErrNone)
{
TBuf<50> imeistr(imei->retrievedIMEI);
CEikonEnv::Static()->InfoWinL(_L("IMEI:"),imeistr);
}
else
CEikonEnv::Static()->InfoWinL(_L("IMEI:"),_L("Error retrieving IMEI"));

CleanupStack::PopAndDestroy();
}
Mon, 2005-06-06 21:16
Joined: 2005-01-31
Forum posts: 4
Re: Active Objects not executing (for IMEI number)
Hi euroq,
I don't know why User::WaitForRequest(iStatus); isn't working, but I think I see a few problems with doing the RunIfReady. 
The active scheduler is a means of cooperative multitasking, which means you need to give the active scheduler some time to run.  By calling RunIfReady repeatedly, your request will never complete because the control never returns to the active scheduler for processing requests.  You can use User::WaitForAnyRequest() (which might have the same problems as User::WaitForRequest(iStatus)Wink in your loop so the active scheduler has time to do some proccessing.  I think User::After(timeInterval); can be used as well to give the active scheduler have some processing time (I've seen this in another post here, though the time interval should be large enough to allow some processing to be done). 
Anyway, I think that's how this works.  I've been using a WaitForAnyRequest/RunIfReady loop in a totally different application and I haven't found any problems with doing this. 
Good luck, I hope you find a solution.   Smiley

TnyLtSprGy
Sun, 2006-04-02 17:17
Joined: 2004-06-17
Forum posts: 47
Re: Active Objects not executing (for IMEI number)
Quote from: Arjen Broeze
the following workaround uses a CActive object (found it on the developer library and modified it a little). Hope this helps someone:


Hi,

where or at what point of my application can I use this?

It is e.g working perfectly in AppUI::HandleCommandL(), but never returns when called in AppUI::ConstructL()

Regards
lkz633
  • Login to reply to this topic.