maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   MeeGo / Harmattan (https://talk.maemo.org/forumdisplay.php?f=45)
-   -   PySide script does not print sensor data (https://talk.maemo.org/showthread.php?t=81214)

Gybe 2011-12-30 15:19

PySide script does not print sensor data
 
I am not perfectly sure I am writing this on the right forum, so apologies if the forum is not correct.

So, I decided to try and give a look on the data the sensors deliver in my N9, but hit a wall.

I thought that it would be relatively easy to just create a python script that prints out accelerometer and/or compass data. So, I installed python and some bindings as instructed in

http://wiki.meego.com/Python/Harmattan/Getting_started

(Note: python-modules-all was not found)

Then, found some example codes:

http://qt.gitorious.org/pyside/pysid...bility/sensors

and

http://wiki.meego.com/User:Mdengler

Both get stuck somewhere before getting to the output generating part. Typical output, after which the process must be killed manually:

Code:

~/python $ python ac.py
Using the meego graphics system
loaded the Generic plugin
loaded the grue plugin
Loaded the MeeGo sensor plugin
Setting data rate 0 Hz (interval 0 ms) for "meego.accelerometer"
Setting data rate 0 Hz (interval 0 ms) for "meego.magnetometer"

Finally, I tried to generate as simple script as I could:

Code:

import sys
from PySide.QtCore import *
from QtMobility.Sensors import *
                               
app = QCoreApplication(sys.argv)
sensor = QAccelerometer()     
sensor.start()                 
reading = sensor.reading()     
print reading.x(), reading.y(), reading.z()

Which gives following output:

Code:

~/python $ python acc.py 
loaded the Generic plugin
loaded the grue plugin
Loaded the MeeGo sensor plugin
Setting data rate 0 Hz (interval 0 ms) for "meego.accelerometer"
0.0 0.0 0.0
~/python $

Now, I would expect one of those to be slightly below 10 if the phone is lying still. I tried similar script for the compass sensor, and I got a bearing of 0 regardless which direction the phone was turned.

So, what have I missed?

Thanks,

Gybe

nicolai 2011-12-30 15:57

Re: PySide script does not print sensor data
 
Here is an example that works for me:
http://qt.gitorious.org/pyside/pysid...cceleration.py

nicolai

Gybe 2011-12-30 16:21

Re: PySide script does not print sensor data
 
Quote:

Originally Posted by nicolai (Post 1143527)
Here is an example that works for me:
http://qt.gitorious.org/pyside/pysid...cceleration.py

nicolai

Thanks nicolai, that is one of the example scripts I tried, with following output:

Code:

~/python $ python show_acceleration.py
loaded the Generic plugin
loaded the grue plugin
Loaded the MeeGo sensor plugin
Setting data rate 0 Hz (interval 0 ms) for "meego.accelerometer"
^C^Z[1]+  Stopped                    python show_acceleration.py
~/python $ python ./show_acceleration.py
loaded the Generic plugin
loaded the grue plugin
Loaded the MeeGo sensor plugin
Setting data rate 0 Hz (interval 0 ms) for "meego.accelerometer"
^Z[2]+  Stopped                    python ./show_acceleration.py
~/python $ python ./show_acceleration.py -r 100

loaded the Generic plugin
loaded the grue plugin
Loaded the MeeGo sensor plugin
Setting data rate 100 Hz (interval 10 ms) for "meego.accelerometer"
^Z[3]+  Stopped                    python ./show_acceleration.py -r 100

It simply does not produce any output after it tells me that it has set the data rate, which forces me to kill the process manually.

So basically I have copied the script file to my n9 and run it as user. Is this how you do it as well?

Is there something I need to enable if I want my scripts to use the data from sensors?

Gybe

nicolai 2011-12-30 16:44

Re: PySide script does not print sensor data
 
Yes, I started this script from xterm application on my N950
and over ssh. On both ways it produces an output like:
Acceleration: -4.42 x 0.18 y 13.42 z m/s^2 11.00 ms since last, 87.85 Hz
Acceleration: -2.12 x 1.59 y 6.71 z m/s^2 110.00 ms since last, 9.05 Hz
Acceleration: -2.12 x 1.59 y 6.71 z m/s^2 32.00 ms since last, 31.03 Hz

It only produces an output while the screen is unlocked.

Gybe 2011-12-30 16:49

Re: PySide script does not print sensor data
 
Quote:

Originally Posted by nicolai (Post 1143546)

It only produces an output while the screen is unlocked.

That was it. Thanks very much.


All times are GMT. The time now is 03:27.

vBulletin® Version 3.8.8