×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Modules required :)

    Hi,

    I'm looking for the following functionalities available under PyS60:

    a) determine the RX quality for a GSM location provided by location.gsm_location()
    b) determine whether the phone is currently charged or runs herat battery.

    Is anybody aware of those modules?

    Regards

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Modules required :)

    Quote Originally Posted by neil.young View Post
    b) determine whether the phone is currently charged or runs herat battery.
    You can determine the current charge level using sysinfo.battery(). You can determine whether the phone is currently charging using the sysagent extension (with the function charger_status()). What's "herat battery"?

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: Modules required :)

    Quote Originally Posted by bogdan.galiceanu View Post
    You can determine the current charge level using sysinfo.battery(). You can determine whether the phone is currently charging using the sysagent extension (with the function charger_status()). What's "herat battery"?
    Hi bogdan,

    thanks for the answer. herat is nothing more than a big, fat typo I already found sysagent_module, but the charger and battery stuff is no longer part of the sysagent_2008_3rd_release..... I have found an older version of sysagent, which seems to have the charger thing in, but I don't have an installer for S60 3rd...

    Regards

  4. #4
    Regular Contributor
    Join Date
    Jul 2007
    Location
    Eindhoven, the Netherlands
    Posts
    187

    Re: Modules required :)

    Hi Neil,

    I ran into similar problems, so for retrieving battery & charger status information, I wrote a little extension, it is not mature, but for a simple fetching of the battery & charger status it works fine. It is called properties.sis, and you can find it here: http://code.google.com/p/tracker-py/downloads/list

    Usage:
    Code:
    from properties import *
    
    def GetChargerStatus():
        return GetInt(KPSUidHWRMPowerState,KHWRMChargingStatus)
    
    print GetChargerStatus()
    More info can be found here: http://code.google.com/p/tracker-py/.../properties.py


    Regards,
    Mark.

  5. #5
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: Modules required :)

    Thanks Mark, I guess I have to opensign it ?

    Regards

  6. #6
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: Modules required :)

    Hi Mark,
    I opensigned and installed it fine. Trying to use it

    from properties import *

    gives import error. No module named properties.

    Are u sure with the sis?

    It contains a resource dir, containing a subdir named "Python25", herein properties.py. The second dir is sys/bin containing kf__properties.pyd.

    I'm not sure with the "Python25"...

    Regards

  7. #7
    Regular Contributor
    Join Date
    Jul 2007
    Location
    Eindhoven, the Netherlands
    Posts
    187

    Re: Modules required :)

    Quote Originally Posted by neil.young View Post
    Hi Mark,
    It contains a resource dir, containing a subdir named "Python25", herein properties.py. The second dir is sys/bin containing kf__properties.pyd.
    I'm not sure with the "Python25"...
    Oh, I forgot to mention, this sis was build for python 1.9.4.

    I don't have 1.4.x installed anymore, but if you feel bold you could probably build it for 1.4.5 yourself using the sources
    that can be found here: http://code.google.com/p/tracker-py/...unk/properties .
    (I do have some problems with the subscribe function currently, so best to use version 484 where subscribe is disabled)
    Make the following changes in the properties_3rd.mmp file:
    line 14: Replace python25 with python
    line 16: Replace python25.lib with python222.lib

    Once I get the subscribe function working properly, I'll do a proper release for 1.9.x and 1.4.x.


    Regards,
    Mark.

  8. #8
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: Modules required :)

    Quote Originally Posted by hurenkam View Post
    Oh, I forgot to mention, this sis was build for python 1.9.4.

    I don't have 1.4.x installed anymore, but if you feel bold you could probably build it for 1.4.5 yourself using the sources
    that can be found here: http://code.google.com/p/tracker-py/...unk/properties .
    (I do have some problems with the subscribe function currently, so best to use version 484 where subscribe is disabled)
    Make the following changes in the properties_3rd.mmp file:
    line 14: Replace python25 with python
    line 16: Replace python25.lib with python222.lib

    Once I get the subscribe function working properly, I'll do a proper release for 1.9.x and 1.4.x.


    Regards,
    Mark.
    Hmm. I'm currently not having a C++ environment here. What would be required? Carbide?

  9. #9
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: Modules required :)

    I'm trying to compile your module using Carbide++ This is the errors, I'm getting:


    Creation Time Description Resource Path Location Type
    1243807030698 the file 'Python.h' cannot be opened[C:\Symbian\9.1\S60_3rd_MR\Epoc32\include\python\symbian_python_ext_util.h] properties_3rd line 26 C/C++ Problem
    1243807030727 undefined identifier 'PyObject'[C:\Symbian\9.1\S60_3rd_MR\Epoc32\include\python\symbian_python_ext_util.h] properties_3rd line 37 C/C++ Problem
    1243807030753 undefined identifier 'DL_IMPORT'[C:\Symbian\9.1\S60_3rd_MR\Epoc32\include\python\symbian_python_ext_util.h] properties_3rd line 38 C/C++ Problem
    1243807030782 declaration syntax error[C:\Symbian\9.1\S60_3rd_MR\Epoc32\include\python\symbian_python_ext_util.h] properties_3rd line 39 C/C++ Problem
    1243807030811 declaration syntax error[C:\Symbian\9.1\S60_3rd_MR\Epoc32\include\python\symbian_python_ext_util.h] properties_3rd line 40 C/C++ Problem
    1243807030840 ')' expected[C:\Symbian\9.1\S60_3rd_MR\Epoc32\include\python\symbian_python_ext_util.h] properties_3rd line 41 C/C++ Problem
    1243807030869 ')' expected[C:\Symbian\9.1\S60_3rd_MR\Epoc32\include\python\symbian_python_ext_util.h] properties_3rd line 42 C/C++ Problem
    1243807030897 declaration syntax error[C:\Symbian\9.1\S60_3rd_MR\Epoc32\include\python\symbian_python_ext_util.h] properties_3rd line 43 C/C++ Problem
    1243807030927 declaration syntax error[C:\Symbian\9.1\S60_3rd_MR\Epoc32\include\python\symbian_python_ext_util.h] properties_3rd line 44 C/C++ Problem
    1243807030957 declaration syntax error[C:\Symbian\9.1\S60_3rd_MR\Epoc32\include\python\symbian_python_ext_util.h] properties_3rd line 46 C/C++ Problem
    1243807030989 declaration syntax error[C:\Symbian\9.1\S60_3rd_MR\Epoc32\include\python\symbian_python_ext_util.h] properties_3rd line 47 C/C++ Problem
    1243807031017 declaration syntax error[C:\Symbian\9.1\S60_3rd_MR\Epoc32\include\python\symbian_python_ext_util.h] properties_3rd line 48 C/C++ Problem
    1243807031042 ')' expected[C:\Symbian\9.1\S60_3rd_MR\Epoc32\include\python\symbian_python_ext_util.h] properties_3rd line 49 C/C++ Problem
    1243807031072 undefined identifier 'Py_XINCREF' properties.cpp properties_3rd line 52 C/C++ Problem
    1243807031102 undefined identifier 'PyGILState_STATE' properties.cpp properties_3rd line 70 C/C++ Problem
    1243807031132 undefined identifier 'state' properties.cpp properties_3rd line 71 C/C++ Problem
    1243807031165 undefined identifier 'PyObject_CallObject' properties.cpp properties_3rd line 72 C/C++ Problem
    1243807031196 undefined identifier 'Py_XDECREF' properties.cpp properties_3rd line 75 C/C++ Problem
    1243807031227 undefined identifier 'Py_XDECREF' properties.cpp properties_3rd line 77 C/C++ Problem
    1243807031259 undefined identifier 'state' properties.cpp properties_3rd line 79 C/C++ Problem
    1243807031289 undefined identifier 'PyArg_ParseTuple' properties.cpp properties_3rd line 97 C/C++ Problem
    1243807031318 undefined identifier 'SPyErr_SetFromSymbianOSErr' properties.cpp properties_3rd line 102 C/C++ Problem
    1243807031347 undefined identifier 'Py_None' properties.cpp properties_3rd line 102 C/C++ Problem
    1243807031384 undefined identifier 'PyArg_ParseTuple' properties.cpp properties_3rd line 114 C/C++ Problem
    1243807031414 undefined identifier 'Py_BuildValue' properties.cpp properties_3rd line 118 C/C++ Problem
    1243807031446 undefined identifier 'PyArg_ParseTuple' properties.cpp properties_3rd line 128 C/C++ Problem
    1243807031476 undefined identifier 'SPyErr_SetFromSymbianOSErr' properties.cpp properties_3rd line 133 C/C++ Problem
    1243807031506 undefined identifier 'Py_None' properties.cpp properties_3rd line 133 C/C++ Problem
    1243807031535 undefined identifier 'PyArg_ParseTuple' properties.cpp properties_3rd line 144 C/C++ Problem
    1243807031564 undefined identifier 'SPyErr_SetFromSymbianOSErr' properties.cpp properties_3rd line 149 C/C++ Problem
    1243807031596 undefined identifier 'Py_None' properties.cpp properties_3rd line 149 C/C++ Problem
    1243807031629 undefined identifier 'PyArg_ParseTuple' properties.cpp properties_3rd line 162 C/C++ Problem
    1243807031659 undefined identifier 'PyCallable_Check' properties.cpp properties_3rd line 165 C/C++ Problem
    1243807031691 undefined identifier 'PyExc_TypeError' properties.cpp properties_3rd line 167 C/C++ Problem
    1243807031721 undefined identifier 'SPyErr_SetFromSymbianOSErr' properties.cpp properties_3rd line 174 C/C++ Problem
    1243807031755 undefined identifier 'Py_None' properties.cpp properties_3rd line 174 C/C++ Problem
    1243807031813 ';' expected properties.cpp properties_3rd line 179 C/C++ Problem
    1243807031844 declaration syntax error properties.cpp properties_3rd line 186 C/C++ Problem
    1243807031921 undefined identifier 'DL_EXPORT' properties.cpp properties_3rd line 189 C/C++ Problem
    1243807031952 declaration syntax error properties.cpp properties_3rd line 190 C/C++ Problem
    1243807031981 declaration syntax error properties.cpp properties_3rd line 193 C/C++ Problem


    Any ideas? UIKludges did compile fine.

  10. #10
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: Modules required :)

    No, your module doesn't run with 1.4.5. If you are interested in details, let me know.
    Regards

  11. #11
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: Modules required :)

    Could it be possible, that all of the so called "tutorials" (esp.Cyke's, Croozeu's) is outdated, erroneous and doesn't work any longer (if it ever did work?) I mean, I was just following exactly what was described here: http://wiki.opensource.nokia.com/pro...ing_extensions

    and interestingly, this was the ONLY tutorial of all those Forum Nokia Champs, which really worked ... until I was trying it on my phone. Complilation/Link/Opensign - everything perfect. Run it on the phone (N82) - bang...

    Here is the test sequence:


    Code:
    import e32
    import urllib
    
    import uikludges
    
    def test_softkey():
        uikludges.set_right_softkey_text(u"Back")
    
    test_softkey()
    and here is the glorious result:

    Code:
    Connected.          
    Python 2.2.2 (#0, Jun 10 2008, 15:05:00) [C] on symbian_s60                                                           
    Type "copyright", "credits" or "license" for more information.                                                              
    Type "commands" to see the commands available in this simple line editor.                                                                         
    >>> import e32              
    >>> import urllib                 
    >>>   
    >>> import uikludges                    
    Traceback (most recent call last):
      File "<console>", line 1, in ?
      File "c:\resource\site.py", line 97, in platsec_import
        return _original_import(name, globals, locals, fromlist)
      File "c:\resource\uikludges.py", line 5, in ?
        _uikludges=imp.load_dynamic('_uikludges', 'c:\\sys\\bin\\_uikludges.pyd')
    SymbianError: [Errno -46] KErrPermissionDenied
    >>>
    >>> def test_softkey():
    ...     uikludges.set_right_softkey_text(u"Back")
    ...
    >>> test_softkey()
    Traceback (most recent call last):
      File "<console>", line 1, in ?
      File "<console>", line 2, in test_softkey
    NameError: global name 'uikludges' is not defined
    >>>
    >>>
    >>> import uikludges
    >>> uikludges.set_right_softkey_text("HUHU")
    Traceback (most recent call last):
      File "<console>", line 1, in ?
    AttributeError: 'module' object has no attribute 'set_right_softkey_text'
    >>>

    And - yes, of course, my bad, my bad...

  12. #12
    Regular Contributor
    Join Date
    Jul 2007
    Location
    Eindhoven, the Netherlands
    Posts
    187

    Re: Modules required :)

    Quote Originally Posted by neil.young View Post
    I'm trying to compile your module using Carbide++ This is the errors, I'm getting:
    Hmm, that's a lot more problems than I had expected...
    Not sure if it would help, but you could try leaving out the X in Py_XDECREF & Py_XINCREF, I'm not sure if
    those macros existed in prior versions of python. In most cases Py_DECREF & Py_INCREF will do fine as well.

    Quote Originally Posted by neil.young View Post
    1243807031102 undefined identifier 'PyGILState_STATE' properties.cpp properties_3rd line 70 C/C++ Problem
    1243807031132 undefined identifier 'state' properties.cpp properties_3rd line 71 C/C++ Problem
    These at least can be explained, it is due to the different behaviour between python 1.4.x and 1.9.x.

    To solve this replace (in line 70/71):
    Code:
    PyGILState_STATE state;     
    state = PyGILState_Ensure();
    With:
    Code:
    PyEval_RestoreThread(PYTHON_TLS->thread_state);
    And replace (in line 79):
    Code:
    PyGILState_Release(state);
    With:
    Code:
    PyEval_SaveThread();
    (I doubt it will solve all listed problems though...)

    I notice you are using latest CVS, I currently have problems whith that version. To get it to work comment out lines 16-85, 160, and 171-174, otherwise the module will probably cause python to crash upon import of the module (it does that for me), even though it works fine in the emulator.

    I suggest you go back to revision 484 which does not require these patches, and works fine for me on my N95.


    Regards,
    Mark.

  13. #13
    Regular Contributor
    Join Date
    Jul 2007
    Location
    Eindhoven, the Netherlands
    Posts
    187

    Re: Modules required :)

    Quote Originally Posted by neil.young View Post
    Could it be possible, that all of the so called "tutorials" (esp.Cyke's, Croozeu's) is outdated, erroneous and doesn't work any longer (if it ever did work?) I mean, I was just following exactly what was described here: http://wiki.opensource.nokia.com/pro...ing_extensions
    Yeah, I was also having a hard time finding a procedure & example to use as a basis for building my extension.

    Quote Originally Posted by neil.young View Post
    >>> import uikludges
    Traceback (most recent call last):
    File "<console>", line 1, in ?
    File "c:\resource\site.py", line 97, in platsec_import
    return _original_import(name, globals, locals, fromlist)
    File "c:\resource\uikludges.py", line 5, in ?
    _uikludges=imp.load_dynamic('_uikludges', 'c:\\sys\\bin\\_uikludges.pyd')
    SymbianError: [Errno -46] KErrPermissionDenied
    It looks like there's a mismatch between the permissions used for the extension module, and that of the installed python core/shell. Later it looks like loading it goes fine, but I doubt that is really the case (uikludges was already imported, so the second import is silently ignored).

    Try 'import _uikludges', if that fails with KErrPermissionDenied, you really need to look at the permissions you used to sign the SIS. If it does work, then rewrite the code at the beginning of uikludges.py to simply use 'import _uikludges' instead of dynamically load it.

    Regards,
    Mark.

  14. #14
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: Modules required :)

    Hi Mark,
    thanks for your patience and sorry for the late reply.

    Here is the result.

    1) I've checked out the revision, you suggested
    2) I had to change the includes to something similar to the uikludges mmp:

    SYSTEMINCLUDE \epoc32\include
    SYSTEMINCLUDE \epoc32\include\libc

    USERINCLUDE .
    USERINCLUDE \epoc32\include\python

    3) This compiles well with two warnings:

    Creation Time Description Resource Path Location Type
    1243973198520 Frozen .DEF file \Projekte\Carbide\workspace\Tracker\tracker-py\BWINS\kf__properties.def not found - project not frozen properties_3rd Unknown C/C++ Problem

    Creation Time Description Resource Path Location Type
    1243973201653 MAKEDEF WARNING: 1 export(s) not yet Frozen: init_properties @1[\Symbian\9.2\S60_3rd_FP1_2\EPOC32\BUILD\Projekte\Carbide\workspace\Tracker\tracker-py\properties\PROPERTIES_3RD\WINSCW\kf__properties.def] properties_3rd line 3 C/C++ Problem

    4) Produced C:\Symbian\9.2\S60_3rd_FP1_2\Epoc32\release\gcce\urel\kf__properties.pyd
    5) Changed these two lines in properties_3rd_fp1.pkg

    "properties.py"-"c:\resource\properties.py"
    "C:\Symbian\9.2\S60_3rd_FP1_2\epoc32\release\gcce\urel\kf__properties.PYD" -"c:\sys\bin\kf__properties.pyd"

    6) Used makesis to produce the sis from the pkg
    7) Opensigned the sis with full properties
    8) Installed the sisx.

    Running test.py in a bluetooth console.

    This is the output:

    >>> from properties import *
    >>> from e32 import ao_sleep as Sleep
    >>>
    >>> def Callback():
    ... SubscribeInt(KPSUidHWRMPowerState,KHWRMChargingStatus,Callback)
    ... print "Charging status: ", GetInt(KPSUidHWRMPowerState,KHWRMChargingStat
    us)
    ...
    >>> Callback()
    Traceback (most recent call last):
    File "<console>", line 1, in ?
    File "<console>", line 2, in Callback
    NameError: global name 'SubscribeInt' is not defined
    >>> Sleep(5)
    >>> SetInt(KPSUidHWRMPowerState,KHWRMChargingStatus,1)
    Traceback (most recent call last):
    File "<console>", line 1, in ?
    NameError: name 'SetInt' is not defined
    >>>


    SetInt is not defined

    BTW: "from _properties import *" resolves SetInt, at least. Seems, the publics of the CPP are not known in the python wrapper ?!

    Regards
    Last edited by neil.young; 2009-06-02 at 21:29.

  15. #15
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: Modules required :)

    I noticed, that SubscribeInt is _really_ not defined, because commented out. test.py seems to be not up to date.

    Regards

Similar Threads

  1. How to get required capability of API ?
    By savaj in forum Symbian
    Replies: 9
    Last Post: 2009-05-11, 11:08
  2. Need some modules for Python
    By ashok.soni in forum Symbian
    Replies: 2
    Last Post: 2008-12-07, 06:23
  3. carbide-error
    By upendersolanki in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 5
    Last Post: 2008-02-06, 11:09
  4. Problem with Cabride.c++ v1.1
    By markovuksanovic in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 3
    Last Post: 2007-01-24, 20:05
  5. Conditional compilation: managing set of modules
    By doctordwarf in forum Symbian
    Replies: 3
    Last Post: 2004-08-31, 14:01

Posting Permissions

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