Failed invoking <symbol> trying to read torque efectiveness

Hello:

I'm trying to read the torque effectiveness for a data field and I get the error Failed invoking <symbol>

First of all I declared the class

using Toybox.WatchUi as Ui;
using Toybox.Graphics as Gfx;
using Toybox.UserProfile as Upf;
using Toybox.Application as App;
using Toybox.AntPlus as Apl;

class MyBikePowerListener extends Apl.BikePowerListener
{
    //Initializes class variables
    function initialize()
    {
        Apl.BikePowerListener.initialize();
    }
}

Then, inside the function initialize() of my class that extends the Ui.DataField I have

var listener = new MyBikePowerListener();
var bikePower = new Apl.BikePower(listener);

And then inside my function compute(info) I have

var torqueData = bikePower.getTorqueEffectivenessPedalSmoothness();

Until here the code works. If I simulate data from the wizard all works well. But the problem comes when I try to extract the data as

var data_left = torqueData.leftTorqueEffectiveness;

If I put this code I obtain the Failed invoking <symbol>. Obviously I'm doing something wrong, but I can't find the source. Could anyone help, please? Or maybe someone could share some code about reading these advanced power metrics?

Thanks

  • Did you check whether torqueData is null first? Might want to put System.println("torqueData = " + torqueData) before the line that crashes.

  • Thank you for your answer.

    I've checked with your suggestion and I obtain a null value. But

    System.println("listener = " + listener);
    System.println("bikePower = " + bikePower);

    return apparently correct values, i.e., the objects were created

    listener = Obj: 148
    bikePower = Obj: 149

    so I can't understand why the torque data is not read. I'm trying to run the program with the simulate option in the FIT menu and also with the playback option using a FIT file from my Favero Assiome power meter

    Any idea?

  • Could be the target you are using doesn't support it, or this specific data isn't available with fit simulation..  You want to null check everything.

    It could be in this case you need an ant stick and the device to see data in the sim.