×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Regular Contributor
    Join Date
    Mar 2009
    Location
    Strasbourg - France
    Posts
    110

    Panic E32USER-CBase 42 / RecvFrom

    Hi everybody

    I have a problem, I'm programming a UDP server for Symbian S60 5th.
    When I add this line :
    Code:
    iSocket.RecvFrom(iBuffer,IRremoteAddress,0,Status);
    SetActive();
    I have a "Panic E32USER-CBase 42" error
    My class derives from CActive Object, could you help me ?
    Regards and Peace.

    Cartouche67.

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: Panic E32USER-CBase 42 / RecvFrom

    Class CActive has datamember called iStatus, so use that member instead of local variable (Status).

    Also before issueing request, check if any request is still outstanding.

  3. #3
    Regular Contributor
    Join Date
    Mar 2009
    Location
    Strasbourg - France
    Posts
    110

    Re: Panic E32USER-CBase 42 / RecvFrom

    yes sorry, this is a typing error, I have iStatus and not Status

    I don't think a request is outstanding, my class is very basic, I put in bold my modification from the template class

    Code:
    /*
     ============================================================================
     Name		: RTPTestUDP.cpp
     Author	  : 
     Version	 : 1.0
     Copyright   : 
     Description : CRTPTestUDP implementation
     ============================================================================
     */
    
    #include "RTPTestUDP.h"
    #include "logfile.h"
    
    CRTPTestUDP::CRTPTestUDP() :
    	CActive(EPriorityStandard) // Standard priority
    	{
    	}
    
    CRTPTestUDP* CRTPTestUDP::NewLC()
    	{
    	CRTPTestUDP* self = new (ELeave) CRTPTestUDP();
    	CleanupStack::PushL(self);
    	self->ConstructL();
    	return self;
    	}
    
    CRTPTestUDP* CRTPTestUDP::NewL()
    	{
    	CRTPTestUDP* self = CRTPTestUDP::NewLC();
    	CleanupStack::Pop(); // self;
    	return self;
    	}
    
    void CRTPTestUDP::ConstructL()
    	{
    	User::LeaveIfError(iTimer.CreateLocal()); // Initialize timer
    	CActiveScheduler::Add(this); // Add to scheduler
    	
    	LFPRINT((_L("TestUDP : 0")));	
    	User::LeaveIfError(session.Connect());
    		
    	LFPRINT((_L("TestUDP : 0 bis")));
    	User::LeaveIfError(iSocket.Open(session, KAfInet,KSockDatagram, KProtocolInetUdp));	
    	}
    
    CRTPTestUDP::~CRTPTestUDP()
    	{
    	Cancel(); // Cancel any request, if outstanding
    	iTimer.Close(); // Destroy the RTimer object
    	// Delete instance variables if any
    	}
    
    void CRTPTestUDP::DoCancel()
    	{
    	iTimer.Cancel();
    	}
    
    void CRTPTestUDP::StartL(TTimeIntervalMicroSeconds32 aDelay)
    	{
    	Cancel(); // Cancel any request, just to be sure
    	iState = EUninitialized;
    	iTimer.After(iStatus, aDelay); // Set for later
    		
    				
    	LFPRINT((_L("TestUDP : 1")));	
    	iAddress.SetPort(6666);
    	iAddress.SetAddress(INET_ADDR(127,0,0,1));
    	
    	//LFPRINT((_L("TestUDP : 1bis")));
    	//iRemoteAddress.SetPort(6667);
    	//iRemoteAddress.SetAddress(INET_ADDR(127,0,0,1));
    	
    	LFPRINT((_L("TestUDP : 2")));	
    	User::LeaveIfError(iSocket.Bind(iAddress));
    	
    	LFPRINT((_L("TestUDP : 3")));
    	RecvL();
    	SetActive(); // Tell scheduler a request is active
    	}
    
    void CRTPTestUDP::RecvL()
    	{
    	if(!IsActive()){
    		iSocket.RecvFrom(iBuffer,iRemoteAddress,0,iStatus);
    		SetActive(); // Tell scheduler a request is active
    	}
    	}
    
    void CRTPTestUDP::SendL()
    	{
    	/*LFPRINT((_L("TestUDP : 4")));
    	_LIT8(KDATA,"it works");
    	iSocket.SendTo(KDATA,iRemoteAddress,0,iStatus);
    	LFPRINT((_L("TestUDP : 5")));*/
    	}
    
    
    void CRTPTestUDP::RunL()
    	{
    	LFPRINT((_L("RTPTestUDP : paquet recu")));
    	if (iState == EUninitialized)
    		{
    		// Do something the first time RunL() is called
    		iState = EInitialized;
    		}
    	else if (iState != EError)
    		{
    		// Do something
    		}
    	iTimer.After(iStatus, 1000000); // Set for 1 sec later
    	SetActive(); // Tell scheduler a request is active
    	}
    
    void CRTPTestUDP::Close()
    	{
    	iSocket.Close();
    	session.Close();
    	}
    
    TInt CRTPTestUDP::RunError(TInt aError)
    	{
    	return aError;
    	}
    Regards and Peace.

    Cartouche67.

  4. #4
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: Panic E32USER-CBase 42 / RecvFrom

    Code:
    void CRTPTestUDP::StartL(TTimeIntervalMicroSeconds32 aDelay)
    	{
    	Cancel(); // Cancel any request, just to be sure
    	iState = EUninitialized;
    	iTimer.After(iStatus, aDelay); // Set for later
    		
    				
    	
    	RecvL();
    	SetActive(); // Tell scheduler a request is active
    	}
    
    void CRTPTestUDP::RecvL()
    	{
    	if(!IsActive()){
    		iSocket.RecvFrom(iBuffer,iRemoteAddress,0,iStatus);
    		SetActive(); // Tell scheduler a request is active
    	}
    	}

    You are trying issue two request at a time one active object, issue second request if no pending request is there. Also Call SetActive() just after issuing asynchronous request.

  5. #5
    Regular Contributor
    Join Date
    Mar 2009
    Location
    Strasbourg - France
    Posts
    110

    Re: Panic E32USER-CBase 42 / RecvFrom

    Thanks you very much savaj, now it works.

    I have another question, I put
    Code:
    LFPRINT((_L("RTPTestUDP : paquet recu")));
    in RunL, and in my log I found this line 8 times per seconds, is it normal ? First I wanted trigger an action on a reception .
    Regards and Peace.

    Cartouche67.

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,694

    Re: Panic E32USER-CBase 42 / RecvFrom

    Actually it is you who should know what your code is supposed to do.

  7. #7
    Regular Contributor
    Join Date
    Mar 2009
    Location
    Strasbourg - France
    Posts
    110

    Re: Panic E32USER-CBase 42 / RecvFrom

    Sure, I just see what's
    Code:
    iTimer.After(iStatus, aDelay);
    do (it's set by default in active class), I commented it because I want RunL is called only when an event occurs.

    But I don't see how I can differentiate which event happend when RunL is called.
    Regards and Peace.

    Cartouche67.

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,694

    Re: Panic E32USER-CBase 42 / RecvFrom

    You can not differentiate, and you should not be able to, because there must not be anything to differentiate.
    A single active object have a single iStatus member variable, which can wait for a single event. You must not pass iStatus to some service if you are already waiting for an other one, that is what E32USER-CBase 42 is about (because you always have to invoke SetActive after you have passed iStatus to an asyncronous service provider).

  9. #9
    Super Contributor
    Join Date
    Mar 2004
    Location
    Bangalore,India
    Posts
    2,146

    Re: Panic E32USER-CBase 42 / RecvFrom

    Well if you are doing multiple things one after the other or something on the same AO, then you would do well to implement a state machine by using a locally defined enum, for instance

    typedef enum
    {
    ETask1,
    ETask2,
    } YourEnum;

    in the .h file

    YourEnum iAppState;

    before calling the code that could trigger RunL,

    Set the enum to the desired value, iAppState = ETask1

    and then in the RunL you can check

    if(iAppState == ETask1)
    {
    // Fire AO request for Task2 or something
    }
    else if(iAppState == ETask2)
    {
    // Do what u want to do with task 2 completion
    }

    So on and so forth..

    Cheers,
    Mayank

    P.S. Make sure to check IsActive() before calling the SetActive() to be doubly sure unless you are following a clearly well defined state machine.

  10. #10
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,694

    Re: Panic E32USER-CBase 42 / RecvFrom

    The state machine is a good idea indeed.
    Quote Originally Posted by mayankkedia View Post
    P.S. Make sure to check IsActive() before calling the SetActive() to be doubly sure unless you are following a clearly well defined state machine.
    However this one is not necessarily a good one, one can rarely benefit from checking IsActive:
    - if he expect IsActive to return EFalse, and it happens to return ETrue, the code is already doomed, since something is wrong. An immediate E32USER-CBase 42 is far easier to find than a delayed stray signal caused by a conditional SetActive
    - if someone knows that the object may already wait for something, and it is considered OK, an unconditional Cancel should be invoked (since Cancel checks IsActive internally).

    In fact the latter case is still questionable a bit, since the original request obviously has a purpose, so it has to be justified why it is not important any more. Personally this is why I do not like the Chat example, because beginners do not necessarily see how it really works.

  11. #11
    Super Contributor
    Join Date
    Mar 2004
    Location
    Bangalore,India
    Posts
    2,146

    Re: Panic E32USER-CBase 42 / RecvFrom

    Quote Originally Posted by wizard_hu_ View Post
    The state machine is a good idea indeed.However this one is not necessarily a good one, one can rarely benefit from checking IsActive:
    - if he expect IsActive to return EFalse, and it happens to return ETrue, the code is already doomed, since something is wrong. An immediate E32USER-CBase 42 is far easier to find than a delayed stray signal caused by a conditional SetActive
    - if someone knows that the object may already wait for something, and it is considered OK, an unconditional Cancel should be invoked (since Cancel checks IsActive internally).

    In fact the latter case is still questionable a bit, since the original request obviously has a purpose, so it has to be justified why it is not important any more. Personally this is why I do not like the Chat example, because beginners do not necessarily see how it really works.
    I have to agree with you on this, and generally how I do AO state machines are, I just fire one Async call from outside the RunL and then all my subsequent requests are made from the RunL on successful completion of the previous one, thereby ensuring I dont end up queueing more then one async request on the same AO.

    Cheers,
    Mayank
    P.S. However I have seen tonnes of code released by Nokia/Symbian where they do IsActive(), SetActive() combinations :-)

  12. #12
    Regular Contributor
    Join Date
    Mar 2009
    Location
    Strasbourg - France
    Posts
    110

    Re: Panic E32USER-CBase 42 / RecvFrom

    Thank you very much wizard_hu_ and mayankkedia, the state machine is exaclty what I want.
    I think I don't get it all you said but I have the principal. Thanks!
    Regards and Peace.

    Cartouche67.

Similar Threads

  1. Panic USER 42: how it is here ???
    By KhaledMahmood in forum Symbian Networking & Messaging (Closed)
    Replies: 10
    Last Post: 2010-01-25, 14:26
  2. E32User CBase panics....
    By raj8nokiaforum in forum Symbian
    Replies: 19
    Last Post: 2008-10-17, 08:25
  3. regarding E32USER CBase 42
    By arumilli in forum Symbian
    Replies: 15
    Last Post: 2008-06-26, 20:12
  4. Using Bluetooth serial port in MIDlets (nokia 9500 issue)
    By orsteglasy in forum Mobile Java Networking & Messaging & Security
    Replies: 11
    Last Post: 2007-10-07, 21:49
  5. opendir panic in thread with error CBase 69
    By baumannpan in forum Symbian
    Replies: 1
    Last Post: 2007-03-26, 10:16

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×