×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    May 2008
    Posts
    53

    racing condition problem with positioning module

    hello people, is there any trick for solving racing condition problems involving positioning module? In the following code im getting NameError :global name 'e' is not defined. it seems this line "canvas.text( (2,12), unicode(str(e["latitude"])))" is called before my internal gps gives my position (it takes like 30 seconds), is there any way of making this work?
    i also tried adding "the normal" applicatin body to stop and wait for exist but im having the same racing condition problem...
    any hint would be appreciated.
    thanks



    Code:
    
    
    from graphics import *
    import appuifw
    import e32
    import positioning
    
    appuifw.app.screen='normal'
    appuifw.app.title=unicode('My Test App')
    canvas=appuifw.Canvas()
    appuifw.app.body=canvas
    
    
    
    positioning.select_module(positioning.default_module())
    
    positioning.set_requestors([{"type":"service",
                                 "format":"application",
                                 "data":"test_app"}])
    
    
    
    def cb(event):
        global e
        e = event["position"]
    
    
    d= positioning.position(course=1,satellites=1,callback=cb, interval=500000,partial=0)
    
    
    canvas.clear()
    canvas.text( (2,12), unicode(str(e["latitude"])))
    canvas.text( (2,24), unicode(str(e["longitude"])))
    e32.ao_yield()
    e32.ao_sleep(1115)

  2. #2
    Regular Contributor
    Join Date
    Dec 2007
    Location
    India
    Posts
    133

    Re: racing condition problem with positioning module

    You could use the usual print to the Console option if Canvas is not your priority requirement.

    I do not see any hinches with the code. Do you run it as a script or as a standalone?

    If standalone, does it work fine as a script?
    Kandyfloss

    V 7.0642.0
    18-10-06
    RH-51
    Nokia 7610

  3. #3
    Regular Contributor
    Join Date
    May 2008
    Posts
    53

    Re: racing condition problem with positioning module

    hello, i need to print in canvas. printing in console works fine, but its not what i need. Im running the code as script.

    thanks

  4. #4
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: racing condition problem with positioning module

    Quote Originally Posted by oyuky View Post
    im getting NameError :global name 'e' is not defined
    You could try adding a check, for example (untested, just writing):

    Code:
    # Initialize variable before anything else
    e = None
    
    ...
    
    if e and e.has_key('latitude'):
        s = unicode(str(e["latitude"]))
    else:
        s = u"Not defined"
    canvas.text( (2,12), s)

  5. #5
    Regular Contributor
    Join Date
    May 2008
    Posts
    53

    Re: racing condition problem with positioning module

    it works perfect thanks


Similar Threads

  1. What is the real problem to receive data calls with Nokia TDMA cell modem?
    By jackal_jr in forum PC Suite API and PC Connectivity SDK
    Replies: 0
    Last Post: 2002-12-04, 16:05
  2. Replies: 0
    Last Post: 2002-12-04, 15:46
  3. Replies: 2
    Last Post: 2002-11-25, 20:41
  4. Replies: 0
    Last Post: 2002-10-29, 12:51
  5. PJava runtime problem within Nokia 9210, Hrlp~!
    By Nokia_Archive in forum PersonalJava
    Replies: 1
    Last Post: 2002-05-28, 13:15

Posting Permissions

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