×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    Apr 2009
    Posts
    442

    Unhappy KERN EXEC 3 Panic when try to call .pyd

    Hi

    I am writnig .Pyd(DLL) code. (using Symbian S60 3rd edition FP1 and Pys60 1.9.5).
    I attached .py file. From this file i call .pyd file.

    When i click on "Call DLL" from option menu emulator display panic
    KERN EXCE 3. Please help me where i am doing mistake? Please.

    Code:
    #include <e32std.h>
    #include <e32cmn.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <Python.h>
    #include <symbian_python_ext_util.h>
    
    #define MODULE_NAME sdk12graphics //:ulwp COMP_NAME
    #define MODULE_NAME_STRING "sdk12graphics" //:usp COMP_NAME.inspect
    #define MODULE_INIT_FUNC initsdk12graphics //:ulwp 'init' + COMP_NAME
    
    static PyObject *sdk12graphics_InitControlL(PyObject *self, PyObject *args);
    static int InitControlL(TPtrC& aUrl);
    
    static int InitControlL(TPtrC& aUrl)
    	{
    	return 1;
    	}
    
    static PyObject *sdk12graphics_InitControlL(PyObject *self, PyObject *args)
    	{
    	TInt error;	
    	char* b;
    	int l;
    	
    	if (!PyArg_ParseTuple(args, "u#", &b, &l))
    		{
    			//Py_INCREF(Py_None);
    			return SPyErr_SetFromSymbianOSErr(error); //Py_None;
    		}
    	
    	TPtrC aUrl((TUint16*)b, l);
    		
    	return Py_BuildValue("i",InitControlL(aUrl));
    	}
    
    static const PyMethodDef sdk12graphics_methods[] =
    {
    	{"initializecontroll", (PyCFunction)sdk12graphics_InitControlL, METH_VARARGS, "Returns a CObject with a CFbsBitmap*"},
    	{NULL, NULL} /* sentinel */
    };
    
    #define METHOD_TABLE const_cast<PyMethodDef*>(&sdk12graphics_methods[0])
    
    extern "C" {
    	DL_EXPORT(void) MODULE_INIT_FUNC(void)
    	{
    	// Add extra initialization here
    	PyObject* module = Py_InitModule(MODULE_NAME_STRING, METHOD_TABLE);
    	if (!module)
    		{
    		return;
    		}
    	}
    }
    
    #ifndef EKA2
    GLDEF_C TInt E32Dll(TDllReason)
    	{
    	return KErrNone;
    	}
    #endif
    .mmp File
    Code:
    TARGET		  _pythondll.pyd
    TARGETTYPE	  dll
    UID			 0x1000008d 0xEE402E33
    
    #ifdef EKA2
    CAPABILITY  NetworkServices LocalServices ReadUserData WriteUserData UserEnvironment
    #endif
    
    USERINCLUDE	 ..\inc
    SYSTEMINCLUDE   \epoc32\include 
    SYSTEMINCLUDE	\epoc32\include\libc
    SYSTEMINCLUDE   \epoc32\include\python
    
    TARGETPATH \system\libs
    
    nostrictdef
    
    LIBRARY		 euser.lib
    LIBRARY 	 fbscli.lib
    LIBRARY 	 estlib.lib
    LIBRARY		 python_appui.lib
    LIBRARY		 python222.lib
    LIBRARY		 python25.lib 
    LIBRARY      estlib.lib /* Necessary only if you use the C standard library */
    LIBRARY      apgrfx.lib 
    LIBRARY      eikcore.lib 
    LIBRARY      ws32.lib 
    LIBRARY      cone.lib
    
    #ifdef ENABLE_ABIV2_MODE
    DEBUGGABLE_UDEBONLY
    #endif
    
    SOURCEPATH	  ..\src
    SOURCE PythonDLL.cpp
    Regards,
    SymbianTH
    Attached Files Attached Files
    Last edited by SymbianTH; 2009-07-03 at 12:33. Reason: Forget attach a File

  2. #2
    Regular Contributor
    Join Date
    Apr 2009
    Posts
    442

    Re: KERN EXEC 3 Panic when try to call .pyd

    Hi

    I put my File in following path:
    _pythondll.pyd : C:\Symbian\9.2\S60_3rd_FP1\Epoc32\winscw\c\sys
    DetectSymbian : C:\Symbian\9.2\S60_3rd_FP1_4\Epoc32\winscw\c\Data\python

    My .Pyd File Code is:

    Code:
    from graphics import *
    
    import appuifw
    import e32
    
    class BabelFishUI(object):
        
        def __init__(self):
            
            self.__lock = e32.Ao_lock()
            self.__img = Image.new((176, 144))
            self.__language = 'it_en'
            self.__textUI = None
            
            appuifw.app.exit_key_handler = lambda:self.__lock.signal()
            
            appuifw.app.title = u'BabelFish v1.0'
            appuifw.app.body = self.__canvas = appuifw.Canvas(redraw_callback=self.updateScreen)
            
            appuifw.app.menu = [(u'Translate', lambda:self.__translateUI()), (u'Call DLL', lambda:self.__CallDLL()), (u'About', lambda:appuifw.note(u'BabelFish: v1.0", "Created by\nWhite Tiger\n<Z-TEAM@Libero.it>', 'info')), (u'Exit', lambda:self.__lock.signal)]
            
            self.updateScreen(None)
            
            self.__menuMain = appuifw.app.menu
            self.__bgMain = appuifw.app.body
            
            self.__lock.wait()
        
        def updateScreen(self, rect):
            
            self.__canvas.blit(self.__img)
    .
    .
    .
        def __CallDLL(self):
            
            if e32.pys60_version_info > (1,9):
                # PyS60 1.9.x and above
        		appuifw.note(u"1.9.x")
            else:
                # Pys60 1.4.x or below
                appuifw.note(u"1.4.x")
    
            #appuifw.note(u'CallDLL", " Now write code for call Symbian DLL', 'info')
            if e32.s60_version_info>=(3,0):
                # Symbian 9.0 way to import things
                import imp
                _pythondll=imp.load_dynamic('_pythondll', 'c:\\sys\\_pythondll.pyd')   
            else:
                # Old way
                import _pythondll
    .
    .
    .
       
    </BabelFishUI>
    
    if __name__ == '__main__':
        
        BabelFishUI()

  3. #3
    Regular Contributor
    Join Date
    Apr 2009
    Posts
    65

    Re: KERN EXEC 3 Panic when try to call .pyd

    This panic is raised when completing an outstanding request to a logical channel; the panic occurs when the request number is invalid. Specifically, the panic occurs in a call to the Complete() member function of a DLogicalChannel.

    Try making a standalone which calls the pyd and test on a real device. This panic is raised in debug builds only.
    --NirpSis

    http://sites.google.com/site/nirpsis/
    http://nirpsis.blogspot.com/

  4. #4
    Nokia Developer Expert
    Join Date
    Apr 2007
    Posts
    131

    Re: KERN EXEC 3 Panic when try to call .pyd

    Since you are developing an extension for PyS60 1.9.6, you should not link against `python222.lib`. Remove this entry from the MMP file. Also, wondering why you need to link against `python_appui.lib`.

  5. #5
    Nokia Developer Expert
    Join Date
    Apr 2007
    Posts
    131

    Re: KERN EXEC 3 Panic when try to call .pyd

    Also, the PYD name should be in a specific format: kf_<module_name>.pyd
    For example, if your module name is `sdk12graphics', the pyd name in the mmp file should be as follows:

    .MMP file
    Code:
    TARGET		kf_sdk12graphics.pyd
    Suggest you to take a look at the 'Extending and Embedding PyS60' chapter in the PyS60 documentation.

  6. #6
    Regular Contributor
    Join Date
    Apr 2009
    Posts
    442

    Re: KERN EXEC 3 Panic when try to call .pyd

    Quote Originally Posted by mahesh.sayibabu View Post
    Also, the PYD name should be in a specific format: kf_<module_name>.pyd
    For example, if your module name is `sdk12graphics', the pyd name in the mmp file should be as follows:

    .MMP file
    Code:
    TARGET		kf_sdk12graphics.pyd
    Suggest you to take a look at the 'Extending and Embedding PyS60' chapter in the PyS60 documentation.
    Hi
    Thank you for your response.

    I tested in Nokia E71x (3rd edition FP1) attached application code(example.sisx).

    I do that way which you suggest me look in example application
    but now give me an error named:
    "example=imp.load_dynamic('example','C:\\sys\\bin\\kf_example.pyd") ImportError:dlopen:Load failed"

    Please help me again.

    Regards,
    SymbianTH
    Attached Files Attached Files

  7. #7
    Nokia Developer Expert
    Join Date
    Apr 2007
    Posts
    131

    Re: KERN EXEC 3 Panic when try to call .pyd

    1. example.c, replace these lines

    Code:
    DL_EXPORT(void) initexample(void) {
    	Py_InitModule("example", example_methods);
    }
    with,
    Code:
    DL_EXPORT(void) initexample(void) {
    	Py_InitModule("_example", example_methods); //note the change in module name, basically it is better to name pyd and its wrapper (.py file) with different names.
    }
    2. example.mmp, replace
    Code:
    TARGET		kf_example.pyd
    TARGETPATH	\system\libs
    with

    Code:
    TARGET		kf__example.pyd // kf_<module_name>.pyd => kf__example.pyd
    // TARGETPATH	\system\libs    // Remove this entry, the pyd will be created in \epoc32\release\<platform>\<build>\
    3. example.py, you really don't need to import this way
    Code:
    if e32.s60_version_info>=(3,0):
        import imp
        example=imp.load_dynamic('example', 'c:\\sys\\bin\\kf_example.pyd')
        
    else:
        import example
    This is sufficient
    Code:
    import _example
    You also need to export the module init function at ordinal 1. Have a .def file for this purpose.
    Take a look at the example code of a simple extension module, elemlist present under extras\elemlist of PyS60 source tree.

  8. #8
    Regular Contributor
    Join Date
    Apr 2009
    Posts
    442

    Re: KERN EXEC 3 Panic when try to call .pyd

    Quote Originally Posted by mahesh.sayibabu View Post
    1. example.c, replace these lines

    Code:
    DL_EXPORT(void) initexample(void) {
    	Py_InitModule("example", example_methods);
    }
    with,
    Code:
    DL_EXPORT(void) initexample(void) {
    	Py_InitModule("_example", example_methods); //note the change in module name, basically it is better to name pyd and its wrapper (.py file) with different names.
    }
    2. example.mmp, replace
    Code:
    TARGET		kf_example.pyd
    TARGETPATH	\system\libs
    with

    Code:
    TARGET		kf__example.pyd // kf_<module_name>.pyd => kf__example.pyd
    // TARGETPATH	\system\libs    // Remove this entry, the pyd will be created in \epoc32\release\<platform>\<build>\
    3. example.py, you really don't need to import this way
    Code:
    if e32.s60_version_info>=(3,0):
        import imp
        example=imp.load_dynamic('example', 'c:\\sys\\bin\\kf_example.pyd')
        
    else:
        import example
    This is sufficient
    Code:
    import _example
    You also need to export the module init function at ordinal 1. Have a .def file for this purpose.
    Take a look at the example code of a simple extension module, elemlist present under extras\elemlist of PyS60 source tree.
    Hi

    Thanks for give me snippets and for your help.

    I have done all change as you told me but than also do not work this.

    When i type on interactive script
    >> import _example
    give me error like this name module not find in python25\python25.zip\...

    i tried with all commands like
    >> import _example
    >> import kf__example
    >> import __example

    but gives me same error. I tested on N73 also.

    Rgards,
    SymbianTH

  9. #9
    Nokia Developer Expert
    Join Date
    Apr 2007
    Posts
    131

    Re: KERN EXEC 3 Panic when try to call .pyd

    Strange!
    'import _example' should have worked. Hope the PYD is packaged and installed on the device.

    Try to compile and import elemlist module, present under extras\elemlist of PyS60 source tree. If this works, then you can easily modify it and add the functionality that you want your module to do.

  10. #10
    Regular Contributor
    Join Date
    Oct 2007
    Posts
    114

    Re: KERN EXEC 3 Panic when try to call .pyd

    Quote Originally Posted by SymbianTH View Post
    Hi

    Thanks for give me snippets and for your help.

    I have done all change as you told me but than also do not work this.

    When i type on interactive script
    >> import _example
    give me error like this name module not find in python25\python25.zip\...

    i tried with all commands like
    >> import _example
    >> import kf__example
    >> import __example

    but gives me same error. I tested on N73 also.

    Rgards,
    SymbianTH
    Check the capabilities of this example PYD. It should be equal or higher than that of ScriptShell.
    import antigravity

Similar Threads

  1. KERN EXEC 3 ERROR
    By sanjayks84 in forum Symbian User Interface
    Replies: 5
    Last Post: 2011-02-11, 07:16
  2. View server panic with 11 on draw
    By raj_rr7 in forum Symbian User Interface
    Replies: 7
    Last Post: 2009-05-18, 11:36
  3. KERN EXEC 3 on device not on Epoc
    By Kavit Patel in forum Symbian
    Replies: 4
    Last Post: 2008-11-21, 15:02
  4. Rfile and saving image file received in MHFRunL() of socket.. kern exec 0 panic
    By sanee in forum Symbian Networking & Messaging (Closed)
    Replies: 14
    Last Post: 2008-11-03, 09:14

Posting Permissions

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