Merge commit '8b301a91dc0d4ae7a4ddd5f470016b4cd68b85c4'.
This commit is contained in:
		@@ -2,129 +2,107 @@
 | 
			
		||||
#include <QString>
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include "tslib.h"
 | 
			
		||||
#include "shared_mem_buffer.h"
 | 
			
		||||
//#include "controlBus.h"
 | 
			
		||||
 | 
			
		||||
// ///////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//          control serial interface   gui <--> serial
 | 
			
		||||
// ///////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
static QString    rs_comportName;   // z.B. "COM48"
 | 
			
		||||
static QString    rs_baudStr;       // z.B. "19200"
 | 
			
		||||
static int        rs_baudNr;        //0...5 oder -1
 | 
			
		||||
static uint8_t    rs_connect;       // 0,1
 | 
			
		||||
//static QString    rs_comportName;   // z.B. "COM48"
 | 
			
		||||
//static QString    rs_baudStr;       // z.B. "19200"
 | 
			
		||||
//static int        rs_baudNr;        //0...5 oder -1
 | 
			
		||||
//static uint8_t    rs_connect;       // 0,1
 | 
			
		||||
 | 
			
		||||
void epi_setSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect)
 | 
			
		||||
{
 | 
			
		||||
//    qDebug() << "ENTER" << BaudNr << BaudStr << ComName << connect;
 | 
			
		||||
void epi_setSerial(int BaudNr,
 | 
			
		||||
                   QString BaudStr,
 | 
			
		||||
                   QString ComName,
 | 
			
		||||
                   uint8_t connect) {
 | 
			
		||||
    memset(&SharedMemBuffer::getData()->rs.comportName[0], 0x00,
 | 
			
		||||
           sizeof(SharedMemBuffer::getData()->rs.comportName));
 | 
			
		||||
    strncpy(SharedMemBuffer::getData()->rs.comportName,
 | 
			
		||||
            ComName.toStdString().c_str(),
 | 
			
		||||
            sizeof(SharedMemBuffer::getData()->rs.comportName)-1);
 | 
			
		||||
 | 
			
		||||
    rs_comportName = ComName;
 | 
			
		||||
    rs_baudStr     = BaudStr;
 | 
			
		||||
    rs_baudNr      = BaudNr;    // 0=1200  1=9600  2=19200  3=38400  4=57600  5=115200  oder -1
 | 
			
		||||
    rs_connect     = connect;     // 0/1
 | 
			
		||||
    memset(&SharedMemBuffer::getData()->rs.baudStr[0], 0x00,
 | 
			
		||||
           sizeof(SharedMemBuffer::getData()->rs.baudStr));
 | 
			
		||||
    strncpy(SharedMemBuffer::getData()->rs.baudStr,
 | 
			
		||||
            BaudStr.toStdString().c_str(),
 | 
			
		||||
            sizeof(SharedMemBuffer::getData()->rs.baudStr)-1);
 | 
			
		||||
 | 
			
		||||
//    qDebug() << "LEAVE" << rs_baudNr << rs_baudStr << rs_comportName << rs_connect;
 | 
			
		||||
    SharedMemBuffer::getData()->rs.baudNr = BaudNr;
 | 
			
		||||
    SharedMemBuffer::getData()->rs.connect = connect;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void epi_closeSerial(void)
 | 
			
		||||
{
 | 
			
		||||
    rs_connect=0;
 | 
			
		||||
//    qDebug() << "ENTER/LEAVE rc_connect=0";
 | 
			
		||||
void epi_closeSerial(void) {
 | 
			
		||||
    SharedMemBuffer::getData()->rs.connect = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void gpi_serialChanged(void)
 | 
			
		||||
{
 | 
			
		||||
void gpi_serialChanged(void) {
 | 
			
		||||
    // serial confirms that port was closed or opened
 | 
			
		||||
    rs_connect=2;   // Flanke, nur 1x öffnen/schließen
 | 
			
		||||
    //qDebug() << "ENTER/LEAVE rc_connect=2";
 | 
			
		||||
    // rs_connect=2;   // Flanke, nur 1x öffnen/schließen
 | 
			
		||||
    SharedMemBuffer::getData()->rs.connect = 2;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t gpi_getSerialConn(void)
 | 
			
		||||
{
 | 
			
		||||
    return rs_connect;
 | 
			
		||||
uint8_t gpi_getSerialConn(void) {
 | 
			
		||||
    return SharedMemBuffer::getDataConst()->rs.connect;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int gpi_getBaudNr(void)
 | 
			
		||||
{
 | 
			
		||||
    return rs_baudNr;
 | 
			
		||||
int gpi_getBaudNr(void) {
 | 
			
		||||
    return SharedMemBuffer::getDataConst()->rs.baudNr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString gpi_getComPortName(void)
 | 
			
		||||
{
 | 
			
		||||
    return rs_comportName;
 | 
			
		||||
QString gpi_getComPortName(void) {
 | 
			
		||||
    return SharedMemBuffer::getDataConst()->rs.comportName;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool rs_portIsOpen;
 | 
			
		||||
 | 
			
		||||
void gpi_serialIsOpen(bool offen)
 | 
			
		||||
{
 | 
			
		||||
    //qDebug() << "ENTER/LEAVE offen=" << offen;
 | 
			
		||||
    rs_portIsOpen=offen;
 | 
			
		||||
void gpi_serialIsOpen(bool offen) {
 | 
			
		||||
    SharedMemBuffer::getData()->rs.portIsOpen = offen;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool epi_isSerialPortOpen()
 | 
			
		||||
{
 | 
			
		||||
bool epi_isSerialPortOpen() {
 | 
			
		||||
    // true: port is open   false: port is closed
 | 
			
		||||
    //qDebug() << "ENTER/LEAVE offen=" << rs_portIsOpen;
 | 
			
		||||
    return rs_portIsOpen;
 | 
			
		||||
    return SharedMemBuffer::getDataConst()->rs.portIsOpen;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ///////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//          Control transfer   gui <--> serial
 | 
			
		||||
// ///////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static char       AutoEmissionOn;     // 1: zyklisch Anfragen zum Slave senden
 | 
			
		||||
 | 
			
		||||
void epi_startEmmision(char start)
 | 
			
		||||
{
 | 
			
		||||
    AutoEmissionOn=start;
 | 
			
		||||
void epi_startEmmision(char start) {
 | 
			
		||||
    SharedMemBuffer::getData()->AutoEmissionOn = start;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool gpi_isEmmisionOn(void)
 | 
			
		||||
{
 | 
			
		||||
    return AutoEmissionOn;
 | 
			
		||||
bool gpi_isEmmisionOn(void) {
 | 
			
		||||
    return SharedMemBuffer::getDataConst()->AutoEmissionOn;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//-----------------------------------------------------
 | 
			
		||||
 | 
			
		||||
static uint16_t datif_sendingPeriod;
 | 
			
		||||
static bool     datif_sendingPer_changed;
 | 
			
		||||
 | 
			
		||||
uint16_t gpi_getPeriodicSendTimeVal()
 | 
			
		||||
{
 | 
			
		||||
    datif_sendingPer_changed=0;
 | 
			
		||||
    if (datif_sendingPeriod<3 || datif_sendingPeriod>10000)
 | 
			
		||||
uint16_t gpi_getPeriodicSendTimeVal() {
 | 
			
		||||
    SharedMemBuffer::getData()->datif.sendingPer_changed = 0;
 | 
			
		||||
    if ((SharedMemBuffer::getDataConst()->datif.sendingPeriod < 3) ||
 | 
			
		||||
        (SharedMemBuffer::getDataConst()->datif.sendingPeriod > 10000)) {
 | 
			
		||||
        return 130;         // ms, default
 | 
			
		||||
    else
 | 
			
		||||
        return datif_sendingPeriod;
 | 
			
		||||
    }
 | 
			
		||||
    return SharedMemBuffer::getDataConst()->datif.sendingPeriod;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void epi_setPeriodicSendTimeVal(uint16_t val)
 | 
			
		||||
{
 | 
			
		||||
    if (val>=3 && val<10000)
 | 
			
		||||
    {
 | 
			
		||||
        datif_sendingPer_changed=1;
 | 
			
		||||
        datif_sendingPeriod=val;
 | 
			
		||||
void epi_setPeriodicSendTimeVal(uint16_t val) {
 | 
			
		||||
    if (val>=3 && val<10000) {
 | 
			
		||||
        SharedMemBuffer::getData()->datif.sendingPer_changed = 1;
 | 
			
		||||
        SharedMemBuffer::getData()->datif.sendingPeriod = val;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool gpi_PeriodicSendTimeHasChanged()
 | 
			
		||||
{
 | 
			
		||||
    return datif_sendingPer_changed;
 | 
			
		||||
bool gpi_PeriodicSendTimeHasChanged() {
 | 
			
		||||
    return SharedMemBuffer::getDataConst()->datif.sendingPer_changed;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//-----------------------------------------------------
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//-----------------------------------------------------
 | 
			
		||||
 | 
			
		||||
// ///////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//          Status Display    gui <--> serial
 | 
			
		||||
// ///////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//              linke Spalte, über Connect Button
 | 
			
		||||
static QString txt4comStateLine;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -863,6 +863,11 @@ char T_datif::loadRecDataFromFrame()
 | 
			
		||||
    //int portNr;
 | 
			
		||||
    bool ret;
 | 
			
		||||
    uint8_t uctmp;      // maxai
 | 
			
		||||
    char ctmp;
 | 
			
		||||
    static uint8_t lastResult;
 | 
			
		||||
    uint8_t prnResult;
 | 
			
		||||
    static uint32_t lastInsertedAmount;
 | 
			
		||||
    uint32_t newInsertedAmount;
 | 
			
		||||
 | 
			
		||||
    ret=myDCIF->getReceivedInData(&SlaveAdr, &readSource, &readAddress,  &RdDleng, receivedData);
 | 
			
		||||
        // retval: data valid, only one time true, true if CommandState OK and readState OK
 | 
			
		||||
@@ -902,7 +907,8 @@ char T_datif::loadRecDataFromFrame()
 | 
			
		||||
 | 
			
		||||
    for (int ii=0; ii<RdDleng; ii++)
 | 
			
		||||
    {
 | 
			
		||||
        localStr.append(receivedData[ii]);
 | 
			
		||||
        ctmp=receivedData[ii];
 | 
			
		||||
        localStr.append(ctmp);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //qDebug() << "got HW version: " << localStr;
 | 
			
		||||
@@ -936,7 +942,7 @@ char T_datif::loadRecDataFromFrame()
 | 
			
		||||
 | 
			
		||||
        case CMD2DC_RdBkDCstate:                            //101
 | 
			
		||||
            //qDebug() << "got DC state " << localStr;
 | 
			
		||||
            localStr[8]=0;
 | 
			
		||||
            //localStr[8]=0;
 | 
			
		||||
            gpi_storeGenerals(2, localStr);
 | 
			
		||||
                // 0=HW   1=SW  2=State
 | 
			
		||||
            break;
 | 
			
		||||
@@ -1112,7 +1118,9 @@ char T_datif::loadRecDataFromFrame()
 | 
			
		||||
    case CMD2DC_RdBk_MifState:          //109
 | 
			
		||||
        // get reader status and card type
 | 
			
		||||
 | 
			
		||||
        gpi_storeMifReaderStateAndCardType(receivedData);
 | 
			
		||||
        //gpi_storeMifReaderStateAndCardType(receivedData);
 | 
			
		||||
        gpi_storeNewMifareCard(receivedData[0], &receivedData[1]);
 | 
			
		||||
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case CMD2DC_RdBk_MifData:           //24
 | 
			
		||||
@@ -1216,7 +1224,7 @@ char T_datif::loadRecDataFromFrame()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// ab hier neu:    XXX
 | 
			
		||||
// ab hier neu:    12.4.23
 | 
			
		||||
 | 
			
		||||
    case CMD2DC_RDBK_DEV_PARA:      //14
 | 
			
		||||
/*
 | 
			
		||||
@@ -1350,10 +1358,16 @@ char T_datif::loadRecDataFromFrame()
 | 
			
		||||
 | 
			
		||||
    case 112:       // get inserted amount in cent in sum
 | 
			
		||||
        // byte 0..3: amount just paid   4,5:last coin type  6,7: last coin value
 | 
			
		||||
        ultmp=uchar2ulong(receivedData[3],receivedData[2],receivedData[1],receivedData[0]);
 | 
			
		||||
        newInsertedAmount=uchar2ulong(receivedData[3],receivedData[2],receivedData[1],receivedData[0]);
 | 
			
		||||
        uitmp=uchar2uint(receivedData[5],receivedData[4]);
 | 
			
		||||
        uit2=uchar2uint(receivedData[7],receivedData[6]);
 | 
			
		||||
        gpi_storeCurrentPayment(ultmp, uitmp, uit2);
 | 
			
		||||
        gpi_storeCurrentPayment(newInsertedAmount, uitmp, uit2);
 | 
			
		||||
        if (newInsertedAmount != lastInsertedAmount)
 | 
			
		||||
        {
 | 
			
		||||
            emit datif_gotNewCoin();
 | 
			
		||||
            lastInsertedAmount=newInsertedAmount;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case 113:       // get wake source, 8byte
 | 
			
		||||
@@ -1465,17 +1479,35 @@ char T_datif::loadRecDataFromFrame()
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
        gpi_storeDynMachineConditions(RdDleng, receivedData);
 | 
			
		||||
 | 
			
		||||
        prnResult=receivedData[52];
 | 
			
		||||
        if (prnResult != lastResult)
 | 
			
		||||
        {
 | 
			
		||||
            // new result
 | 
			
		||||
            if (prnResult==1)
 | 
			
		||||
            {
 | 
			
		||||
                emit datif_templatePrintFinished_OK();
 | 
			
		||||
            } else
 | 
			
		||||
            if (prnResult==2)
 | 
			
		||||
            {
 | 
			
		||||
                emit datif_templatePrintFinished_Err();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            lastResult=prnResult;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case 32:        // Get current cash level (in vault)
 | 
			
		||||
                    // bytes 0..3: amount   bytes 4,5=Nr.ofCoins in vault
 | 
			
		||||
 | 
			
		||||
        ultmp=uchar2ulong(receivedData[3],receivedData[2],receivedData[1],receivedData[0]);
 | 
			
		||||
        uitmp=uchar2uint(receivedData[5],receivedData[4]);
 | 
			
		||||
        gpi_storeCBlevel(ultmp, uitmp);
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case 33:        // Get all backuped acc. Numbers
 | 
			
		||||
                    // 8 UINTs with acc-nr
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        gpi_storeDCbackupAccNr(RdDleng, receivedData);
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case 38:        // Get stored account record backup
 | 
			
		||||
@@ -1541,7 +1573,8 @@ struct T_vaultRecord
 | 
			
		||||
    UCHAR endofblock[4];	// end>
 | 
			
		||||
// 316 byte Block im Speicher
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
        // readAddress,  &RdDleng, receivedData
 | 
			
		||||
        gpi_storeVaultRecord(readAddress, receivedData );   // always 64byte
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
@@ -1644,11 +1677,15 @@ bool T_datif::verifyLineTestresponse(uint8_t RdDlen, uint8_t *receivedData)
 | 
			
		||||
    if (RdDlen < 16)
 | 
			
		||||
        return false;
 | 
			
		||||
    QString myStr;
 | 
			
		||||
    char ctmp;
 | 
			
		||||
 | 
			
		||||
    myStr.clear();
 | 
			
		||||
    myStr.append("< Slave Response");
 | 
			
		||||
 | 
			
		||||
    for (int nn=0; nn<16; nn++)
 | 
			
		||||
        if (myStr[nn] !=receivedData[nn])
 | 
			
		||||
    {
 | 
			
		||||
        ctmp=receivedData[nn];
 | 
			
		||||
        if (myStr[nn] != ctmp)
 | 
			
		||||
        {
 | 
			
		||||
            //qDebug() << " datif cmd 10: got wrong string ";
 | 
			
		||||
            //qDebug() << myStr;
 | 
			
		||||
@@ -1656,6 +1693,7 @@ bool T_datif::verifyLineTestresponse(uint8_t RdDlen, uint8_t *receivedData)
 | 
			
		||||
            //qDebug() << nn;
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -21,29 +21,65 @@
 | 
			
		||||
#include "controlBus.h"
 | 
			
		||||
#include "storeINdata.h"
 | 
			
		||||
#include "dcBL.h"
 | 
			
		||||
#include "shared_mem_buffer.h"
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <../plugins/interfaces.h>
 | 
			
		||||
#include <QSharedMemory>
 | 
			
		||||
 | 
			
		||||
#include "interfaces.h"
 | 
			
		||||
 | 
			
		||||
static uint32_t hwapi_lastStartAmount;
 | 
			
		||||
 | 
			
		||||
static const QMap<QString, int> baudrateMap = {
 | 
			
		||||
  {"1200"   ,   0}, {"9600"   ,   1}, {"19200"  ,   2}, {"38400"  ,   3},
 | 
			
		||||
  {"57600"  ,   4}, {"115200" ,   5}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
hwapi::hwapi(QWidget *parent) : QObject(parent)
 | 
			
		||||
{
 | 
			
		||||
    // constructor
 | 
			
		||||
    //epi_resetAllDOs();
 | 
			
		||||
    //PI_INI();
 | 
			
		||||
hwapi::hwapi(QWidget *parent) : QObject(parent) {
 | 
			
		||||
    // create or attach shared memory segment
 | 
			
		||||
    // !!! The compoment creating the shared memory MUST be ATBQT !!!
 | 
			
		||||
    m_sharedMem = SharedMemBuffer::getShm(sizeof(SharedMemBuffer));
 | 
			
		||||
    if (m_sharedMem) {
 | 
			
		||||
        if (m_sharedMem->isAttached()) {
 | 
			
		||||
            qInfo() << "Shared memory ("
 | 
			
		||||
                    << sizeof(SharedMemBuffer) << "bytes) created and attached";
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        qCritical() << "Creating/attaching shared memory failed";
 | 
			
		||||
    }
 | 
			
		||||
    sendWRcmd_INI();
 | 
			
		||||
 | 
			
		||||
    myDatif = new T_datif();
 | 
			
		||||
 | 
			
		||||
    connect(myDatif, SIGNAL(datif_templatePrintFinished_OK()), this, SLOT(hwapi_slotPrintFinished_OK()));
 | 
			
		||||
    connect(myDatif, SIGNAL(datif_templatePrintFinished_Err()), this, SLOT(hwapi_slotPrintFinished_Err()));
 | 
			
		||||
    connect(myDatif, SIGNAL(datif_gotNewCoin()), this, SLOT(hwapi_slotGotCoin()));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
hwapi::~hwapi() {
 | 
			
		||||
    if (m_sharedMem && m_sharedMem->isAttached()) {
 | 
			
		||||
        m_sharedMem->detach();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void hwapi::hwapi_slotPrintFinished_OK(void) {
 | 
			
		||||
    emit hwapi_templatePrintFinished_OK();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void hwapi::sub_storeSendingText(QByteArray *buf) const
 | 
			
		||||
{
 | 
			
		||||
void hwapi::hwapi_slotPrintFinished_Err(void) {
 | 
			
		||||
    emit hwapi_templatePrintFinished_Err();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void hwapi::hwapi_slotGotCoin(void) {
 | 
			
		||||
    // new coin was inserted while transaction and new amount reported:
 | 
			
		||||
    emit hwapi_gotNewCoin();
 | 
			
		||||
 | 
			
		||||
    uint32_t newSum=epi_CurrentPaymentGetAmount();
 | 
			
		||||
 | 
			
		||||
    if (newSum>=hwapi_lastStartAmount)
 | 
			
		||||
        emit hwapi_vendStopByMax();
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void hwapi::sub_storeSendingText(QByteArray *buf) const {
 | 
			
		||||
 | 
			
		||||
    char local[70], copie[1350];    // 64byte more then max buffer size!
 | 
			
		||||
    int LL, nn, len, maxruns=20;
 | 
			
		||||
@@ -739,13 +775,16 @@ QString hwapi::rtc_getTimStr() const
 | 
			
		||||
{
 | 
			
		||||
    uint8_t hh,  mm,  ss, buf[20], nn;
 | 
			
		||||
    QString qbuf;
 | 
			
		||||
 | 
			
		||||
    char ctmp;
 | 
			
		||||
    qbuf.clear();
 | 
			
		||||
    for (nn=0; nn<20; nn++) buf[nn]=0;
 | 
			
		||||
    epi_getTime(&hh, &mm, &ss);
 | 
			
		||||
    GetTimeString(hh, mm, ss, HourSys24h, MITSEK, buf); // about 12byte long
 | 
			
		||||
    for (nn=0; nn<20; nn++) qbuf[nn]=buf[nn];
 | 
			
		||||
 | 
			
		||||
    for (nn=0; nn<20; nn++)
 | 
			
		||||
    {
 | 
			
		||||
        ctmp=buf[nn];
 | 
			
		||||
        qbuf[nn]=ctmp;
 | 
			
		||||
    }
 | 
			
		||||
    return qbuf;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -753,14 +792,17 @@ QString hwapi::rtc_getDatStr() const
 | 
			
		||||
{
 | 
			
		||||
    uint8_t day,  month,  year, buf[20], nn;
 | 
			
		||||
    QString qbuf;
 | 
			
		||||
    char ctmp;
 | 
			
		||||
 | 
			
		||||
    qbuf.clear();
 | 
			
		||||
    for (nn=0; nn<20; nn++) buf[nn]=0;
 | 
			
		||||
    epi_getDate(&year, &month, &day);
 | 
			
		||||
    GetDateString(day, month, 0x20, year, DateFormatDeutsch, 0, buf);
 | 
			
		||||
    for (nn=0; nn<20; nn++)
 | 
			
		||||
        qbuf[nn]=buf[nn];
 | 
			
		||||
 | 
			
		||||
    {
 | 
			
		||||
        ctmp=  buf[nn];
 | 
			
		||||
        qbuf[nn]=ctmp;
 | 
			
		||||
    }
 | 
			
		||||
    return qbuf;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -2221,7 +2263,8 @@ bool hwapi::pri_TD_addText(QByteArray text) const
 | 
			
		||||
 | 
			
		||||
bool hwapi::pri_TD_addValue(int val) const
 | 
			
		||||
{
 | 
			
		||||
    QString  tmpStr;
 | 
			
		||||
//    QString  tmpStr;
 | 
			
		||||
    QByteArray  tmpStr;
 | 
			
		||||
    tmpStr.setNum(val,10);      // up to 12 chars
 | 
			
		||||
    if (ticketTemplate.length()>1266)
 | 
			
		||||
        return false;
 | 
			
		||||
@@ -3071,7 +3114,7 @@ bool hwapi::bl_isUp(void) const
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void hwapi::bl_sendAddress(u_int16_t blockNumber) const
 | 
			
		||||
void hwapi::bl_sendAddress(uint16_t blockNumber) const
 | 
			
		||||
{
 | 
			
		||||
    // send start address, nr of 64byte-block, start with 0
 | 
			
		||||
    // will be sent only for folling block-numbers:
 | 
			
		||||
@@ -3106,7 +3149,7 @@ void hwapi::bl_openBinary(void) const
 | 
			
		||||
    dcBL_loadBinary(0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void hwapi::bl_sendDataBlock(uint8_t length, u_int8_t *buffer) const
 | 
			
		||||
void hwapi::bl_sendDataBlock(uint8_t length, uint8_t *buffer) const
 | 
			
		||||
{
 | 
			
		||||
    // send 64 byte from bin file
 | 
			
		||||
    uint8_t LL=length, sendBuf[80], sendLen;
 | 
			
		||||
@@ -3137,6 +3180,7 @@ void hwapi::bl_sendLastBlock(void) const
 | 
			
		||||
 | 
			
		||||
    len=dcBL_writeLastPage(buf);
 | 
			
		||||
    sendWRcmd_setSendBlock160(len, buf);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t hwapi::bl_wasSendingDataOK(void) const
 | 
			
		||||
@@ -3309,6 +3353,60 @@ bool hwapi::rtc_getExtendedTime(uint8_t *leng, uint8_t *data) const
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool hwapi::rtc_getExtendedTime(struct T_extTime *exTime) const
 | 
			
		||||
{
 | 
			
		||||
    uint8_t len;
 | 
			
		||||
    uint16_t LL, nn;
 | 
			
		||||
    uint8_t *start;
 | 
			
		||||
    uint8_t  buf[66];
 | 
			
		||||
 | 
			
		||||
    epi_restoreExtendedTime(&len, buf);
 | 
			
		||||
        // Puffer in struct eintragen:
 | 
			
		||||
    LL=sizeof(struct T_extTime);
 | 
			
		||||
    start = &(exTime->Hours);
 | 
			
		||||
    nn=0;
 | 
			
		||||
    do
 | 
			
		||||
    {
 | 
			
		||||
        *start = buf[nn];
 | 
			
		||||
        start++;
 | 
			
		||||
    } while(++nn<LL);
 | 
			
		||||
 | 
			
		||||
    return true;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
struct T_extTime
 | 
			
		||||
{
 | 
			
		||||
    uint8_t     Hours;
 | 
			
		||||
    uint8_t     Min;
 | 
			
		||||
    uint8_t     Sec;
 | 
			
		||||
    uint8_t     Year;
 | 
			
		||||
    uint8_t     Month;
 | 
			
		||||
    uint8_t     Day;
 | 
			
		||||
    uint8_t     DOW;
 | 
			
		||||
    uint8_t     res1;
 | 
			
		||||
    uint16_t    MinOfDay;
 | 
			
		||||
    uint16_t    res2;
 | 
			
		||||
    uint32_t    SecOfDay;
 | 
			
		||||
    uint8_t     isLeapYear;
 | 
			
		||||
    uint8_t     nxtLeapYear;
 | 
			
		||||
    uint8_t     lastLeapYear;
 | 
			
		||||
    uint8_t     hoursOfThisWeek;
 | 
			
		||||
    uint16_t    minutesOfThisWeek;
 | 
			
		||||
    uint16_t    hoursOfThisMonth;
 | 
			
		||||
    uint16_t    daysOfThisYear;
 | 
			
		||||
    uint16_t    GetHoursOfYear;
 | 
			
		||||
    uint16_t    res3;
 | 
			
		||||
    uint32_t    GetMinutesOfYear;
 | 
			
		||||
    uint8_t     getWakeIntvSec;
 | 
			
		||||
    uint8_t     res4;
 | 
			
		||||
    uint16_t    res5;
 | 
			
		||||
    uint32_t    MinutesOfMillenium;
 | 
			
		||||
};
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool hwapi::sys_runCompleteTest(void) const
 | 
			
		||||
{
 | 
			
		||||
    // warning: lasts 20s in one pace
 | 
			
		||||
@@ -3320,9 +3418,8 @@ bool hwapi::sys_ready4sending(void) const
 | 
			
		||||
    // return true if a Json-file can be sent
 | 
			
		||||
 | 
			
		||||
    // check free memory
 | 
			
		||||
    uint8_t frei=FDLONG_STACKDEPTH - check4FDlongCmd();
 | 
			
		||||
    uint8_t frei=check4freeFDlongCmd();
 | 
			
		||||
        // Command-Stack sollte 16 Commands fassen, je 64byte Nutzdaten = 1024byte
 | 
			
		||||
        // in check4FDlongCmd() steht wieviele Plaetze bereits belegt sind
 | 
			
		||||
        // frei gibt also die Anzahl freier 64byte Bloecke zurueck
 | 
			
		||||
        // das Json-File hat max 800 byte = 13 bloecke
 | 
			
		||||
    if (frei<16)        // Puffer muss ganz leer sein! nicht dass was durcheinander kommt
 | 
			
		||||
@@ -3357,9 +3454,8 @@ bool hwapi::sys_sendJsonFileToDc(uint8_t kindOfFile, uint8_t nrOfTemplate, uint8
 | 
			
		||||
    dateiLang<<=6;  // auf volle 64byte aufgerundet
 | 
			
		||||
 | 
			
		||||
    // check free memory
 | 
			
		||||
    frei=FDLONG_STACKDEPTH - check4FDlongCmd();
 | 
			
		||||
    frei=check4freeFDlongCmd();
 | 
			
		||||
        // Command-Stack sollte 16 Commands fassen, je 64byte Nutzdaten = 1024byte
 | 
			
		||||
        // in check4FDlongCmd() steht wieviele Plaetze bereits belegt sind
 | 
			
		||||
        // frei gibt also die Anzahl freier 64byte Bloecke zurueck
 | 
			
		||||
        // das Json-File hat max 800 byte = 13 bloecke
 | 
			
		||||
    if (frei<16)        // Puffer muss ganz leer sein! nicht dass was durcheinander kommt
 | 
			
		||||
@@ -3380,8 +3476,8 @@ bool hwapi::sys_sendJsonFileToDc(uint8_t kindOfFile, uint8_t nrOfTemplate, uint8
 | 
			
		||||
    {
 | 
			
		||||
        biox_CopyBlock(inhaltOfJson, uitmp, temp, 0, 64);
 | 
			
		||||
        longFDcmd_set(31,0, bn++, 64, temp);
 | 
			
		||||
        uitmp += 64;
 | 
			
		||||
        // uitmp<<=6;
 | 
			
		||||
        //uitmp<<=6;  // falsch
 | 
			
		||||
        uitmp+=64;
 | 
			
		||||
    } while(uitmp < dateiLang);
 | 
			
		||||
 | 
			
		||||
    longFDcmd_set(32, 0,0, 0,temp);       // Abschluss
 | 
			
		||||
@@ -3412,11 +3508,12 @@ bool hwapi::prn_printTemplate(uint8_t nrOftemplate) const
 | 
			
		||||
    return sendFDcmd_set(152, 0,0, nrOftemplate,0,0,0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void hwapi::log_getHoldAccountNumbers(uint32_t *accNr ) const
 | 
			
		||||
    // returns all acc nrs of the backuped vault records
 | 
			
		||||
    // use: uint32_t backupedAccNumbers[8]
 | 
			
		||||
void hwapi::log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const
 | 
			
		||||
{
 | 
			
		||||
    Q_UNUSED(accNr);
 | 
			
		||||
    // returns all acc nrs of the backuped vault records
 | 
			
		||||
    // use: uint16_t backupedAccNumbers[8]
 | 
			
		||||
 | 
			
		||||
    epi_restoreDCbackupAccNr(nrOfVals, accNr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -3424,21 +3521,62 @@ void hwapi::log_getHoldAccountNumbers(uint32_t *accNr ) const
 | 
			
		||||
bool hwapi::log_selectVaultRecord(uint16_t accountNr ) const
 | 
			
		||||
{
 | 
			
		||||
    // return true if sending, false if cmd-stack is full
 | 
			
		||||
    uint8_t dat1, dat2;
 | 
			
		||||
    // and trigger transfer
 | 
			
		||||
 | 
			
		||||
    uint8_t dat1, dat2;
 | 
			
		||||
    bool ret;
 | 
			
		||||
 | 
			
		||||
    uint8_t frei=check4freeFDshortCmd();
 | 
			
		||||
    if (frei<8)
 | 
			
		||||
        return false;
 | 
			
		||||
 | 
			
		||||
    epi_iniVRstorage();
 | 
			
		||||
    dat1=uint2uchar(accountNr, LOWBYTE);
 | 
			
		||||
    dat2=uint2uchar(accountNr, HIGHBYTE);
 | 
			
		||||
    return sendFDcmd_set(153, 0,0, dat1,dat2,0,0);
 | 
			
		||||
    ret=sendFDcmd_set(153, 0,0, dat1,dat2,0,0); // select this record
 | 
			
		||||
        // true means "will be sent"
 | 
			
		||||
    sendFDcmd_set(0,38,0, 0,0,0,0);    // return VaultRecord block-Nr.0
 | 
			
		||||
    sendFDcmd_set(0,38,1, 0,0,0,0);    // return VaultRecord block-Nr.1
 | 
			
		||||
    sendFDcmd_set(0,38,2, 0,0,0,0);    // return VaultRecord block-Nr.2
 | 
			
		||||
    sendFDcmd_set(0,38,3, 0,0,0,0);    // return VaultRecord block-Nr.3
 | 
			
		||||
    sendFDcmd_set(0,38,4, 0,0,0,0);    // return VaultRecord block-Nr.4
 | 
			
		||||
    sendFDcmd_set(0,38,5, 0,0,0,0);    // return VaultRecord block-Nr.4
 | 
			
		||||
        // 38: <100 to get long 64byte response
 | 
			
		||||
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool hwapi::log_chkIfVaultRecordAvailable(void) const
 | 
			
		||||
{
 | 
			
		||||
    // return true if completly received
 | 
			
		||||
    return epi_checkIfVaultRecordAvailable();
 | 
			
		||||
        return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//request, isAvailable
 | 
			
		||||
void hwapi::log_getVaultRecord(struct T_vaultRecord *retVR) const
 | 
			
		||||
bool hwapi::log_getVaultRecord(struct T_vaultRecord *retVR) const
 | 
			
		||||
    // which was selected by: log_selectVaultRecord()
 | 
			
		||||
    // to be forwarded to Ismas
 | 
			
		||||
    // return true if completly received
 | 
			
		||||
{
 | 
			
		||||
    Q_UNUSED(retVR);
 | 
			
		||||
 | 
			
		||||
    uint16_t LL, nn, len;
 | 
			
		||||
    char   *start;
 | 
			
		||||
    uint8_t  buf[400];
 | 
			
		||||
    bool ret;
 | 
			
		||||
 | 
			
		||||
    ret=epi_restoreVaultRecord(&len, buf);   // true if completly received
 | 
			
		||||
    if (ret==false)
 | 
			
		||||
        return false;
 | 
			
		||||
        // Puffer in struct eintragen:
 | 
			
		||||
    LL=sizeof(struct T_vaultRecord);		// =320
 | 
			
		||||
    start = &retVR->startbuffer[0];
 | 
			
		||||
    nn=0;
 | 
			
		||||
    do
 | 
			
		||||
    {
 | 
			
		||||
        *start = buf[nn];
 | 
			
		||||
        start++;
 | 
			
		||||
    } while(++nn<LL);
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool hwapi::prn_printAccountReceipt(void) const
 | 
			
		||||
@@ -3453,14 +3591,19 @@ bool hwapi::prn_printTestTicket(void) const
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool hwapi::cash_startPayment(uint16_t amount) const
 | 
			
		||||
bool hwapi::cash_startPayment(uint32_t amount) const
 | 
			
		||||
{
 | 
			
		||||
    uint8_t dat1, dat2;
 | 
			
		||||
    // 17.4.23TS: extended to 32bit
 | 
			
		||||
    uint8_t dat1, dat2, dat3, dat4;
 | 
			
		||||
 | 
			
		||||
    hwapi_lastStartAmount=amount;
 | 
			
		||||
    epi_clearCurrentPayment();
 | 
			
		||||
    dat1=uint2uchar(amount, LOWBYTE);
 | 
			
		||||
    dat2=uint2uchar(amount, HIGHBYTE);
 | 
			
		||||
    return sendFDcmd_set(155, 0,0, dat1,dat2,0,0);
 | 
			
		||||
    dat1=ulong2uchar(amount, 0);
 | 
			
		||||
    dat2=ulong2uchar(amount, 1);
 | 
			
		||||
    dat3=ulong2uchar(amount, 2);
 | 
			
		||||
    dat4=ulong2uchar(amount, 3);
 | 
			
		||||
 | 
			
		||||
    return sendFDcmd_set(155, 0,0, dat1,dat2,dat3,dat4);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -3494,6 +3637,7 @@ bool hwapi::cash_stopPayment(void) const
 | 
			
		||||
{
 | 
			
		||||
    // DB1: 1=encash    2=cancel & return coins
 | 
			
		||||
    //      3=stop and keep coins in escrow
 | 
			
		||||
    emit hwapi_vendStopByPushbutton();
 | 
			
		||||
    return sendFDcmd_set(156, 0,0, 3,0,0,0);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -3516,17 +3660,24 @@ bool hwapi::vend_failed(void) const
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
uint8_t hwapi::mif_getCardType(QString cardholder) const
 | 
			
		||||
uint8_t hwapi::mif_getCardType(QString *cardholder) const
 | 
			
		||||
    // return 1,2,3,4 = upper, lower access card, printer test, coin test
 | 
			
		||||
    // cardholder: 7byte Name-String
 | 
			
		||||
{
 | 
			
		||||
    Q_UNUSED(cardholder);
 | 
			
		||||
    return 0; // to satisfy compiler
 | 
			
		||||
    uint8_t type, buf[8], nn;
 | 
			
		||||
    char ctmp;
 | 
			
		||||
 | 
			
		||||
    memset(buf, 0x00, sizeof(buf));
 | 
			
		||||
 | 
			
		||||
    type=epi_mifGetCardType(&buf[0]);
 | 
			
		||||
        //holder[8] = name of card holder
 | 
			
		||||
        // retval Type of MifareCard, 1=upper door, 2=lower door 3=test printer 4=test coins
 | 
			
		||||
    for (nn=0;nn<8; nn++) {
 | 
			
		||||
        ctmp=buf[nn];
 | 
			
		||||
        cardholder[nn]=ctmp;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    return type;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint64_t hwapi::sys_getWakeSource(void) const
 | 
			
		||||
@@ -3535,17 +3686,138 @@ uint64_t hwapi::sys_getWakeSource(void) const
 | 
			
		||||
     return epi_getWakeSources();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//void hwapi::sys_getDeviceConditions(struct T_moduleCondition *devCond) const
 | 
			
		||||
 | 
			
		||||
void hwapi::sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const
 | 
			
		||||
{
 | 
			
		||||
    //uint8_t leng, data[66];
 | 
			
		||||
    epi_restoreDeviceConditions(leng, data);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//void hwapi::sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const
 | 
			
		||||
void hwapi::sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const
 | 
			
		||||
void hwapi::sys_getDeviceConditions(struct T_moduleCondition *devCond) const
 | 
			
		||||
{
 | 
			
		||||
    epi_restoreDeviceConditions(leng, data);
 | 
			
		||||
    uint16_t LL, nn;
 | 
			
		||||
    uint8_t *start;
 | 
			
		||||
    uint8_t  buf[70], leng;
 | 
			
		||||
 | 
			
		||||
    epi_restoreDeviceConditions(&leng, buf);
 | 
			
		||||
 | 
			
		||||
        // Puffer in struct eintragen:
 | 
			
		||||
    LL=sizeof(struct T_moduleCondition);
 | 
			
		||||
    start = &devCond->ram;
 | 
			
		||||
    nn=0;
 | 
			
		||||
    do
 | 
			
		||||
    {
 | 
			
		||||
        *start = buf[nn];
 | 
			
		||||
        start++;
 | 
			
		||||
    } while(++nn<LL);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void hwapi::sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const
 | 
			
		||||
{
 | 
			
		||||
    epi_restoreDynMachineConditions(leng, data);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void hwapi::sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    uint16_t LL, nn;
 | 
			
		||||
    char *start;
 | 
			
		||||
    uint8_t  buf[70], leng;
 | 
			
		||||
 | 
			
		||||
    epi_restoreDynMachineConditions(&leng, buf);
 | 
			
		||||
        // Puffer in struct eintragen:
 | 
			
		||||
    LL=sizeof(struct T_dynamicCondition);
 | 
			
		||||
    start = &dynMachCond->allDoorsDebounced;
 | 
			
		||||
    nn=0;
 | 
			
		||||
    do
 | 
			
		||||
    {
 | 
			
		||||
        *start = buf[nn];
 | 
			
		||||
        start++;
 | 
			
		||||
    } while(++nn<LL);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
uint32_t hwapi::cash_getAmountInVault(void) const
 | 
			
		||||
{
 | 
			
		||||
    return epi_getCashBoxContent();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint16_t hwapi::cash_getNrCoinsInVault(void) const
 | 
			
		||||
{
 | 
			
		||||
    return epi_getNrOfCoinsInCashBox();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
uint8_t hwapi::prn_getPrintResult() const
 | 
			
		||||
{
 | 
			
		||||
    // return:  0: unknown
 | 
			
		||||
    //          1: OK - last template was printed succesful
 | 
			
		||||
    //          2: error - last template was not printed
 | 
			
		||||
 | 
			
		||||
    struct T_dynamicCondition dynMachCon;
 | 
			
		||||
    //uint8_t  buf[70], leng,
 | 
			
		||||
    uint8_t res;
 | 
			
		||||
    static  uint8_t lastState;
 | 
			
		||||
    //uint32_t  aa;
 | 
			
		||||
 | 
			
		||||
   // aa=&dynMachCon;
 | 
			
		||||
    sys_getDynMachineConditions(&dynMachCon);
 | 
			
		||||
    res= dynMachCon.resultOfLastTemplPrint;
 | 
			
		||||
        // 0: unknown or printing in progress
 | 
			
		||||
        // 1: OK, doc was printed   2: error, doc was not printed
 | 
			
		||||
 | 
			
		||||
    if (res==0)
 | 
			
		||||
    {
 | 
			
		||||
        if (lastState>0)
 | 
			
		||||
        {
 | 
			
		||||
            // print was started
 | 
			
		||||
            lastState=res;
 | 
			
		||||
        }
 | 
			
		||||
    } else
 | 
			
		||||
    {
 | 
			
		||||
        if (lastState==0)
 | 
			
		||||
        {
 | 
			
		||||
            // result hat sich auf 1 oder 2 geändert, d.h. Druck ist fertig
 | 
			
		||||
            if (res==1)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                //emit    hwapi_templatePrintFinished_OK();
 | 
			
		||||
            } else
 | 
			
		||||
            if (res==2)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                //emit    hwapi_templatePrintFinished_Err();
 | 
			
		||||
            }
 | 
			
		||||
                lastState=res;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return res;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t hwapi::prn_getCurrentPrinterState() const
 | 
			
		||||
{
 | 
			
		||||
        //        0: printer OK
 | 
			
		||||
        //          bit0: near paper end          bit1: no paper
 | 
			
		||||
        //          bit2: temperature error       bit3: error head open
 | 
			
		||||
        //          bit4: paper jam in cutter
 | 
			
		||||
        //          bit6: no response             bit7: serial rec. error
 | 
			
		||||
        //			bit5: printer not ready
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    uint8_t     lastPrinterStatus;
 | 
			
		||||
    uint8_t  buf[70], leng;
 | 
			
		||||
 | 
			
		||||
    // 2nd way to get dyn.conditions:
 | 
			
		||||
    epi_restoreDynMachineConditions(&leng, buf);
 | 
			
		||||
    lastPrinterStatus=buf[53];
 | 
			
		||||
 | 
			
		||||
    return lastPrinterStatus;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -563,11 +563,17 @@ bool sendFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, ui
 | 
			
		||||
 | 
			
		||||
uint8_t check4FDshortCmd(void)
 | 
			
		||||
{
 | 
			
		||||
    // returns number of waiting command
 | 
			
		||||
    // returns number of waiting command, max FDCMD_STACKDEPTH
 | 
			
		||||
    return p_nextFDcmdsInQueue;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
uint8_t check4freeFDshortCmd(void)
 | 
			
		||||
{
 | 
			
		||||
    // returns number of free places in short-command stack
 | 
			
		||||
    return FDCMD_STACKDEPTH - p_nextFDcmdsInQueue;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// long command, 64 data bytes
 | 
			
		||||
static uint8_t longFDwrCmd[FDLONG_STACKDEPTH];
 | 
			
		||||
@@ -602,7 +608,7 @@ bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8
 | 
			
		||||
    uint8_t nn;
 | 
			
		||||
    if (p_longFDcmdsInQueue>=FDLONG_STACKDEPTH)
 | 
			
		||||
    {
 | 
			
		||||
        qCritical() << "cannot save cmd because stack is full";
 | 
			
		||||
        qDebug() << "cannot save cmd because stack is full";
 | 
			
		||||
        return false;           // not possible
 | 
			
		||||
    }
 | 
			
		||||
    longFDwrCmd[p_longFDcmdsInQueue]=nextWrCmd;
 | 
			
		||||
@@ -613,7 +619,6 @@ bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8
 | 
			
		||||
        longFDpara[p_longFDcmdsInQueue][nn]=data[nn];
 | 
			
		||||
 | 
			
		||||
    p_longFDcmdsInQueue++;
 | 
			
		||||
 | 
			
		||||
    return true;                // ok, will be sent
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -659,5 +664,10 @@ uint8_t check4FDlongCmd(void)
 | 
			
		||||
    return p_longFDcmdsInQueue;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t check4freeFDlongCmd(void)
 | 
			
		||||
{
 | 
			
		||||
    // returns number of free places in command stack
 | 
			
		||||
    return FDLONG_STACKDEPTH - p_longFDcmdsInQueue;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										39
									
								
								DCPlugin/src/shared_mem_buffer.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								DCPlugin/src/shared_mem_buffer.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
#include "shared_mem_buffer.h"
 | 
			
		||||
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <atomic>
 | 
			
		||||
 | 
			
		||||
#ifdef QT_POSIX_IPC
 | 
			
		||||
    // The POSIX backend can be explicitly selected using the -feature-ipc_posix
 | 
			
		||||
    // option to the Qt configure script. If it is enabled, the QT_POSIX_IPC
 | 
			
		||||
    // macro will be defined. -> we use SystemV shared memory
 | 
			
		||||
#error "QT_POSIX_IPC defined"
 | 
			
		||||
#else
 | 
			
		||||
#include <sys/ipc.h>    // ftok
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// std::atomic_bool SharedMemBuffer::__sharedMemLocked{false};
 | 
			
		||||
 | 
			
		||||
QSharedMemory *SharedMemBuffer::getShm(std::size_t size) {
 | 
			
		||||
    static QSharedMemory shMem;
 | 
			
		||||
    if (size > 0) {
 | 
			
		||||
        static const long nativeKey = ftok("/etc/os-release", 'H');
 | 
			
		||||
        static const QString fkey = std::to_string(nativeKey).c_str();
 | 
			
		||||
        shMem.setKey(fkey);
 | 
			
		||||
        if (!shMem.isAttached()) {
 | 
			
		||||
            if (shMem.create(size)) {
 | 
			
		||||
                return &shMem;
 | 
			
		||||
            } else {
 | 
			
		||||
                if (shMem.error() == QSharedMemory::AlreadyExists) {
 | 
			
		||||
                    if (shMem.attach()) {
 | 
			
		||||
                        return &shMem;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            qCritical() << shMem.nativeKey() << shMem.key() << shMem.data()
 | 
			
		||||
                        << shMem.error() << shMem.errorString();
 | 
			
		||||
            return nullptr;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return &shMem;
 | 
			
		||||
}
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -76,6 +76,23 @@ uint8_t uint2uchar(uint16_t uival, bool getHighB)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
uint8_t ulong2uchar(uint32_t ulval, uint8_t getBytNr)
 | 
			
		||||
{
 | 
			
		||||
    // getBytNr: 0=LSB  3=MSB
 | 
			
		||||
    uint32_t ultmp=ulval;
 | 
			
		||||
    if (getBytNr==0)
 | 
			
		||||
        return uint8_t(ultmp);
 | 
			
		||||
    ultmp>>=8;
 | 
			
		||||
    if (getBytNr==1)
 | 
			
		||||
        return uint8_t(ultmp);
 | 
			
		||||
    ultmp>>=8;
 | 
			
		||||
    if (getBytNr==2)
 | 
			
		||||
        return uint8_t(ultmp);
 | 
			
		||||
    ultmp>>=8;
 | 
			
		||||
    return uint8_t(ultmp);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void delay(uint16_t MilliSec)
 | 
			
		||||
{
 | 
			
		||||
    QThread::msleep(uint32_t(MilliSec));
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user