forked from GerhardHoffmann/DCLibraries
		
	Prepare new implementation of downloading the bootloader.
This commit is contained in:
		@@ -29,25 +29,31 @@ T_runProc::T_runProc()
 | 
			
		||||
    QTimer *runProc_callProcesses = new QTimer();
 | 
			
		||||
    connect(runProc_callProcesses, SIGNAL(timeout()), this, SLOT(runProc_slotProcess()));
 | 
			
		||||
    runProc_callProcesses->setSingleShot(false);
 | 
			
		||||
    runProc_callProcesses->start(100);     // in ms
 | 
			
		||||
    runProc_callProcesses->start(10);     // in ms
 | 
			
		||||
 | 
			
		||||
    hwapi_lastDoorState=0;      // default: all doors (should be) closed, coin box inserted
 | 
			
		||||
        // bit0: upper door  1:middle 2:lower  3=cash-box out
 | 
			
		||||
 | 
			
		||||
    hwapi_triggerBL = new QTimer();
 | 
			
		||||
    connect(hwapi_triggerBL, SIGNAL(timeout()), this, SLOT(bl_performComplStart()));
 | 
			
		||||
    hwapi_triggerBL->setSingleShot(false);
 | 
			
		||||
    hwapi_triggerBL->stop();
 | 
			
		||||
//    hwapi_triggerBL = new QTimer();
 | 
			
		||||
//    connect(hwapi_triggerBL, SIGNAL(timeout()), this, SLOT(bl_performComplStart()));
 | 
			
		||||
//    hwapi_triggerBL->setSingleShot(false);
 | 
			
		||||
