Orb_copy() call fails in barometer driver ms5611::collect()

#1

Hi,

I’m inserting a code to improve barometer altitude accuracy.

To get the current velocity of the vehicle I used orb functions: orb_subscribe(), orb_check() and orb_copy() for ORB_ID(vehicle_local_position) as like other samples.

Problem: But always orb_copy() returns ERROR value (-1) and the ‘errno’ value is 5 (EIO).

I checked that the publishing of the message is ok.

What is wrong? Something should be considered when orb_copy() is used in driver code?

Anyone knows?

The added codes are as following:

in class MS5611 declaration

protected:

    int _local_pos_sub; // the vehicle local position subscription
    struct vehicle_local_position_s _local_pos;

in MS5611:MS5611() constructor

    _local_pos_sub is initialized as -1.

in MS5611::collect()

            if(_local_pos_sub == -1)
            {
                _local_pos_sub = orb_subscribe(ORB_ID(vehicle_local_position));
            }

            orb_check(_local_pos_sub, &updated);

            if(updated)
            {
                int result;

                result = orb_copy(ORB_ID(vehicle_local_position), _local_pos_sub, &_local_pos);

                // Problem: the 'result' is always ERROR (-1) and the 'errno' is EIO (5).
                ...
            }
#2

Is this within the cycle (runs in HPWORK)?

#3

Yes, it is, I think.

It is called by MS5611::cycle().

And this seems to be called by work_queue(HPWORK, …).

Is it a problem?

#4

Hello,

Any follow up for this problem? I’m facing a similar problem.

It seems to me that orb_copy / orb_check do not work inside work callbacks (i.e. inside cycle function). Is it true?

Thanks.