TelemetryFeedback ACTelemetryPlugin::Update()
{
    TelemetryInfo info = GetNewData();
    feedback.isConnected = true;

    float force = info.ForceValue;

    if (pluginSettings->GetIsInverted())
        force = force * -1;

    feedback.torquePct = force / 3;

    return feedback;

}
TCodecProcessResult CAriMp3DecMmfCodec::ProcessL( const CMMFBuffer& aSrc,
        CMMFBuffer& aDst )
{
    PRINT_ENTRY;
    // total decoded bytes added to the dst buffer
    TInt totalDstBytesAdded = 0;
    // total src bytes added to the internal src buffer
    TInt totalSrcBytesCopied = 0;
    // temporary variable to use for copying the sorce or destination data
    TInt numberOfBytesCopied;
    // Flag for finding valid sync
    TBool syncFound = EFalse;

    /**
    * Process the dst buffer, update the dstBufferPos and check
    * whether dst buffer is NULL or not.
    */
    CMMFDataBuffer* dst = static_cast<CMMFDataBuffer*>( &aDst );

    const TInt dstMaxLen = dst->Data().MaxLength();
    TUint8* dstPtr = const_cast<TUint8*>( dst->Data().Ptr() );
    TInt dstBufferPos = dst->Position();

    /**
    * Process the src buffer, update srcbuffer length, position and
    * flag for last frame. check whether src buffer is NULL or not
    * and check src buffer contains any data
    */
    const CMMFDataBuffer* src = static_cast<const CMMFDataBuffer*>( &aSrc );

    TUint8* srcPtr = const_cast <TUint8*>( src->Data().Ptr() );
    TInt srcBufferLen = src->Data().Length();
    TInt srcBufferPos = src->Position();
    TBool lastFrame = src->LastBuffer();

    if ( srcBufferLen == 0 && iInternalInputBufferResidueLen == 0 )
    {
        PRINT_ERR( "source buffer length is zero" );
        User::Leave( KErrArgument );
    }

    /**
    * if any destination bytes from internal destination buffer is not
    * given to the dst buffer from the previous call, give it to the
    * dst buffer. After this block, it ensures that no bytes are remaining
    * in the internal destination buffer.
    */
    if ( iInternalOutputBufferResidueLen - iInternalOutputBufferPos > 0 )
    {
        numberOfBytesCopied = CopyToDstBuffer( dst, totalDstBytesAdded );

        if ( iInternalOutputBufferResidueLen - iInternalOutputBufferPos > 0 )
        {
            PRINT_EXIT;
            return Result( TCodecProcessResult::EProcessIncomplete,
                           totalSrcBytesCopied, totalDstBytesAdded );
        }
        else
        {
            if ( ( lastFrame ) && ( srcBufferLen - srcBufferPos == 0 )&&
                    ( iInternalInputBufferResidueLen == 0 ) )
            {
                iInternalOutputBufferResidueLen = 0;
                iInternalInputBufferResidueLen = 0;
                iInternalOutputBufferPos = 0;
                PRINT_EXIT;
                return Result( TCodecProcessResult::EEndOfData,
                               totalSrcBytesCopied, totalDstBytesAdded );
            }
            iInternalOutputBufferPos = 0;
            iInternalOutputBufferResidueLen = 0;
        }
    }

    /**
    * copy the src buffer data into the internal buffer till internal buffer
    * holds minimum bytes to process i.e KMinBytesInput. After this block, it
    * ensures that internal source buffer holds KMinBytesInput.
    * if it is a last frame, treat remaining residual buffer as internal
    * buffer.
    */
    if ( ( KMinBytesInput - iInternalInputBufferResidueLen > 0 )
            && ( srcBufferLen - srcBufferPos > 0 ) )
    {
        numberOfBytesCopied = CopyFromSrcBuffer( src, totalSrcBytesCopied );
    }

    if ( ( KMinBytesInput > iInternalInputBufferResidueLen )
            && ( !lastFrame ) )
    {
        PRINT_EXIT;
        return Result( TCodecProcessResult::EDstNotFilled,
                       srcBufferLen - srcBufferPos, totalDstBytesAdded );
    }

    /**
    * process the src buffer till destination buffer or source buffer
    * or both buffers are exhausted.
    */
    do
    {
        /**
        * call seeksync to find the valid fram start offset i.e syncpos.
        * update internal buffer position to that offset position if it is
        * success.if it is failed then there is no valid frame start in
        * the available buffer. Go for new src buffer. all bytes present
        * in the internal buffer are discarded.
        */
        TInt syncpos;
        TInt srcBufferRemainingBytes = srcBufferLen
                                       - srcBufferPos
                                       - totalSrcBytesCopied;
        TInt dstBufferRemainingBytes = dstMaxLen
                                       - dstBufferPos
                                       - totalDstBytesAdded;
        TInt internalInputBufferPos = 0;

        if ( KErrNone != iCodec->SeekSync(
                    &iInternalInputBuffer[internalInputBufferPos],
                    ( iInternalInputBufferResidueLen - internalInputBufferPos ),
                    syncpos ) )
        {
            TCodecProcessResult result = GetNewData( src, totalSrcBytesCopied,
                                         totalDstBytesAdded );

            if ( result.iStatus == TCodecProcessResult::EDstNotFilled ||
                    result.iStatus == TCodecProcessResult::EEndOfData )
            {
                return result;
            }
        }
        else
        {
            syncFound = ETrue;
            internalInputBufferPos += syncpos;
        }
        /**
        * call GetFrameInfo to find whether valid frame is present in the
        * availabel buffer.if it is success and framelength is 0 then
        * there is no valid frame is present,  discard the present buffer
        * till sync position and add new buffer.
        */
        if ( syncFound )
        {
            TInt frameLen;
            TMp3FrameInfo frameInfo;
            if ( KErrNone != iCodec->GetFrameInfo(
                        &iInternalInputBuffer[internalInputBufferPos],
                        ( iInternalInputBufferResidueLen - internalInputBufferPos ),
                        frameLen, frameInfo ) )
            {
                PRINT_ERR( "Decoder Getframeinfo failed" );
                User::Leave( KErrGeneral );
            }
            if ( frameLen == 0 )
            {
                TCodecProcessResult result = GetNewData( src,
                                             totalSrcBytesCopied, totalDstBytesAdded );

                if ( result.iStatus == TCodecProcessResult::EDstNotFilled ||
                        result.iStatus == TCodecProcessResult::EEndOfData )
                {
                    return result;
                }
            }

            /**
            * if the buffer has less than framelen then fill the internal
            * sorce buffer with KMinBytesInput bytes.
            */
            if ( frameLen   > ( iInternalInputBufferResidueLen
                                - internalInputBufferPos ) )
            {
                if( lastFrame )
                {
                    iInternalInputBufferResidueLen = 0;
                    iInternalOutputBufferResidueLen = 0;
                    iInternalOutputBufferPos = 0;
                    PRINT_EXIT;
                    return Result(
                               TCodecProcessResult::EEndOfData,
                               totalSrcBytesCopied, totalDstBytesAdded );
                }

                ShiftData( internalInputBufferPos, 0 );
                numberOfBytesCopied = CopyFromSrcBuffer( src,
                                      totalSrcBytesCopied );
                internalInputBufferPos = 0;

                if ( iInternalInputBufferResidueLen < KMinBytesInput )
                {
                    PRINT_EXIT;
                    return Result(
                               TCodecProcessResult::EDstNotFilled,
                               totalSrcBytesCopied, totalDstBytesAdded );
                }
            }

            /**
            * initialize the variables like srcUsed and dstLen accordingly.
            * call Decode.
            */

            TInt srcUsed = iInternalInputBufferResidueLen
                           - internalInputBufferPos;
            TInt dstLen  = iOutFrameSize;

            TInt error = iCodec->Decode(
                             &iInternalInputBuffer[internalInputBufferPos],
                             srcUsed, iInternalOutputBuffer, dstLen );

            if ( KErrNone != error )
            {
                iInternalInputBufferResidueLen = 0;
                PRINT_ERR( error );
                return Result(
                           TCodecProcessResult::EProcessError,
                           totalSrcBytesCopied, totalDstBytesAdded );
            }

            /**
            * Fill Destination Buffer
            */

            iInternalOutputBufferResidueLen = dstLen;
            numberOfBytesCopied = CopyToDstBuffer( dst, totalDstBytesAdded );
            dstBufferRemainingBytes -= numberOfBytesCopied;

            /***
            * Fill Sorce Buffer
            */

            internalInputBufferPos += srcUsed ;
            ShiftData( internalInputBufferPos, 0 );
            numberOfBytesCopied = CopyFromSrcBuffer( src,
                                  totalSrcBytesCopied );
            srcBufferRemainingBytes -= numberOfBytesCopied;
            internalInputBufferPos = 0;

            /***
            * check four conditions if else for src and if else for dst
            */

            // src buffer has available bytes to decode
            if ( srcBufferRemainingBytes > 0 )
            {
                if ( dstBufferRemainingBytes == 0 )
                {
                    PRINT_EXIT;
                    return Result( TCodecProcessResult::EProcessIncomplete,
                                   totalSrcBytesCopied, totalDstBytesAdded );
                }
            }

            else
            {
                // dst buffer has availabe space for decoded bytes
                if ( dstBufferRemainingBytes > 0 )
                {
                    // last frame of the input stream
                    if ( lastFrame )
                    {
                        if ( iInternalInputBufferResidueLen == 0 )
                        {
                            PRINT_EXIT;
                            return Result( TCodecProcessResult::EEndOfData,
                                           totalSrcBytesCopied, totalDstBytesAdded );
                        }
                    }
                    else
                    {
                        PRINT_EXIT;
                        return Result( TCodecProcessResult::EDstNotFilled,
                                       totalSrcBytesCopied, totalDstBytesAdded );
                    }
                }
                else
                {
                    /**
                     *internal output buffer has decoded bytes which is not
                     *given to dst buffer.
                     */
                    if ( iInternalOutputBufferResidueLen
                            - iInternalOutputBufferPos > 0 )
                    {
                        PRINT_EXIT;
                        return Result(
                                   TCodecProcessResult::EProcessIncomplete,
                                   totalSrcBytesCopied, totalDstBytesAdded );
                    }
                    // last frame of the input stream
                    else if ( lastFrame )
                    {
                        // if internal buffer has available bytes to decode
                        if ( iInternalInputBufferResidueLen > 0 )
                        {
                            PRINT_EXIT;
                            return Result(
                                       TCodecProcessResult::EProcessIncomplete,
                                       totalSrcBytesCopied, totalDstBytesAdded );
                        }
                        else
                        {
                            iInternalInputBufferResidueLen = 0;
                            PRINT_EXIT;
                            return Result(
                                       TCodecProcessResult::EEndOfData,
                                       totalSrcBytesCopied, totalDstBytesAdded );
                        }
                    }
                    else
                    {
                        PRINT_EXIT;
                        return Result(
                                   TCodecProcessResult::EProcessComplete,
                                   totalSrcBytesCopied, totalDstBytesAdded );
                    }
                }
            }
        }
    } while ( 1 );
}