You Are Here:

Community: Developer Discussion Boards

#1 Old Unhappy KERN EXEC 3 Panic when try to call .pyd - 2009-07-03, 13:28

Join Date: Apr 2009
Posts: 317
SymbianTH's Avatar
SymbianTH
Offline
Regular Contributor
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
File Type: txt DetectSymbian.txt (4.0 KB, 18 views)
Last edited by SymbianTH : 2009-07-03 at 13:33. Reason: Forget attach a File
Reply With Quote

#2 Old Re: KERN EXEC 3 Panic when try to call .pyd - 2009-07-03, 14:09

Join Date: Apr 2009
Posts: 317
SymbianTH's Avatar
SymbianTH
Offline
Regular Contributor
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()
Reply With Quote

#3 Old Re: KERN EXEC 3 Panic when try to call .pyd - 2009-07-04, 14:16

Join Date: Apr 2009
Posts: 65
nirpsis
Offline
Regular Contributor
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/
Reply With Quote

#4 Old Re: KERN EXEC 3 Panic when try to call .pyd - 2009-07-04, 18:20

Join Date: Apr 2007
Posts: 131
mahesh.sayibabu's Avatar
mahesh.sayibabu
Online
Regular Contributor
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`.
Reply With Quote

#5 Old Re: KERN EXEC 3 Panic when try to call .pyd - 2009-07-04, 18:53

Join Date: Apr 2007
Posts: 131
mahesh.sayibabu's Avatar
mahesh.sayibabu
Online
Regular Contributor
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.
Reply With Quote

#6 Old Re: KERN EXEC 3 Panic when try to call .pyd - 2009-07-06, 12:57

Join Date: Apr 2009
Posts: 317
SymbianTH's Avatar
SymbianTH
Offline
Regular Contributor
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
File Type: zip example.zip (18.5 KB, 29 views)
Reply With Quote

#7 Old Re: KERN EXEC 3 Panic when try to call .pyd - 2009-07-06, 19:41

Join Date: Apr 2007
Posts: 131
mahesh.sayibabu's Avatar
mahesh.sayibabu
Online
Regular Contributor
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.
Reply With Quote

#8 Old Re: KERN EXEC 3 Panic when try to call .pyd - 2009-07-08, 16:16

Join Date: Apr 2009
Posts: 317
SymbianTH's Avatar
SymbianTH
Offline
Regular Contributor
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
Reply With Quote

#9 Old Re: KERN EXEC 3 Panic when try to call .pyd - 2009-07-09, 08:51

Join Date: Apr 2007
Posts: 131
mahesh.sayibabu's Avatar
mahesh.sayibabu
Online
Regular Contributor
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.
Reply With Quote

#10 Old Re: KERN EXEC 3 Panic when try to call .pyd - 2009-07-09, 10:11

Join Date: Oct 2007
Posts: 114
ashwinurao
Offline
Regular Contributor
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
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
View server panic with 11 on draw raj_rr7 Symbian User Interface 7 2009-05-18 12:36
KERN EXEC 3 on device not on Epoc Kavit Patel General Symbian C++ 4 2008-11-21 16:02
Rfile and saving image file received in MHFRunL() of socket.. kern exec 0 panic sanee Symbian Networking & Messaging 14 2008-11-03 10:14
求助!显示GIF格式图像时出现 KERN EXEC 15的错误!急! allenliujiansong Symbian 2 2008-10-29 04:49
KERN EXEC 3 ERROR sanjayks84 Symbian User Interface 3 2008-05-28 10:13

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia