Gremsy / gSDK

SDK application used by software to control the Gremsy’s gimbal
20 stars 21 forks source link

Found Error in Thread Handling #13

Open Xnoopeex opened 5 months ago

Xnoopeex commented 5 months ago

Hi Gremsy team,

I found an issue with thread locking:. gSDK Alpha: gimbal_interface.cpp

Gimbal_Interface::imu_t Gimbal_Interface::get_gimbal_raw_imu(void)
{
    pthread_mutex_lock(&_messages.mutex);

    /* Check gimbal imu value has changed*/
    if (_messages.timestamps.raw_imu) {
        /* Reset timestamps */
        _messages.timestamps.raw_imu = 0;
        const mavlink_raw_imu_t &raw = _messages.raw_imu;
        pthread_mutex_unlock(&_messages.mutex); //this needs to be added!
        return imu_t(vector3<int16_t>(raw.xacc, raw.yacc, raw.zacc), vector3<int16_t>(raw.xgyro, raw.ygyro, raw.zgyro));
    }

    pthread_mutex_unlock(&_messages.mutex);
    return imu_t();
}

see comment: pthread_mutex_unlock(&_messages.mutex); //this needs to be added! Otherwise the Thread stays in lock mode and crashes the application.

DatNguyenGremsy commented 1 month ago

Thank you, we have fixed this error in the newest version.