×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    11

    Reading data from Magnetometer or Compass causes error

    hi,

    i am trying to read out data from the magnetometer with qt mobility framework on my 5800.
    but when i access the reading an error occurs. in the simulator everything works fine.
    here my code:

    In the constructor:

    Code:
    magnetometerSensor = new QMagnetometer(this);
    magnetometerSensor->start();

    In a timer triggered method:

    Code:
    QMagnetometerReading *magReading = magnetometerSensor->reading();
    qreal xMag = magReading->x();
    qreal yMag = magReading->y();
    qreal zMag = magReading->z();

    The error:

    Process 13708, thread 13709 stopped at 0x791bd860: A data abort exception has occurred.

    It occurs in this line;

    Code:
    qreal xMag = magReading->x();

    i am using qt 4.6.3 and qt mobility 1.0.0. The same error occurs when i'm using QCompass instead of QMagnetometer.

    thanks and best regards,
    ghal maraz

  2. #2
    Registered User
    Join Date
    Nov 2007
    Location
    Espoo, Finland
    Posts
    25

    Re: Reading data from Magnetometer or Compass causes error

    Unfortunately Nokia 5800 XPressMusic has no magnetometer (compass), so you can't use that feature on that phone.

    Before trying to use a sensor, your application should check validity of sensor which tells if the sensor is available or not. So your application should be changed to something like this:

    Code:
    QMagnetometer *magnetometerSensor = new QMagnetometer(this);
    
    if (magnetometerSensor->isAvailable())
    {
        ...
        magnetometerSensor->start();
        ...
    }
    You can also check availability of other hardware features. You can do that by using QtMobility's System Information API. Eg. if you want to check if GPS is available then you can check it this way:

    Code:
    QSystemInfo info;
    if (info.hasFeatureSupported(QSystemInfo::LocationFeature))
    {
        ...
    }
    Last edited by miksuh; 2010-12-19 at 20:24.

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    11

    Re: Reading data from Magnetometer or Compass causes error

    Oh, thanks. I had in mind there was a magnetometer on the 5800, but i didn't check.

Similar Threads

  1. Magnetometer data
    By torsak1 in forum General Development Questions
    Replies: 13
    Last Post: 2012-06-12, 19:01
  2. Error for reading Data from socket
    By rati2010 in forum Symbian
    Replies: 10
    Last Post: 2008-07-31, 12:12
  3. Read error after reading data from socket
    By abhinav_kalra in forum Symbian
    Replies: 2
    Last Post: 2008-05-18, 13:45
  4. Bluetooth-data reading Error
    By future_proof in forum Mobile Java General
    Replies: 0
    Last Post: 2004-11-04, 10: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
  •  
×