merge changes from T.Sax

This commit is contained in:
2025-10-22 15:18:34 +02:00
parent 9744db7838
commit 3f3911e573
15 changed files with 424 additions and 232 deletions

View File

@@ -379,6 +379,11 @@ bool T_com::isPortOpen(void)
return false;
}
void T_com::flushPort(void)
{
if (CatSerial->isOpen())
CatSerial->clear();
}
// -------------------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------------------

View File

@@ -496,6 +496,31 @@ uint8_t epi_getBatchResult()
// 8.10.2024 new, control power up/down
/*
void gpi_storePowerState(bool ptu_sleep, bool ptu_wake, bool dc_sleep, bool dc_wake)
{
if (ptu_sleep)
SharedMem::write()->Sdata_ptuInSleep=true;
if (ptu_wake)
SharedMem::write()->Sdata_ptuInSleep=false;
if (dc_sleep)
SharedMem::write()->Sdata_dcInSleep=true;
if (dc_wake)
SharedMem::write()->Sdata_dcInSleep=false;
}
bool epi_getPowerState_ptu()
{
return SharedMem::read()->Sdata_ptuInSleep;
}
bool epi_getPowerState_dc()
{
return SharedMem::read()->Sdata_dcInSleep;
}
*/

View File

@@ -45,6 +45,8 @@ static uint8_t datif_repeatCtr;
static uint8_t datif_kindOfCmd;
static uint8_t datif_pNextCmd, datif_sendSlowCmd;
static char testSerial;
static bool autoRequestWasOnBeforePowerDown;
//#define DATIF_MAXTO_WAIT4RESP 80 //20 erhöht am 17.7 geht viel besser
// höchster gemessener Wert (bei 20ms): 6
@@ -122,11 +124,11 @@ T_datif::T_datif(QObject *parent) : QObject(parent)
datei_clearFile(FILENAME_SHAREDDATA);
datei_writeToFile(FILENAME_SHAREDDATA, myBA);
*/
doRepeat=true;
doRepeat=false;
datif_pNextCmd=0;
datif_sendSlowCmd=0;
readCount = 0;
testSerial=99;
autoRequestWasOnBeforePowerDown=false;
}
void T_datif::resetChain(void)
@@ -164,22 +166,23 @@ char T_datif::datif_cycleSend()
// supervise if DC data are valid
datif_noResponseCtr++; // inc every 20ms
if (datif_noResponseCtr>250) // no life sign from device controller (DC) for about 20ms x 250 = 5000ms = 5s
{
if (datif_noResponseCtr>250) // no life sign from device controller (DC) for about a sec
{ // 10.7.2025: timeout increased 50-->250 (1s-->5s)
epi_resetDcDataValid(3); // DC data has not updated for >=5s -> no longer valid!
datif_nowNewDyns=0;
datif_nowNewStats=0;
testSerial=0; // New, 11.10.20TS
datif_noResponseCtr=0; // New, 11.10.20TS
}
// 24.7.24 new, data are valid if dynamic machine conditions AND dyn machine states came in
if (datif_nowNewDyns && datif_nowNewStats && !epi_areDcDataValid() )
epi_setDcDataValid();
// Ueberwachung ob ein oder mehrere Commands am Stueck erfolgreich waren
if (gpi_wantToResetSupervision())
{
gpi_storeOverallResult(0xFF);
}
//if (gpi_wantToResetSupervision())
//{
// gpi_storeOverallResult(0xFF);
//}
@@ -219,16 +222,7 @@ char T_datif::datif_cycleSend()
gpi_storeLastResult(8);
return 0;
}
/*
* Unsinn, wird nie durchlaufen
if (cycl_running>=(RESPONSEWAITTIME+6)) // 3.7.24: 101-->110
{
// Antwort ist gekommen, also nach kurzer Luecke naechstes (datif_cmdWasPerformed==1)
// oder nochmal gleiches (datif_cmdWasPerformed==2) Kommando senden
//qDebug()<< "datif got any response";
cycl_running=0;
}
*/
// hier stoppen, weil Antwort des letzten Cmds noch nicht da
return 0;
}
@@ -366,19 +360,53 @@ char T_datif::datif_cycleSend()
}
// if no direct comands need to be sent then send input requests
// new, 8.10.2024, avoid wrong messages right after wake-up
if ( testSerial==1)
{
myDCIF->setUserWriteData(0, 0,0, data);
myDCIF->setUserReadData(CMD2DC_TestSerial);
myDCIF->sendUserData(selectedSlaveAddr);
// request fixed string from DC and thus wait until DC is ready
cycl_running=1; // 1: start transmission
datif_kindOfCmd=0;
datif_repeatCtr=0;
doRepeat=false;
} else
if ( testSerial==2)
{
if (autoRequestWasOnBeforePowerDown)
epi_startEmmision(true);
testSerial++;
} else
if (gpi_isEmmisionOn()) // auto send button is pressed
{
//qDebug() << "auto request is on";
datif_kindOfCmd=0;
sendINrequestsAutomatic(); // request all cyclic data sequential
}
else
if (testSerial==0)
{
// start with test command after wakeup
testSerial=1;
} else
{
sendINrequestsAutomatic(); // request all cyclic data sequential
autoRequestWasOnBeforePowerDown=true;
}
} else
{
// new: after stopping auto-request flush com port ONE time, 6.11.24TS
// why? to get boot loader response correct at first request
// without flushing we got the response of last cyclic data request in buffer
if (autoRequestWasOnBeforePowerDown)
myDCIF->flushPort();
dif_scanStep=0; // always start from beginning
epi_resetDcDataValid(4);
datif_nowNewDyns=0;
datif_nowNewStats=0;
autoRequestWasOnBeforePowerDown=false;
testSerial=0;
}
datif_cmdWasPerformed=0; // 0: no response by now
@@ -403,8 +431,11 @@ char T_datif::sendINrequestsAutomatic(void)
uint8_t datif_maxNrCommands=35, datif_sendNow;
// send quicker while transaction is ongoing:
uint8_t datif_vendRequCommandList[15]={102,107,108,110,112,115,116,30,31,32,40,41,42,23,0};
uint8_t datif_maxVendingCmds=13;
//uint8_t datif_vendRequCommandList[15]={102,107,108,110,112,115,116,31,32,40,41,42,23,0,0};
//uint8_t datif_maxVendingCmds=13;
// 30 muss drin sein um coin attach zu erkennen:
uint8_t datif_vendRequCommandList[15]={102,107,108,110,112,115,116, 30, 31,32,40,41,42,23,0};
uint8_t datif_maxVendingCmds=14;
// special commands:
// 102: get IOs run constantly!!!
@@ -620,121 +651,7 @@ char T_datif::loadRecDataFromFrame()
gpi_storeRecPayLoad(RdDleng, receivedData); // save for host (user of hwapi)
if (myDCIF && myDCIF->getSerialPort()) {
uint32_t writeCount = myDCIF->getSerialPort()->getWriteCount();
if ((readCount + 1) == writeCount) { // there can be only one command sent to the DC
readCount = writeCount;
if (readSource != myDCIF->getReadSource()) {
qCritical() << __func__ << ":" << __LINE__ << ": ERROR length" << RdDleng << ", ignore data"
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
qCritical() << __func__ << ":" << __LINE__ << "would be interpretated as" << readSource << myDCIF->getReadSource();
return 0;
} else {
// only for debugging
// qCritical() << __func__ << ":" << __LINE__ << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << readSource << myDCIF->getReadSource();
/*
if (readSource == 30) {
T_moduleCondition const *modCond = reinterpret_cast<T_moduleCondition const *>(receivedData);
if(modCond->rtc >= 200) {
dump(modCond);
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E002 (modCond->rtc >= 200)"
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
}
if (modCond->printer == 200 || modCond->printer == 201) {
dump(modCond);
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E020 (modCond->printer == 200 || modCond->printer == 201)"
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
}
if (modCond->printer == 202) {
dump(modCond);
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E018 (modCond->printer == 202)"
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
}
if (modCond->coinBlocker >= 200) {
dump(modCond);
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E025 (modCond->coinBlocker >= 200)"
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
}
if (modCond->mdbBus >= 200) {
dump(modCond);
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E034 (modCond->mdbBus >= 200)"
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
}
if (modCond->intEe >= 200) {
dump(modCond);
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E011 (modCond->intEe >= 200)"
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
}
if (modCond->voltage >= 200) {
dump(modCond);
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E003 (modCond->voltage >= 200)"
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
}
if (modCond->changer >= 200) {
dump(modCond);
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E026 (modCond->changer >= 200)"
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
}
if (modCond->coinSafe == 201) {
dump(modCond);
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E007 (modCond->coinSafe == 201)"
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
}
if (modCond->coinSafe == 200) {
dump(modCond);
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E009 (modCond->coinSafe == 200)"
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
}
}
if (readSource == 31) {
T_dynamicCondition const *dynCond = reinterpret_cast<T_dynamicCondition const *>(receivedData);
if (dynCond->modeAbrech > 0) {
dump(dynCond);
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E011 (dynCond->modeAbrech > 0)"
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
}
if (dynCond->nowCardTest > 0) {
dump(dynCond);
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E072 (dynCond->nowCardTest > 0)"
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
}
if (dynCond->startupTestIsRunning > 0) {
dump(dynCond);
qCritical() << __func__ << ":" << __LINE__ << ": ERROR E073 (dynCond->startupTestIsRunning > 0)"
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
}
}
*/
}
} else {
qCritical() << __func__ << ":" << __LINE__ << QString(": ERROR readCount + 1 != writeCount: %1 != %2").arg(readCount + 1).arg(writeCount);
qCritical() << __func__ << ":" << __LINE__ << ": ERROR length" << RdDleng << ", ignore data"
<< QByteArray((char const *)receivedData, RdDleng).toHex(':');
qCritical() << __func__ << ":" << __LINE__ << "would be interpretated as" << readSource << myDCIF->getReadSource();
/*
if (readSource == 30) {
T_moduleCondition const *modCond = reinterpret_cast<T_moduleCondition const *>(receivedData);
dump(modCond);
}
if (readSource == 31) {
T_dynamicCondition const *dynCond = reinterpret_cast<T_dynamicCondition const *>(receivedData);
dump(dynCond);
if (dynCond->coinAttached > 0) {
qCritical() << __func__ << ":" << __LINE__ << ": dynCond->coinAttached"
<< QByteArray(reinterpret_cast<char const *>(receivedData), RdDleng).toHex(':');
}
}
*/
readCount = writeCount;
return 0;
}
}
//sub_gerhardsDiagnose();
// uint8_t nn;
//qDebug() << "\n datif: got valid data, rdsrc:" << readSource << " rdadd:" << readAddress
// << " rdlen:" << RdDleng;
@@ -777,8 +694,11 @@ char T_datif::loadRecDataFromFrame()
ret=verifyLineTestresponse(RdDleng, receivedData);
gpi_storeResult_serialTestOK(ret);
if (ret==true)
{
gpi_setTxt4datifLine("correct");
else
if ( testSerial==1) testSerial=2; // nach wake kam richtige Antwort
} else
gpi_setTxt4datifLine("false");
break;
@@ -1202,7 +1122,6 @@ char T_datif::loadRecDataFromFrame()
uit2=uchar2uint(receivedData[7],receivedData[6]); // value of last coin
//if (uitmp>0) // nur 1x bei neuer Münze 6.10.23 aendern:
// beim Wechsler hat die kleinste Muenze immer coin type 0!
if (uitmp>10000 || uit2>10000)
{
uitmp=0;

View File

@@ -242,11 +242,7 @@ uint8_t dcBL_sendFlashStartAddr2BL(uint32_t startAddr, uint8_t *sendData)
myBuf[2]=ulongTOuchar(startAddr, GETMIDLOWBYTE);
myBuf[3]=ulongTOuchar(startAddr, GETLOWBYTE);
myBuf[4]=0;
qDebug()<<"dcBL_sendFlashStartAddr2BL "<<myBuf[0]<<" "<<myBuf[1]<<" "<<myBuf[2]<<" "<<myBuf[3];
//qDebug()<<"dcBL_sendFlashStartAddr2BL "<<myBuf[0]<<" "<<myBuf[1]<<" "<<myBuf[2]<<" "<<myBuf[3];
return dcBL_prepareDC_BLcmd(0x21, 4, myBuf, sendData);
}
@@ -258,9 +254,9 @@ uint8_t dcBL_writeLastPage(uint8_t *sendData)
strclr(myBuf, 0, 2);
ret=dcBL_prepareDC_BLcmd(0x22, 0, myBuf, sendData);
qDebug()<<"dcBL just sending last block command, ret: "<<ret<<" "<<sendData[0]
<<" "<<sendData[1]<<" "<<sendData[2]<<" "<<sendData[3]<<" "<<sendData[4]
<<" "<<sendData[5]<<" "<<sendData[6]<<" "<<sendData[7];
//qDebug()<<"dcBL just sending last block command, ret: "<<ret<<" "<<sendData[0]
// <<" "<<sendData[1]<<" "<<sendData[2]<<" "<<sendData[3]<<" "<<sendData[4]
// <<" "<<sendData[5]<<" "<<sendData[6]<<" "<<sendData[7];
return ret;
}
@@ -332,7 +328,12 @@ uint8_t dcBL_getResponse(uint8_t *respBuff)
//dcBL_writeText("dcBL gotResponse");
}
if (recLen>=150)
{
dcBL_writeText("dcBL rec.buff. overflow");
epi_clrRawReceivedString();
recLen=0;
}
return recLen;
}
@@ -402,8 +403,8 @@ uint8_t dcBL_sendSuccess(uint8_t lastCommand)
if (recLen==0)
return 0; // no response by now
// qDebug()<<"dcBL_sendSuccess: got BL data"<< recLen <<
// Indata[0]<< Indata[1]<< Indata[2]<< Indata[3] << Indata[4]<< Indata[5]<< Indata[6]<< Indata[7];
qDebug()<<"dcBL_sendSuccess: got BL data"<< recLen <<
Indata[0]<< Indata[1]<< Indata[2]<< Indata[3] << Indata[4]<< Indata[5]<< Indata[6]<< Indata[7];
if (Indata[0]==2 && Indata[1]==(lastCommand | 0x80) )
return 10; // OK
@@ -663,8 +664,8 @@ void dcBL_sendAddress(uint16_t blockNumber)
dcBL_BlkCtr*=64;
len=dcBL_sendFlashStartAddr2BL(dcBL_BlkCtr, buf); // make command string
//qDebug()<<"dcBL_bl_sendAddress "<<buf[0]<<" "<<buf[1]<<" "<<buf[2]<<" "<<buf[3]<<" "
// <<buf[4]<<" "<<buf[5]<<" "<<buf[6]<<" ";
qDebug()<<"dcBL_bl_sendAddress "<<buf[0]<<" "<<buf[1]<<" "<<buf[2]<<" "<<buf[3]<<" "
<<buf[4]<<" "<<buf[5]<<" "<<buf[6]<<" ";
sendWRcmd_setSendBlock160(len, buf); // send command to BL
}
@@ -695,7 +696,7 @@ uint8_t dcBL_getFileBlock(uint16_t blockPointer, uint8_t *buf)
}
static uint16_t block2beSentNow, blTimeOutCounter;
static uint8_t blChainStep, blChainResult, blRepeatCounter;
static uint8_t blChainStep, blChainResult, blRepeatCounter, blRepeatOnErrorCtr;
bool dcBL_sendOneBlockCpl(uint16_t blockNumber)
{
@@ -712,6 +713,7 @@ bool dcBL_sendOneBlockCpl(uint16_t blockNumber)
blChainResult=0;
blTimeOutCounter=0;
blRepeatCounter=0;
blRepeatOnErrorCtr=0;
return true;
}
@@ -725,10 +727,17 @@ int8_t dcBL_getBlockResult(void)
}
void dcBL_cancelSending(void)
{
blChainStep=99;
}
char dcBL_cycle(void)
{
// to be called cyclic every 100ms
// to be called cyclic every 10ms
// this step chain sends ONE data block (64byte) and repeats if neccesary
// stop on timeout, 3xerror or success
uint8_t buf[70], sendBuf[160], ret, sendLen;
if (blChainStep==1)
@@ -737,9 +746,10 @@ char dcBL_cycle(void)
if (block2beSentNow==0 || block2beSentNow==1024 || block2beSentNow==2048
|| block2beSentNow==3072 || block2beSentNow==4096 )
{
epi_clrRawReceivedString();
dcBL_sendAddress(block2beSentNow);
blChainStep++;
blTimeOutCounter=0;
//qDebug()<<"dcBL_cycle sending address and wait for response";
return 0; // continue in 100ms
} else
@@ -757,7 +767,8 @@ char dcBL_cycle(void)
blChainStep=10; // OK, continue with data
blTimeOutCounter=0;
return 0; // continue in 100ms
blRepeatOnErrorCtr=0;
return 0; // continue in 10ms
}
if (ret==1)
{
@@ -770,28 +781,32 @@ char dcBL_cycle(void)
blChainStep=1; // repeat
else
{
qDebug()<<"dcBL cancel, wrong resp. to addr";
blChainResult=3; // error timeout, no response from DC-BL
blChainStep=99;
return 0;
}
return 0; // continue in 100ms
}
// noch keine Antwort:
blTimeOutCounter++;
if (blTimeOutCounter>=3) // wait 3 cycles (3x100ms) for response
if (blTimeOutCounter>=20) // wait 5 cycles (5x10ms) for response
{
//qDebug()<<"dcBL_cycle TO";
blChainResult=3; // error timeout, no response from DC-BL
blChainStep=99;
return 0;
} else
{
// ein oder zweimal keine Antwort
blChainStep=1; // repeat
//qDebug()<<"dcBL_cycle no response";
return 0; // continue in 100ms
blRepeatOnErrorCtr++;
if (blRepeatOnErrorCtr<5)
{
// keine Antwort, nochmal senden
blChainStep=1; // repeat
//qDebug()<<"dcBL_cycle no response";
return 0; // continue in 100ms
} else
{
// 5x keine Antwort, Abbruch
qDebug()<<"dcBL cancel, no resp. to addr";
blChainResult=3; // error timeout, no response from DC-BL
blChainStep=99;
return 0;
}
}
}
@@ -799,6 +814,7 @@ char dcBL_cycle(void)
if (blChainStep==10)
{
// send data block or conclusion
epi_clrRawReceivedString();
if (block2beSentNow == dcBL_nrOfBlocks)
{
// very last blocknumber, send conclusion
@@ -808,14 +824,28 @@ char dcBL_cycle(void)
{
// send data...
dcBL_getFileBlock(block2beSentNow, buf);
//qDebug()<<"dcBL sending data block"<<block2beSentNow;
sendLen=dcBL_prepareDC_BLcmd(0x22, 64, buf, sendBuf); // pack into protocol frame
//sendBuf[sendLen-1]=0; // testweise ETX verbiegen um Fehlerreaktion zu testen
// tested 2024.11.11: send without ETX, got no response, sending is repeated 4x, correct
// sendBuf[sendLen-2]=0; // testweise crc verbiegen
// tested 2024.11.11: send with wrong crc, got error-response, repeat 4x, OK
//if (blRepeatCounter<3)
// sendBuf[sendLen-2]=0; // testweise crc 3x verbiegen, bei 4. mal richtig senden
// tested 2024.11.11: send with wrong crc, got error-response, OK
//sendBuf[50]=0; // testweise nur die Haelft senden
// tested 2024.11.11: send incomplete, is repeated 4x then stop, everything correct
sendWRcmd_setSendBlock160(sendLen, sendBuf); // send up to 140 bytes
}
blChainStep++;
blTimeOutCounter=0;
} else
if (blChainStep==11)
@@ -829,36 +859,44 @@ char dcBL_cycle(void)
blChainResult=1; // block sent succesful
if (block2beSentNow == dcBL_nrOfBlocks)
blChainResult=2; // transfer complete
blTimeOutCounter=0;
return 0; // continue in 100ms
blRepeatOnErrorCtr=0;
return 0; // continue in 10ms
}
if (ret==1)
{
// we got response but BL reports an error
blTimeOutCounter=0;
blRepeatCounter++;
if (blRepeatCounter<3)
if (blRepeatCounter<5)
blChainStep=10; // repeat
else
{
qDebug()<<"dcBL cancel, wrong resp to datablock";
blChainResult=3; // error timeout, no response from DC-BL
blChainStep=99;
return 0;
}
return 0; // continue in 100ms
return 0; // continue in 10ms
}
// noch keine Antwort:
blTimeOutCounter++;
if (blTimeOutCounter>=3) // wait 3 cycles (3x100ms) for response
{
blChainResult=3; // error timeout, no response from DC-BL
blChainStep=99;
return 0;
} else
{
// ein oder zweimal keine Antwort
blChainStep=10; // repeat
return 0; // continue in 100ms
if (blTimeOutCounter>=20) // wait 200ms for response, normal value=40...70ms
{
// no response after 50ms
blRepeatOnErrorCtr++;
if (blRepeatOnErrorCtr<5)
{
blChainStep=10; // repeat
return 0; // continue in 10ms
} else
{
qDebug()<<"dcBL cancel, no resp to datablock";
blChainResult=3; // error timeout, no response from DC-BL
blChainStep=99;
return 0;
}
}
}

