×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    26

    sensors - starting/stopping listening

    Hello,

    I recently came up with a problem and can't find a way to solve it: I need to get sensor data from time to time, but sometimes the system crashes (get a message KErrInUse when trying to read sensor data) and I need to restart the phone to be able to use the resources again. What is the best way to make the sensor usable again? Maybe using symbian c++ if it is not implemented in python..

    The way I read the data is using functions (part of a class):

    def collect_data(self, samples=100):
    self.samples = samples
    self.sensor.set_callback(data_callback=self.collection_callback)

    self.app_lock = e32.Ao_lock()
    self.sensor.start_listening()
    self.app_lock.wait()
    self.sensor.stop_listening()

    and

    def collection_callback(self):
    if self.counter < self.samples:
    self.data.append(self.sensor.azimuth)
    self.counter = self.counter+1
    else:
    self.app_lock.signal()

    Most often it crashes with MagneticNorthData. It seems like sensor.stop_listening() doesn't do what it's supposed to.

    The routine is actually being run as a sub-thread of a main thread, so it is possible to track whether a thread that still should be running has crashed or not, but how do I free up the resources (sensor data) to make them usable again?

    What would you think is the best practice to manage such system, having in mind that I need to collect data from different sensors simultaneously?

    I am using 1.9.6 version of pys60 (was previously using 1.9.4, which had the same issue).

    Thank you.

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: sensors - starting/stopping listening

    hello AndriusA

    you can have a look at this tutorial by fellow champion Jouni, this is what i can help.

  3. #3
    Registered User
    Join Date
    Jun 2009
    Posts
    26

    Re: sensors - starting/stopping listening

    Hi, Gaba,

    Thanks for the reply, but it does not seem to work. It is for pys60 1.4.2 and the API has changed quite a lot since..

    Andrius

  4. #4
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: sensors - starting/stopping listening

    Quote Originally Posted by AndriusA View Post
    Hi, Gaba,

    Thanks for the reply, but it does not seem to work. It is for pys60 1.4.2 and the API has changed quite a lot since..

    Andrius
    hello AndriusA

    i would request you then to please upgrade yourself with the most stable PyS60 1.4.5.

    Regards

  5. #5
    Registered User
    Join Date
    Jun 2009
    Posts
    26

    Re: sensors - starting/stopping listening

    Hi, gaba88

    Again, not a good solution in my case.. In 1.4.5 there still were quite a lot of problems with sockets, that were fixed in later releases. And also the sensor API is really different and much more limited..

    Thanks for the suggestion anyway.

Similar Threads

  1. Replies: 5
    Last Post: 2008-12-07, 13:03
  2. TCP Listening Socket WLAN
    By jmeier in forum Symbian Networking & Messaging (Closed)
    Replies: 9
    Last Post: 2007-12-28, 11:42
  3. sensors on mobile
    By delhiris in forum Mobile Java General
    Replies: 1
    Last Post: 2007-07-20, 16:45
  4. where to buy sensors for mobile phones?
    By delhiris in forum General Development Questions
    Replies: 0
    Last Post: 2007-07-14, 22:35
  5. Replies: 1
    Last Post: 2006-10-15, 12:38

Posting Permissions

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