//    hwapi_triggerBL->stop();
 | 
			
		||||
 | 
			
		||||
    myTO = new QTimer();
 | 
			
		||||
    myTO->setSingleShot(true);
 | 
			
		||||
    myTO->start(200);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void T_runProc::runProc_slotProcess(void)
 | 
			
		||||
{
 | 
			
		||||
#ifndef THIS_IS_CA_MASTER
 | 
			
		||||
    cash_paymentProcessing();
 | 
			
		||||
    doors_supervise();
 | 
			
		||||
    bl_performComplStart();     // neu 1.12.23
 | 
			
		||||
    dcBL_cycle();
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool T_runProc::cash_startPayment(uint32_t amount)
 | 
			
		||||
@@ -654,7 +660,7 @@ bool T_runProc::bl_isUp(void)
 | 
			
		||||
            receivedData[3]==45 && receivedData[4] ==95 && receivedData[5]==176)
 | 
			
		||||
        {
 | 
			
		||||
            qDebug() << "got BL response to readFWversion";
 | 
			
		||||
            epi_clrRawReceivedString();
 | 
			
		||||
            //epi_clrRawReceivedString();
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        // response to "start BL"
 | 
			
		||||
@@ -662,7 +668,7 @@ bool T_runProc::bl_isUp(void)
 | 
			
		||||
            receivedData[3]==223 && receivedData[4] ==131 )
 | 
			
		||||
        {
 | 
			
		||||
            qDebug() << "hwapi_bl_isUp: got BL response to start";
 | 
			
		||||
            epi_clrRawReceivedString();
 | 
			
		||||
            //epi_clrRawReceivedString();
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -677,7 +683,8 @@ void T_runProc::bl_completeStart(void)
 | 
			
		||||
 | 
			
		||||
bool T_runProc::bl_performComplStart(void)
 | 
			
		||||
{
 | 
			
		||||
    // must be called cyclic by timer
 | 
			
		||||
    bool result;
 | 
			
		||||
 | 
			
		||||
    static uint8_t retryCtr;
 | 
			
		||||
 | 
			
		||||
    if ((bl_startupStep<1) || (bl_startupStep>10))
 | 
			
		||||
@@ -691,58 +698,69 @@ bool T_runProc::bl_performComplStart(void)
 | 
			
		||||
 | 
			
		||||
    if (bl_startupStep==2)
 | 
			
		||||
    {
 | 
			
		||||
        qDebug()<<"rebooting";
 | 
			
		||||
        bl_rebootDC();
 | 
			
		||||
        hwapi_triggerBL->stop();
 | 
			
		||||
        hwapi_triggerBL->start(1000);    // call next step in 1s
 | 
			
		||||
        myTO->stop();
 | 
			
		||||
        myTO->start(500);
 | 
			
		||||
        retryCtr=0;
 | 
			
		||||
        bl_startupStep++;
 | 
			
		||||
    } else
 | 
			
		||||
 | 
			
		||||
    if (bl_startupStep==3)
 | 
			
		||||
    {
 | 
			
		||||
        //qDebug()<<"starting BL";
 | 
			
		||||
        bl_startBL();
 | 
			
		||||
        hwapi_triggerBL->stop();
 | 
			
		||||
        hwapi_triggerBL->start(100);
 | 
			
		||||
        bl_startupStep++;
 | 
			
		||||
 | 
			
		||||
        if (!myTO->isActive())
 | 
			
		||||
        {
 | 
			
		||||
            qDebug()<<"starting BL";
 | 
			
		||||
            bl_startBL();
 | 
			
		||||
            myTO->stop();
 | 
			
		||||
            myTO->start(500);
 | 
			
		||||
            bl_startupStep++;
 | 
			
		||||
        }
 | 
			
		||||
    } else
 | 
			
		||||
 | 
			
		||||
    if (bl_startupStep==4)
 | 
			
		||||
    {
 | 
			
		||||
        //if (!myTO->isActive())
 | 
			
		||||
        //{
 | 
			
		||||
        bl_checkBL();
 | 
			
		||||
        hwapi_triggerBL->stop();
 | 
			
		||||
        hwapi_triggerBL->start(100);
 | 
			
		||||
        bl_startupStep++;
 | 
			
		||||
 | 
			
		||||
        //}
 | 
			
		||||
        if (!myTO->isActive())
 | 
			
		||||
        {
 | 
			
		||||
            qDebug()<<"checking BL";
 | 
			
		||||
            bl_checkBL();
 | 
			
		||||
            myTO->stop();
 | 
			
		||||
            myTO->start(200);
 | 
			
		||||
            bl_startupStep++;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    } else
 | 
			
		||||
 | 
			
		||||
    if (bl_startupStep==5)
 | 
			
		||||
    {
 | 
			
		||||
        hwapi_triggerBL->stop();
 | 
			
		||||
        if (bl_isUp())
 | 
			
		||||
        if (!myTO->isActive())
 | 
			
		||||
        {
 | 
			
		||||
            bl_startupStep=99;
 | 
			
		||||
            //  BL is up and running
 | 
			
		||||
        } else
 | 
			
		||||
        {
 | 
			
		||||
            retryCtr++;    // start again
 | 
			
		||||
            if (retryCtr>=15)
 | 
			
		||||
            qDebug()<<"step 5";
 | 
			
		||||
            result = bl_isUp();
 | 
			
		||||
            qDebug()<<"BL result: "<< result;
 | 
			
		||||
            if (result)
 | 
			
		||||
            {
 | 
			
		||||
                bl_startupStep=99;
 | 
			
		||||
                //qDebug()<<"BL error!!!";
 | 
			
		||||
                qDebug()<<"BL is working now...";
 | 
			
		||||
                //  BL is up and running
 | 
			
		||||
                return true;
 | 
			
		||||
            } else
 | 
			
		||||
            {
 | 
			
		||||
                bl_startupStep=3;
 | 
			
		||||
                //qDebug()<<"BL retry...";
 | 
			
		||||
                retryCtr++;    // start again
 | 
			
		||||
                if (retryCtr>=10)
 | 
			
		||||
                {
 | 
			
		||||
                    bl_startupStep=99;
 | 
			
		||||
                    qDebug()<<"BL error!!!";
 | 
			
		||||
                } else
 | 
			
		||||
                {
 | 
			
		||||
                    bl_startupStep=3;
 | 
			
		||||
                    myTO->stop();
 | 
			
		||||
                    myTO->start(200);
 | 
			
		||||
                    qDebug()<<"BL retry...";
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    return true;
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user