View File

@@ -325,7 +325,14 @@ bool hwapi::dc_isPortOpen(void) const
void hwapi::dc_autoRequest(bool on) const
{
// automatically request ALL digital and analog sensors, get time/date, get status information
// call this with on=false before power down !! new, 8.10.2024TS
epi_startEmmision(on);
if (!on)
gpi_storeDcDataValid(0); // new, 8.10.2024TS
// right after wake-up from power down the DC data are not yet valid
}
@@ -2625,6 +2632,8 @@ void hwapi::bl_stopBL(void) const // tested 26.09.2023
len=dcBL_exitBL(buf);
sendWRcmd_setSendBlock160(len, buf);
epi_setNowIsBootload(false);
runProcess->resetBLvari();
dcBL_cancelSending();
}

View File

@@ -618,8 +618,10 @@ bool T_prot::getReceivedInData(uint8_t *SlavAddr, uint16_t *readSrc, uint16_t *
return INdataValid; // nur true wenn CommandState OK und readState OK
}
void T_prot::flushPort(void)
{
mySerialPort->flushPort();
}

View File

@@ -9,7 +9,7 @@ static uint8_t hwapi_cash_lastCollectionState;
static uint8_t hwapi_paymentStarted;
static uint8_t hwapi_lastDoorState;
static uint8_t bl_startupStep;
static uint8_t runProc_BLisStarted;
T_runProc::T_runProc()
@@ -643,6 +643,7 @@ void T_runProc::bl_completeStart(void)
bl_startupStep=1;
}
bool T_runProc::bl_performComplStart(void)
{
bool result;
@@ -727,7 +728,12 @@ bool T_runProc::bl_performComplStart(void)
}
void T_runProc::resetBLvari(void)
{
// reset with BL-stop command
runProc_BLisStarted=0;
}
// new from 21.5.24 ..................................................................
@@ -1328,6 +1334,7 @@ void T_runProc::sub_changeStyle(char *valueStr)
// 10th:height 1th=width
"styl":"align c" // 'l' 'c' 'r' // left center right
"styl":"density25"; // 0....[25]...50 0=blass
"styl":"csiz 12" // character size 6..20, new 26.7.2024
*/
uint8_t val;
@@ -1397,7 +1404,16 @@ void T_runProc::sub_changeStyle(char *valueStr)
val=uint8_t(tslib_atol(&valueStr[7]));
runProc_prnCmdSeq[runProc_pointPrnCmd]=19;
runProc_prnCmdPara[runProc_pointPrnCmd++]=val;
} else
if ( memcmp(valueStr, "csiz ", 5) ==0 )
{
valueStr[7]=0;
val=uint8_t(tslib_atol(&valueStr[5]));
runProc_prnCmdSeq[runProc_pointPrnCmd]=20;
runProc_prnCmdPara[runProc_pointPrnCmd++]=val;
}
// "prn_papSped" comes with feed-cmd, not with "styl" !!
}
@@ -1619,51 +1635,25 @@ bool T_runProc::subGetVariStr(char *valueStr, char *returnStr)
if ( memcmp(valueStr, "wday eng shor", 13) ==0 )
{
switch (dow)
{
case 1:
returnStr[0]='m'; returnStr[1]='o';
break;
case 2:
returnStr[0]='t'; returnStr[1]='u';
break;
case 3:
returnStr[0]='w'; returnStr[1]='e';
break;
case 4:
returnStr[0]='t'; returnStr[1]='h';
break;
case 5:
returnStr[0]='f'; returnStr[1]='r';
break;
case 6:
returnStr[0]='s'; returnStr[1]='a';
break;
case 7:
returnStr[0]='s'; returnStr[1]='u';
break;
default:
returnStr[0]='-'; returnStr[1]='-';
break;
}
swl_returnWeekdayStr(dow, 2, returnStr);
returnStr[2]=0;
return true;
}
if ( memcmp(valueStr, "wday eng long", 13) ==0 )
{
swl_returnWeekdayStr(dow, 2, returnStr);
return true;
}
if ( memcmp(valueStr, "wday deu shor", 13) ==0 )
{
swl_returnWeekdayStr(dow, 1, returnStr);
returnStr[2]=0;
return true;
}
if ( memcmp(valueStr, "wday deu long", 13) ==0 )
{
swl_returnWeekdayStr(dow, 1, returnStr);
return true;
}
@@ -1987,7 +1977,6 @@ void T_runProc::runProc_subPerformPrintCmds(uint8_t nextCmd, uint8_t nextPara)
prn_fontInv=0;
sendFDcmd_set(CMD2DC_PRI_SETLETTER, 0, 0, prn_fontBold, prn_fontInv, prn_underLine, 0);
break;
case 16:
prn_fontTyp=nextPara; // kind of font 5...11 (0..22)
sendFDcmd_set(CMD2DC_PRI_SETFONT, 0,0, prn_fontTyp, prn_fontSiz, prn_width, prn_hei);
@@ -2008,12 +1997,14 @@ void T_runProc::runProc_subPerformPrintCmds(uint8_t nextCmd, uint8_t nextPara)
prn_density=nextPara;
prn_sendPrnSetup(prn_papSped, prn_density, prn_alignment, prn_orient);
break;
case 20:
prn_fontSiz=nextPara;
sendFDcmd_set(CMD2DC_PRI_SETFONT, 0,0, prn_fontTyp, prn_fontSiz, prn_width, prn_hei);
break;
case 30: // cut
// kindof = 1: full cut 2: partial cut 3=eject (5xLF + full cut)
sendFDcmd_set(CMD2DC_PRI_CUT, 0,0, 1,0,0,0);
break;
case 31: // part
// kindof = 1: full cut 2: partial cut 3=eject (5xLF + full cut)
sendFDcmd_set(CMD2DC_PRI_CUT, 0,0, 2,0,0,0);
@@ -2333,3 +2324,133 @@ char T_runProc::prn_directTicket_cycle(void)
}
// neuere TS Version, wurde aber von Gerhard nicht verwendet:
/*
bool T_runProc::bl_waitForRdyMsg(void) // vorher: bl_isUp()
{
uint8_t receivedData[160];
uint8_t LL, nn;
for (nn=0; nn<160; nn++) receivedData[nn]=0;
LL=epi_getRawRecLength();
if (LL>0)
{
epi_getRawReceivedData(receivedData);
// response to "readFWversion"
if (receivedData[0]==2 && receivedData[1]==146 && receivedData[2]==45 &&
receivedData[3]==45 && receivedData[4] ==95 && receivedData[5]==176)
{
//qDebug() << "*** runProc, got BL response to readFWversion";
//epi_clrRawReceivedString();
return true;
}
// response to "start BL"
if (receivedData[0]==2 && receivedData[1]==101 && receivedData[2]==48 &&
receivedData[3]==223 && receivedData[4] ==131 )
{
//qDebug() << "runProc, got BL response to start";
//epi_clrRawReceivedString();
return true;
}
//qDebug() << "runProc, got "<<LL<<" wrong bytes"<<receivedData[0]<<" "
// <<receivedData[1]<<" "<<receivedData[2]<<" "<<receivedData[3]<<" "
// <<receivedData[4]<<" "<<receivedData[5]<<" "<<receivedData[6];
}
return false;
}
uint8_t T_runProc::bl_isUp(void)
{
// return 1: BL is up 2: BL error 0: unknown
return runProc_BLisStarted;
}
bool T_runProc::bl_performComplStart(void)
{
bool result;
static uint8_t retryCtr;
if ((bl_startupStep<1) || (bl_startupStep>10))
return false;
if (bl_startupStep==1)
{
dc_autoRequest(false); // and clear serial input buffer
runProc_BLisStarted=0;
bl_startupStep++;
} else
if (bl_startupStep==2)
{
qDebug()<<"rebooting";
bl_rebootDC();
myTO->stop();
myTO->start(500);
retryCtr=0;
bl_startupStep++;
} else
if (bl_startupStep==3)
{
if (!myTO->isActive())
{
qDebug()<<"starting BL";
epi_clrRawReceivedString();
bl_startBL();
myTO->stop();
myTO->start(500);
bl_startupStep++;
}
} else
if (bl_startupStep==4)
{
if (!myTO->isActive())
{
qDebug()<<"checking BL";
bl_checkBL();
myTO->stop();
myTO->start(1000);
bl_startupStep++;
}
} else
if (bl_startupStep==5)
{
result = bl_waitForRdyMsg();
if (result==true)
{
bl_startupStep++;
qDebug()<<"BL is working now..."; // BL is up and running
runProc_BLisStarted=1; // ok
return true;
}
if (!myTO->isActive())
{
qDebug()<<"no resp. from BL"<< result;
retryCtr++; // start again
if (retryCtr>=3)
{
bl_startupStep=99;
qDebug()<<"BL error!!!";
} else
{
bl_startupStep=3;
runProc_BLisStarted=2; // error
myTO->stop();
myTO->start(1);
}
}
}
return false;
}
*/

