Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User cuijartija's Avatar
    Join Date
    Oct 2009
    Location
    Mexico
    Posts
    69
    I was testing threads in PYS60, this code works:

    Code:
    import e32
    import thread,time
    
    def process():
    	timer = e32.Ao_timer()
    	while 1:
    		print "Tread1"
    		timer.after(.4)
    
    def process2():
    	timer = e32.Ao_timer()
    	while 1:
    		print "Tread2"
    		timer.after(.4)
    
    timer2 = e32.Ao_timer()
    thread.start_new_thread(process, ())
    thread.start_new_thread(process2, ())
    while 1:
    	print "Main"
    	timer2.after(.2)
    Then i tested with urllib retriving data from server and it works

    But if i try get location with thread i get: NaN always

    I have this code for get location:

    Code:
    def gpsGetPosition():
    	lastPositionGPS = positioning.position(course=1,satellites=1)['position']
    	print lastPositionGPS['latitude'],lastPositionGPS['vertical_accuracy'],lastPositionGPS['longitude'],lastPositionGPS['horizontal_accuracy']
    	return
    If i call the function with out thread i get rigth location !

    Code:
    gpsGetPosition()
    But if i try call the function in thread:

    Code:
    thread.start_new_thread(gpsGetPosition, ())
    The function returns inmediatly with "Nan Nan Nan Nan" results, it seems like the thread dont wait for the position.position() function inside the funticion gpsGetPosition.

    Any help? ideas?

    Thanks !!!
    Best Regards

    Eric.

  2. #2
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    27,744
    Symbian design prefers single-threaded processes, one aspect of this preference is that resources (like the GPS API) are not shared automatically between threads. I do not know Python and the design of its modules, but this is what you are probably experiencing.
    If there is a way to move the initialization of that "positioning" to the secondary thread, try doing that.

  3. #3
    Registered User cuijartija's Avatar
    Join Date
    Oct 2009
    Location
    Mexico
    Posts
    69
    [SOLVED]

    wizard_hu was right, i included the initialization GPS in the thread and all works well !!!




    Thanks
    Best Regards

    Eric.

Similar Threads

  1. LocationListener Interface OR loop with Thread.sleep for updating device location?
    By roryoflynn1@gmail.com in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2010-07-28, 12:43
  2. [HELP] Problem with snapshot & location service thread
    By sleep1ng_b0yz in forum Mobile Web Server
    Replies: 0
    Last Post: 2010-03-26, 03:48
  3. need assistance - error starting Location Thread
    By d-safety in forum Mobile Java General
    Replies: 4
    Last Post: 2009-06-14, 11:34
  4. Fail to terminate thread.
    By raj_rr7 in forum Symbian C++
    Replies: 3
    Last Post: 2008-07-29, 06:37
  5. Replies: 16
    Last Post: 2007-09-11, 10:05

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved