Multi threading Issue with CActive
| Wed, 2006-04-19 12:52 | |
|
|
Hi all, I'm developing an application which uses the MobInfo API. I'm threading this class using CActive. The problem is that I get Kern Exec - 3 whenever i try a File Write operation in the RunL() function. How do i resolve this??? Please help me out on this... Thanks... The Cruise is on... |






Forum posts: 982
pirosl
Forum posts: 37
i guess i forgot to mention that i get Error Reason 42 also... This error number as per SDL is raised for the CActiveScheduler. It talks of a Stray Signal.
Anyways, I would like to rephrase my question once again...
I'm writing a UIQ application which would do these things:
1. I want a thread / Active Object running which will monitor the Etel Server for an Incoming / Outgoing call.
>>>This I'm successful in coding...
2. Once an Incoming / Outgoing call is attended, i want to start another thread / AO which would link to the MobInfo library and extract network parameters like MCC, MNC, LAC ID etc...
3. These parameters are to be written into a file say NetworkLog.txt...
I'm trying to on a very broad perspective, trying to implement Celltrack kind of functionality only during the period of Incoming / Outgoing calls...
What I'm able to do is to create 1 UIQ app ui class where this is happening individually on 2 menu selections...
When i try to put them together... I'm facing errors 42, 71 and Kern Exec - 3.
How do you people suggest I do the threading / active object scheduling of this app???
Eventually i want this to be made into a Dll / Exe which will run on boot and keep monitoring continuously...
I'm developing on UIQ 2.1 for Sony Ericsson P900.
I would love to see some suggestions on having this run neatly...
Thanks...
The Cruise is on...
Forum posts: 982
have 2 ao....the first one issue a request to monitor the phone. When the request is complete (eg. incoming/outgoing call) the ao's run method is called....from this method your second ao will issue a request....at completion its run method will be invoked.
Have i missed smth?
If you error is EUser42, it is raised by SetActive....and the problem is that you want to set as active an ao which is already active......so check again your code.
pirosl
Forum posts: 37
I've posted the code file that i had written previous to our talk... This is causing a Kern Exec - 3 Error... This error too comes only during closing the appilcation...
The Text file is created but Write Fails...
What am I doing Wrong over here???
* ============================================================================
* Name : Phoneobserver.cpp
* Part of : Callengine
* ===========================================================================
*/
//INCLUDES
#include <e32base.h>
#include <e32std.h>
#include <etel.h>
#include "CallEngine.h"
#include "phoneobserver.h"
#include <f32file.h>
#include <s32file.h>
#ifndef __WINS__
_LIT(KLog_try2, "c:\\Log_try2.txt");
#else
_LIT(KLog_try2, "c:\\Log_try2.txt");
#endif
// ---------------------------------------------------------
// CPhoneObserver::CPhoneObserver()
// C++ default constructor
// ---------------------------------------------------------
CPhoneObserver::CPhoneObserver(): CActive(EPriorityStandard)
{
}
// ---------------------------------------------------------
// CPhoneObserver::~CPhoneObserver()
// C++ destructor
// ---------------------------------------------------------
CPhoneObserver::~CPhoneObserver()
{
Cancel();
}
// ---------------------------------------------------------
// CPhoneObserver::NewL()
// Two phase constructor
// ---------------------------------------------------------
CPhoneObserver* CPhoneObserver::NewL(CCallEngineAppUi* aAppUi, RLine* aLine)
{
CPhoneObserver* self = NewLC(aAppUi, aLine);
CleanupStack::Pop(self);
return self;
}
// ---------------------------------------------------------
// CPhoneObserver::NewLC()
// ---------------------------------------------------------
CPhoneObserver* CPhoneObserver::NewLC(CCallEngineAppUi* aAppUi, RLine* aLine)
{
CPhoneObserver* self = new (ELeave) CPhoneObserver();
CleanupStack::PushL(self);
self->ConstructL(aAppUi, aLine);
self->Start();
return self;
}
// ---------------------------------------------------------
// CPhoneObserver::RunL()
// Called by active object framework when line event occurs
// ---------------------------------------------------------
void CPhoneObserver::RunL()
{
if (iStatus.Int() == KErrNone)
{
if (iLineStatus == RCall::EStatusRinging)
{
{
RFs fileSession;
User::LeaveIfError(fileSession.Connect());
CleanupClosePushL(fileSession);
RFile file;
TBuf8<30> KWriteDat1;
KWriteDat1=iStatus.Int();
file.Create(fileSession,KLog_try2,EFileWrite|EFileRead );
CleanupClosePushL(file);
file.Write(KWriteDat1);
CleanupStack::PopAndDestroy();
CleanupStack::PopAndDestroy();
}
}
else if (iLineStatus == RCall::EStatusAnswering)
{
{
RFs fileSession;
User::LeaveIfError(fileSession.Connect());
CleanupClosePushL(fileSession);
RFile file;
TBuf8<30> KWriteDat;
KWriteDat=iStatus.Int();
file.Create(fileSession,KLog_try2,EFileWrite|EFileRead );
CleanupClosePushL(file);
file.Write(KWriteDat);
CleanupStack::PopAndDestroy();
CleanupStack::PopAndDestroy();
}
}
Start();
}
else
{
Cancel();
}
}
// ---------------------------------------------------------
// CPhoneObserver::RunError()
// Called by active object framework when error occurs
// ---------------------------------------------------------
TInt CPhoneObserver::RunError(TInt Error)
{
return Error;
}
// ---------------------------------------------------------
// CPhoneObserver::DoCancel()
// Cancels active objects callback request
// ---------------------------------------------------------
void CPhoneObserver::DoCancel()
{
iLine -> NotifyStatusChangeCancel();
}
// ---------------------------------------------------------
// CPhoneObserver::ConstructL()
//
// ---------------------------------------------------------
void CPhoneObserver::ConstructL(CCallEngineAppUi* aAppUi, RLine* aLine)
{
iAppUi = aAppUi;
iLine = aLine;
CActiveScheduler::Add(this);
}
// ---------------------------------------------------------
// CPhoneObserver::Start()
// Active object is activated
// ---------------------------------------------------------
void CPhoneObserver::Start()
{
Cancel();
iLine -> NotifyStatusChange(iStatus, iLineStatus);
SetActive();
}
// ---------------------------------------------------------
// CPhoneObserver::Deactivate()
// Active object is canceled outside of this class.
// ---------------------------------------------------------
void CPhoneObserver::Deactivate()
{
DoCancel();
}
// End of File
The Cruise is on...
Forum posts: 98
KWriteDat1.Copy(_L("Status="));
KWriteDat1.AppendNum(iStatus.Int());
AddDebugMessage(KWriteDat1);
void YourClass::AddDebugMessage(const TDesC& aMessage)
{
TBuf8<200>buf8;
buf8.Copy(aMessage);
TFileName iFullPath ;
iFullPath.Append(_L("C:\\debug.txt"));
RFs iFs;
RFile myFile;
User::LeaveIfError(iFs.Connect());
if(!BaflUtils::FileExists(iFs,iFullPath))
User::LeaveIfError(myFile.Create(iFs,iFullPath,EFileWrite));
else
User::LeaveIfError(myFile.Open(iFs,iFullPath,EFileWrite));
TInt endpos;
myFile.Size(endpos);
myFile.Seek(ESeekStart,endpos);
myFile.Write(endpos,buf8);
myFile.Close();
iFs.Close();
}
Forum posts: 982
pirosl
Forum posts: 37
I've sorted out all the errors as per the ideas you gave yesterday.
Now i've got only one issue... The network data is not getting written to the file....
This has caught up most of the time today...
Do help me on this....
The Cruise is on...
Forum posts: 982
pirosl
Forum posts: 37
How do i resolve both the issues
The Cruise is on...
Forum posts: 982
pirosl
Forum posts: 37
THis is my file writing code...
{
RFs fileSession;
RFile file;
if(!BaflUtils::FileExists(fileSession,KLog_try3))
{
User::LeaveIfError(file.Create(fileSession,KLog_try3,EFileWrite));
CleanupClosePushL(fileSession);
}
else
{
User::LeaveIfError(file.Open(fileSession,KLog_try3,EFileWrite));
CleanupClosePushL(file);
}
file.Write(iAppView->Nw_Buf);
CleanupStack::PopAndDestroy();
CleanupStack::PopAndDestroy();
}
Tell me where i'm wrong.....
The Cruise is on...
Forum posts: 982
pirosl
Forum posts: 98
if(buffer.Length()==0)
file.Write(_L8("Empty Buffer"));
Forum posts: 37
It does not write anything..... even thougth the buffer has data...
Even if the buffer is actually empty, it's gotta write the _L8("Empty Buffer")...
Thats not happening too...
The file's perfectly created.... I have a file called NwLog.txt in C drive but it has no data on it...
I'm having a vague guess that this is happening cause of some mixup in my active scheduler code...  But i'm not too sure about this as the whole application runs very smoothly and doesnt throw panics or errors at any point of time during it's run...
Can someone tell me what's happening???
The Cruise is on...
Forum posts: 140
If the file fails to be created then the file handle will not be valid.
I suggest you check the return code from file.Create.
Paul Todd