//-------------------------------------------------------------------------
bool DcBootControl::privateReset()
{
    QRtMidiData priRst = makePrivateResetCmd();
    if(priRst.isEmpty())
    {
        return false;
    }

    _pMidiOut->dataOut(priRst);

    return true;
}
//-------------------------------------------------------------------------
bool DcBootControl::enableBootcode( )
{
    QRtMidiData md;

    QRtMidiData responceData;

    // The device is in boot mode if it responses to the Echo command.
    if(isBootcode())
    {
        return true;
    }

    QRtMidiData priRst = makePrivateResetCmd();
    if(0 == priRst.length())
        return false;

    QRtMidiTrigger tc(RESPONCE_ENABLE_RECOVERY_ANY);
    QRtAutoTrigger autoch(&tc,_pMidiIn);

    // Issue a private reset
    _pMidiOut->dataOut(priRst);

    QThread::msleep(100);

    // Issue "enable recovery" no more than 300ms after reset to keep the device in boot code.
    for (int idx = 0; idx < 40 ; idx++)
    {
        _pMidiOut->dataOut(CMD_ENABLE_RECOVERY);
        QThread::msleep(20);
        if(tc.dequeue(responceData))
        {
            break;
        }
    }

    bool rtval = false;
    if(responceData.match(RESPONCE_ENABLE_RECOVERY_ACK))
    {
        // Verify device is in boot code
        if(!isBootcode())
        {
            DCLOG() << "Failed to verify device is in boot code";
        }
        else
        {
            DCLOG() << "Device is running boot code";
            rtval = true;
        }

    }
    else if(responceData.match(RESPONCE_ENABLE_RECOVERY_REJECTED))
    {
        DCLOG() << "The device has rejected the enable recovery command";
    }
    else if(responceData.match(RESPONCE_ENABLE_RECOVERY_FAILED))
    {
        DCLOG() << "Device has failed the enabled recovery command";
    }
    else
    {
        DCLOG() << "Timeout entering boot code";
    }
    return rtval;
}
Exemple #3
0
bool DcBootControl::enableBootcode( )
{
    DcMidiData md;
   
    DcMidiData responceData;

    // The device is in boot mode if it responses to the Echo command.
    if(isBootcode())
    {
        return true;
    }
    
    DcMidiData priRst = makePrivateResetCmd();
    if(0 == priRst.length())
    {
        return false;
    }


    DcMidiTrigger tc( _blindMode ? "F0 00 01 55" : RESPONCE_ENABLE_RECOVERY_ANY );
    DcAutoTrigger autoch(&tc,_pMidiIn);
    
    if( _blindMode )
    {
        DCLOG() << "Attempting to enable boot code in blind mode";
    }
    
    // Issue a private reset
    _pMidiOut->dataOut(priRst);

    QThread::msleep(100);
    
    // Issue "enable recovery" no more than 300ms after reset to keep the device in boot code.
    for (int idx = 0; idx < 40 ; idx++)
    {
    	_pMidiOut->dataOut(CMD_ENABLE_RECOVERY);
        QThread::msleep(20);
        if(tc.dequeue(responceData))
        {
            break;
        }
    }

    
    bool rtval = false;
    if(_blindMode )
    {
        DCLOG() << "Device is running 'blind mode' boot code";
        rtval = true;
    }
    else
    {
        
        if( responceData.match( RESPONCE_ENABLE_RECOVERY_ACK ) )
        {
            // Verify device is in boot code
            if( !isBootcode() )
            {
                DCLOG() << "Failed to verify device is in boot code";
                // Just send a reset in case status was lost
                _pMidiOut->dataOut( "F0 00 01 55 42 01 F7" );
            }
            else
            {
                DCLOG() << "Device is running boot code";
                rtval = true;
            }
        }
        else if( responceData.match( RESPONCE_ENABLE_RECOVERY_REJECTED ) )
        {
            DCLOG() << "The device has rejected the enable recovery command";
        }
        else if( responceData.match( RESPONCE_ENABLE_RECOVERY_FAILED ) )
        {
            DCLOG() << "Device has failed the enabled recovery command";
        }
        else
        {
            // Never saw the requested responce from the device
            // Who knows what's going on now - incase the device is in boot-mode
            // Send a reset command.
            _pMidiOut->dataOut( "F0 00 01 55 42 01 F7" );

            DCLOG() << "Timeout entering boot code";
        }
    }
    return rtval;
}