View File

@@ -981,3 +981,62 @@ unsigned int tslib_ah2ui( char *AscString)
return(uitmp);
}
// *****************************************************************************************
void swl_returnWeekdayStr(char dow, char language, char *buf)
{
// dow=1...7
// always returns 10byte
// languages: 1=german 2=english
memset(buf,0,10);
switch (dow)
{
case 1: // monday
if (language==1) tslib_text2array("Montag", buf,10);
else if (language==2) tslib_text2array("Monday", buf,10);
break;
case 2:
if (language==1) tslib_text2array("Dienstag", buf,10);
else if (language==2) tslib_text2array("Tuesday", buf,10);
break;
case 3:
if (language==1) tslib_text2array("Mittwoch", buf,10);
else if (language==2) tslib_text2array("Wednesday", buf,10);
break;
case 4:
if (language==1) tslib_text2array("Donnerstag", buf,10);
else if (language==2) tslib_text2array("Thursday", buf,10);
break;
case 5:
if (language==1) tslib_text2array("Freitag", buf,10);
else if (language==2) tslib_text2array("Friday", buf,10);
break;
case 6:
if (language==1) tslib_text2array("Samstag", buf,10);
else if (language==2) tslib_text2array("Saturday", buf,10);
break;
case 7:
if (language==1) tslib_text2array("Sonntag", buf,10);
else if (language==2) tslib_text2array("Sunday", buf,10);
break;
default: tslib_text2array("----", buf,10);
}
}