Merge from master-branch
This commit is contained in:
commit
23fe319497
BIN
build/CArunGui
Executable file
BIN
build/CArunGui
Executable file
Binary file not shown.
1147
build/carun_out.txt
Normal file
1147
build/carun_out.txt
Normal file
File diff suppressed because it is too large
Load Diff
BIN
build/dCArun
Executable file
BIN
build/dCArun
Executable file
Binary file not shown.
2492
build/interfaces.h
Executable file
2492
build/interfaces.h
Executable file
File diff suppressed because it is too large
Load Diff
BIN
build/libCAmaster.so
Executable file
BIN
build/libCAmaster.so
Executable file
Binary file not shown.
BIN
build/libCAslave.so
Executable file
BIN
build/libCAslave.so
Executable file
Binary file not shown.
601
include/shared_mem_buffer.h.new
Normal file
601
include/shared_mem_buffer.h.new
Normal file
@ -0,0 +1,601 @@
|
||||
#ifndef SHARED_MEM_BUFFER_INCLUDED_H
|
||||
#define SHARED_MEM_BUFFER_INCLUDED_H
|
||||
|
||||
#include <cinttypes>
|
||||
#include <atomic>
|
||||
|
||||
#include <QSharedMemory>
|
||||
#include <QtGlobal>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
bool shdMem_firstUse(void);
|
||||
|
||||
// Vorsicht: im shared memory ist kein QString erlaubt!!!!!!!!!!!!!!!!!!!!!!
|
||||
// nur standard C Typen!!!!!!
|
||||
// also auch kein QByteArray o.ä.
|
||||
|
||||
// Vorsicht: Zugriffe auf Comport NICHT ins shared mem --> Absturz!!!!
|
||||
|
||||
struct SharedMem
|
||||
{
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_1;
|
||||
#endif
|
||||
|
||||
// ------------------ Comport Control --------------------------------
|
||||
bool rs_portIsOpen;
|
||||
bool AutoEmissionOn;
|
||||
bool Sdata_serialTestResult;
|
||||
uint8_t Sdata_pProtResultOk;
|
||||
uint16_t Sdata_receivedDataLength;
|
||||
uint8_t Sdata_receivedDataBlock[64];
|
||||
uint8_t ndbs, pari, nsb, br;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_2;
|
||||
#endif
|
||||
|
||||
uint8_t Sdata_lastResult;
|
||||
uint8_t Sdata_OverallResult;
|
||||
bool Sdata_startSV;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_3;
|
||||
#endif
|
||||
|
||||
// ------------------ Data INPUT --------------------------------
|
||||
|
||||
bool indat_savePrnPwr;
|
||||
bool indat_saveMifPwr;
|
||||
bool indat_MdbIsOn;
|
||||
//QString indat_HWversion;
|
||||
//QString indat_SWversion;
|
||||
//QString indat_DCstate;
|
||||
|
||||
#define versionBufferLen 32
|
||||
char indat_HWversion[versionBufferLen];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_4;
|
||||
#endif
|
||||
|
||||
char indat_SWversion[versionBufferLen];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_5;
|
||||
#endif
|
||||
|
||||
char indat_DCstate[versionBufferLen];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_6;
|
||||
#endif
|
||||
|
||||
struct Sdata
|
||||
{
|
||||
uint64_t slaveUID;
|
||||
uint8_t UIDstr[8];
|
||||
} Sdata;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_7;
|
||||
#endif
|
||||
|
||||
struct T_globTime
|
||||
{
|
||||
// Reihenfolge nicht vertauschen!!!!!
|
||||
uint8_t hour;
|
||||
uint8_t minute;
|
||||
uint8_t second;
|
||||
uint8_t Year;
|
||||
uint8_t Month;
|
||||
uint8_t DayOfMonth;
|
||||
uint8_t DayOfWeek; // 1=monday...7
|
||||
uint8_t reserve1;
|
||||
|
||||
uint16_t MinutesOfToday;
|
||||
uint16_t reserve2;
|
||||
|
||||
uint32_t SecondsOfToday;
|
||||
|
||||
uint8_t IsLeapyear;
|
||||
uint8_t nextLeap;
|
||||
uint8_t lastLeap;
|
||||
uint8_t hoursOfWeek;
|
||||
|
||||
uint16_t minOfWeek;
|
||||
uint16_t hoursOfMonth;
|
||||
uint16_t minOfMonth;
|
||||
uint16_t dayOfYear;
|
||||
uint16_t hoursOfYear;
|
||||
uint16_t reserve3;
|
||||
|
||||
uint32_t minOfYear;
|
||||
|
||||
uint8_t squareOutMode;
|
||||
uint8_t free1;
|
||||
uint16_t reserve4;
|
||||
uint32_t minOfMillenium;
|
||||
// bis hierher 44byts
|
||||
uint32_t free2;
|
||||
uint32_t free3;
|
||||
uint32_t free4;
|
||||
|
||||
} getGlobalTime;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_8;
|
||||
#endif
|
||||
|
||||
#define MAXNROF_AI 4
|
||||
uint16_t AI_val[MAXNROF_AI];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_9;
|
||||
#endif
|
||||
|
||||
#define MAXNROF_MEASURE 4
|
||||
uint32_t Sdata_measurement[MAXNROF_MEASURE];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_10;
|
||||
#endif
|
||||
|
||||
uint8_t di_doorSwitch;
|
||||
uint8_t di_vaultSwitch;
|
||||
uint8_t di_lockSwitch;
|
||||
uint8_t di_opto;
|
||||
uint8_t di_aux;
|
||||
bool di_wakeFromPtu;
|
||||
bool di_wakeFromMdb;
|
||||
bool di_PrnReady;
|
||||
bool di_CoinAttach;
|
||||
bool di_CoinEscrowOpen;
|
||||
bool di_mifCardTap;
|
||||
bool di_wakeFromModem;
|
||||
bool di_contactPwrOn;
|
||||
bool di_mifarePwrOn;
|
||||
bool di_rdbk_mdbTxd;
|
||||
bool di_AuxPwrOn;
|
||||
bool di_gsmPwrOn;
|
||||
bool di_creditPwrOn;
|
||||
bool di_printerPwrOn;
|
||||
bool di_mdbPwrOn;
|
||||
bool di_rejMot_home;
|
||||
uint8_t di_npe_sensor;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_11;
|
||||
#endif
|
||||
|
||||
uint8_t do_mbdRxTst;
|
||||
uint8_t do_motorBits;
|
||||
uint8_t do_serialSwitch;
|
||||
uint8_t do_ledsAndFan;
|
||||
uint8_t do_laermUndRelay;
|
||||
uint8_t do_ptuWake;
|
||||
uint8_t do_auxPower;
|
||||
uint8_t do_coinShutter;
|
||||
uint8_t do_coinEscrow;
|
||||
uint8_t do_printerPower;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_12;
|
||||
#endif
|
||||
|
||||
//#define NROFMIFSTATEBYTES 40
|
||||
//uint8_t Sdata_MIF_STATE[NROFMIFSTATEBYTES];
|
||||
uint8_t Sdata_MIF_DATA[64];
|
||||
//uint8_t mif_cardType;
|
||||
//uint8_t mif_cardHolder[8];
|
||||
uint8_t Sdata_MIF_ATB[64];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_13;
|
||||
#endif
|
||||
|
||||
#define pi_prnStateArraySize 20
|
||||
uint8_t Sdata_PRN_STATE[pi_prnStateArraySize];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_14;
|
||||
#endif
|
||||
|
||||
#define pi_prnFontArraySize 20
|
||||
uint8_t Sdata_PRN_FONTS[pi_prnFontArraySize];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_15;
|
||||
#endif
|
||||
|
||||
bool Sdata_mdb_busRdy;
|
||||
bool Sdata_mdb_V12on;
|
||||
bool Sdata_mdb_V5on;
|
||||
|
||||
uint8_t Sdata_mdbNrOfRecData;
|
||||
uint8_t Sdata_RecBuff[40];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_16;
|
||||
#endif
|
||||
|
||||
uint8_t Sdata_empNrOfsettings;
|
||||
uint8_t Sdata_emp_settingsBuff[66];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_17;
|
||||
#endif
|
||||
|
||||
struct T_coin
|
||||
{
|
||||
uint8_t valid;
|
||||
uint8_t signal;
|
||||
uint8_t error;
|
||||
uint8_t pad;
|
||||
uint16_t value;
|
||||
};
|
||||
|
||||
#define MEMDEPTH_GOTCOINS 16
|
||||
struct T_coin gotCoin[MEMDEPTH_GOTCOINS];
|
||||
uint8_t ctr_gotCoin;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_18;
|
||||
#endif
|
||||
|
||||
uint8_t Sdata_NrOfDeviceSetting;
|
||||
uint8_t Sdata_DeviceSettingBuff[66];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_19;
|
||||
#endif
|
||||
|
||||
uint8_t SizeMachineIDBuff;
|
||||
uint8_t MachineIDBuff[66];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_20;
|
||||
#endif
|
||||
|
||||
uint32_t store_insertedAmount;
|
||||
uint16_t store_lastCoinType[64];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_21;
|
||||
#endif
|
||||
|
||||
uint16_t store_lastCoinValue[64];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_22;
|
||||
#endif
|
||||
|
||||
uint8_t p_lastCoin;
|
||||
char store_curPayNewCoin;
|
||||
|
||||
uint64_t stor_wakSrc;
|
||||
uint8_t stor_reason;
|
||||
|
||||
uint8_t store_rbDevParamLen;
|
||||
uint8_t store_rbDevParams[66];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_23;
|
||||
#endif
|
||||
|
||||
uint8_t store_deviceCondLen;
|
||||
uint8_t store_deviceCond[66];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_24;
|
||||
#endif
|
||||
|
||||
uint8_t store_machCondLen;
|
||||
uint8_t store_machCond[66];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_25;
|
||||
#endif
|
||||
|
||||
uint8_t store_DcBackupNrOfAccNr;
|
||||
uint16_t store_DcBackupAccNr[16]; // z.Z. nur 8
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_26;
|
||||
#endif
|
||||
|
||||
#define PI_SIZOFVAULTRECORD 400
|
||||
uint8_t store_gotNrBlocksOfVaultRec;
|
||||
uint8_t store_vaultrecord[PI_SIZOFVAULTRECORD];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_27;
|
||||
#endif
|
||||
|
||||
uint32_t store_amount;
|
||||
uint16_t store_nrOfCoins;
|
||||
|
||||
bool store_DcDataAreValid;
|
||||
|
||||
uint8_t storeDCdynPrinterData[64];
|
||||
uint8_t DCdynPrinterDataActual;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_28;
|
||||
#endif
|
||||
|
||||
uint16_t store_DCNextAccountNumber;
|
||||
|
||||
uint16_t storeMifCardTypDataLen;
|
||||
uint8_t storeMcardTypData[64];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_29;
|
||||
#endif
|
||||
|
||||
// new from 6.9.23:
|
||||
#define RAW_BL_DATALEN 150
|
||||
uint8_t Sdata_rawData[RAW_BL_DATALEN];
|
||||
uint8_t Sdata_LengthRawData;
|
||||
|
||||
#define numberOfJsons 36
|
||||
#define versionStringLength 16
|
||||
char store_jsonVersion[versionStringLength][numberOfJsons];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_30;
|
||||
#endif
|
||||
|
||||
uint8_t Sdata_changeResult;
|
||||
uint32_t Sdata_changedAmount;
|
||||
uint8_t store_tubeLev[64];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_31;
|
||||
#endif
|
||||
|
||||
uint8_t store_bnaParameter[64];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_32;
|
||||
#endif
|
||||
|
||||
uint8_t store_bnaCollect[8];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_33;
|
||||
#endif
|
||||
|
||||
uint8_t store_bnaContent[64];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_34;
|
||||
#endif
|
||||
|
||||
|
||||
// Mitteilung von Hwapi zu Datif:
|
||||
bool Sdata_coinPaymentNow;
|
||||
bool Sdata_bootloadingNow;
|
||||
|
||||
|
||||
// ------------------ Data OUTPUT --------------------------------
|
||||
|
||||
// sendWRcmd.cpp
|
||||
#define CMDSTACKDEPTH 16
|
||||
uint16_t nextAsynchsendCmd0[CMDSTACKDEPTH];
|
||||
uint8_t nrOfCmdsInQueue;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_35;
|
||||
#endif
|
||||
|
||||
#define CMD4STACKDEPTH 8
|
||||
uint16_t nextAsynchsendCmd4[CMD4STACKDEPTH];
|
||||
uint8_t nextCmd4para1[CMD4STACKDEPTH];
|
||||
uint8_t nextCmd4para2[CMD4STACKDEPTH];
|
||||
uint8_t nextCmd4para3[CMD4STACKDEPTH];
|
||||
uint8_t nextCmd4para4[CMD4STACKDEPTH];
|
||||
uint8_t nrOfCmds4InQueue;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_36;
|
||||
#endif
|
||||
|
||||
#define CMD8STACKDEPTH 4
|
||||
uint16_t nextAsynchsendCmd8[CMD8STACKDEPTH];
|
||||
uint8_t nextCmd8para1[CMD8STACKDEPTH];
|
||||
uint8_t nextCmd8para2[CMD8STACKDEPTH];
|
||||
uint16_t nextCmd8para3[CMD8STACKDEPTH];
|
||||
uint32_t nextCmd8para4[CMD8STACKDEPTH];
|
||||
uint8_t nrOfCmds8InQueue;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_37;
|
||||
#endif
|
||||
|
||||
#define SENDASYDAT_BUFFSIZE 200
|
||||
uint8_t sendAsynchDataBuf[SENDASYDAT_BUFFSIZE]; // no stack, only ONE buffer
|
||||
uint8_t sendAsyDatLen;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_38;
|
||||
#endif
|
||||
|
||||
#define MDBSEND_BUFFSIZE 64
|
||||
uint8_t Sdata_mdbSendBuffer[MDBSEND_BUFFSIZE];
|
||||
uint8_t Sdata_mdbSendLen;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_39;
|
||||
#endif
|
||||
|
||||
uint8_t prnDataParameters[4];
|
||||
uint8_t prnDataBufferUser;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_40;
|
||||
#endif
|
||||
|
||||
|
||||
// ONE printer doc consists of 20 x 64 byte
|
||||
#define MAXNROF_PRNBYTES 64
|
||||
#define MAXNROF_PRNBLOCKS 20
|
||||
char Sdata_PRN_TEXT[MAXNROF_PRNBLOCKS][MAXNROF_PRNBYTES];
|
||||
uint8_t pPrnDataBuff; // points to next PRINTER_BLOCK
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_41;
|
||||
#endif
|
||||
|
||||
//#define FDCMD_STACKDEPTH 16 // up to 1024 byte
|
||||
#define FDCMD_STACKDEPTH 32 // up to 2048 byte
|
||||
// header
|
||||
uint8_t nextFDwrCmd[FDCMD_STACKDEPTH];
|
||||
uint8_t nextFDrdCmd[FDCMD_STACKDEPTH];
|
||||
uint8_t nextFDblkNr[FDCMD_STACKDEPTH];
|
||||
uint8_t nextFDshort[FDCMD_STACKDEPTH];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_42;
|
||||
#endif
|
||||
|
||||
// short data
|
||||
uint8_t nextFDpara1[FDCMD_STACKDEPTH];
|
||||
uint8_t nextFDpara2[FDCMD_STACKDEPTH];
|
||||
uint8_t nextFDpara3[FDCMD_STACKDEPTH];
|
||||
uint8_t nextFDpara4[FDCMD_STACKDEPTH];
|
||||
// long data:
|
||||
uint8_t longFDlength[FDCMD_STACKDEPTH];
|
||||
uint8_t longFDpara[FDCMD_STACKDEPTH][64];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_43;
|
||||
#endif
|
||||
|
||||
uint8_t p_nextFDcmdsInQueue;
|
||||
|
||||
// download of device controller and json files
|
||||
struct DCDownload {
|
||||
enum class FILE_INDEX {
|
||||
DC_BINARY = 0, DC2C_CASH = 1, DC2C_CONF = 2, DC2C_SERIAL=3,
|
||||
DC2C_PRINT_01, DC2C_PRINT_02, DC2C_PRINT_03, DC2C_PRINT_04,
|
||||
DC2C_PRINT_05, DC2C_PRINT_06, DC2C_PRINT_07, DC2C_PRINT_08,
|
||||
DC2C_PRINT_09, DC2C_PRINT_10, DC2C_PRINT_11, DC2C_PRINT_12,
|
||||
DC2C_PRINT_13, DC2C_PRINT_14, DC2C_PRINT_15, DC2C_PRINT_16,
|
||||
DC2C_PRINT_17, DC2C_PRINT_18, DC2C_PRINT_19, DC2C_PRINT_20,
|
||||
DC2C_PRINT_21, DC2C_PRINT_22, DC2C_PRINT_23, DC2C_PRINT_24,
|
||||
DC2C_PRINT_25, DC2C_PRINT_26, DC2C_PRINT_27, DC2C_PRINT_28,
|
||||
DC2C_PRINT_29, DC2C_PRINT_30, DC2C_PRINT_31, DC2C_PRINT_32
|
||||
};
|
||||
char m_filename[(int)FILE_INDEX::DC2C_PRINT_32][512];
|
||||
std::atomic_ushort m_totalBlocks;
|
||||
std::atomic_ushort m_currentblockNumber;
|
||||
std::atomic_bool m_requested{false};
|
||||
std::atomic_bool m_running{false};
|
||||
std::atomic_bool m_finished{false};
|
||||
} m_downLoadDC;
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_44;
|
||||
#endif
|
||||
|
||||
// meta-data
|
||||
char os_release[64];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_45;
|
||||
#endif
|
||||
|
||||
char date_of_creation[32];
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_46;
|
||||
#endif
|
||||
|
||||
char creator[128]; // name of application plus pid
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_47;
|
||||
#endif
|
||||
|
||||
static QSharedMemory *getShm(std::size_t s = 0);
|
||||
|
||||
static SharedMem *getData()
|
||||
{
|
||||
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
|
||||
return (SharedMem *)getShm()->data();
|
||||
}
|
||||
|
||||
static SharedMem const *getDataConst()
|
||||
{
|
||||
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
|
||||
return (SharedMem const *)getShm()->data();
|
||||
}
|
||||
|
||||
// static SharedMemBuffer *write()
|
||||
static SharedMem *write()
|
||||
{
|
||||
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
|
||||
return (SharedMem *)getShm()->data();
|
||||
}
|
||||
|
||||
// static SharedMemBuffer const *read()
|
||||
static SharedMem const *read()
|
||||
{
|
||||
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
|
||||
return (SharedMem const *)getShm()->data();
|
||||
}
|
||||
|
||||
bool thisIsTheFirstUse(void);
|
||||
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
char mem_guard_0;
|
||||
#endif
|
||||
|
||||
static void check_mem_guards() {
|
||||
#ifndef QT_NO_DEBUG
|
||||
static const char memcmp_array[48] = {0,};
|
||||
char mem[48];
|
||||
|
||||
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
|
||||
SharedMem const *d = (SharedMem const *)getShm()->data();
|
||||
|
||||
mem[0] = d->mem_guard_0;
|
||||
mem[1] = d->mem_guard_1; mem[2] = d->mem_guard_2; mem[3] = d->mem_guard_3;
|
||||
mem[4] = d->mem_guard_4; mem[5] = d->mem_guard_5; mem[6] = d->mem_guard_6;
|
||||
mem[7] = d->mem_guard_7; mem[8] = d->mem_guard_8; mem[9] = d->mem_guard_9;
|
||||
|
||||
mem[10] = d->mem_guard_10;
|
||||
mem[11] = d->mem_guard_11; mem[12] = d->mem_guard_12; mem[13] = d->mem_guard_13;
|
||||
mem[14] = d->mem_guard_14; mem[15] = d->mem_guard_15; mem[16] = d->mem_guard_16;
|
||||
mem[17] = d->mem_guard_17; mem[18] = d->mem_guard_18; mem[19] = d->mem_guard_19;
|
||||
|
||||
mem[20] = d->mem_guard_20;
|
||||
mem[21] = d->mem_guard_21; mem[22] = d->mem_guard_22; mem[23] = d->mem_guard_23;
|
||||
mem[24] = d->mem_guard_24; mem[25] = d->mem_guard_25; mem[26] = d->mem_guard_26;
|
||||
mem[27] = d->mem_guard_27; mem[28] = d->mem_guard_28; mem[29] = d->mem_guard_29;
|
||||
|
||||
mem[30] = d->mem_guard_30;
|
||||
mem[31] = d->mem_guard_31; mem[32] = d->mem_guard_32; mem[33] = d->mem_guard_33;
|
||||
mem[34] = d->mem_guard_34; mem[35] = d->mem_guard_35; mem[36] = d->mem_guard_36;
|
||||
mem[37] = d->mem_guard_37; mem[38] = d->mem_guard_38; mem[39] = d->mem_guard_39;
|
||||
|
||||
mem[40] = d->mem_guard_40;
|
||||
mem[41] = d->mem_guard_41; mem[42] = d->mem_guard_42; mem[43] = d->mem_guard_43;
|
||||
mem[44] = d->mem_guard_44; mem[45] = d->mem_guard_45; mem[46] = d->mem_guard_46;
|
||||
mem[47] = d->mem_guard_47;
|
||||
|
||||
if (memcmp(mem, memcmp_array, sizeof(memcmp_array))) {
|
||||
qCritical() << QByteArray(mem, sizeof(memcmp_array)).toHex(':');
|
||||
for (uint i = 0; i < sizeof(memcmp_array); ++i) {
|
||||
fprintf(stderr, "%02d -> %02x", i, (unsigned char)mem[i]);
|
||||
} fprintf(stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // SHARED_MEM_BUFFER_INCLUDED_H
|
@ -3349,21 +3349,15 @@ void hwapi::sys_restoreDeviceParameter(struct T_devices *deviceSettings) const
|
||||
// attention: only applies if function "sys_sendDeviceParameter()" was used to send this settings before
|
||||
// cannot be used to see settings programmed by JsonFile
|
||||
uint8_t buf[64];
|
||||
uint8_t LL, nn;
|
||||
uint8_t LL;
|
||||
tslib_strclr(buf,0,64);
|
||||
uint8_t *start;
|
||||
|
||||
//runProcess->epi_restore64BdevParameter(&LL, buf); // wozu die???
|
||||
epi_restoreRbDeviceSettings(&LL, buf); // viel besser, stimmt immer
|
||||
|
||||
// Puffer in struct eintragen:
|
||||
start = &deviceSettings->kindOfPrinter;
|
||||
nn=0;
|
||||
do
|
||||
{
|
||||
*start = buf[nn];
|
||||
start++;
|
||||
} while(++nn<LL);
|
||||
Q_STATIC_ASSERT(sizeof(*deviceSettings) <= sizeof(buf));
|
||||
|
||||
memcpy(deviceSettings, buf, sizeof(*deviceSettings));
|
||||
}
|
||||
|
||||
bool hwapi::sys_areDCdataValid(void) const
|
||||
|
232
src/shared_mem_buffer.cpp.new
Normal file
232
src/shared_mem_buffer.cpp.new
Normal file
@ -0,0 +1,232 @@
|
||||
#include "shared_mem_buffer.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QString>
|
||||
#include <QTextStream>
|
||||
#include <QDateTime>
|
||||
#include <QCoreApplication>
|
||||
#include <atomic>
|
||||
#include <algorithm>
|
||||
|
||||
#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
|
||||
#ifdef linux
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/ipc.h> // ftok
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//static bool shdMemFirstUse;
|
||||
|
||||
static QString read1stLineOfFile(QString fileName) { // read for instance /etc/os-release
|
||||
QFile f(fileName);
|
||||
if (f.exists()) {
|
||||
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&f);
|
||||
in.setCodec("UTF-8");
|
||||
while(!in.atEnd()) {
|
||||
return in.readLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
|
||||
//QSharedMemory *SharedMemBuffer::getShm(std::size_t size) {
|
||||
QSharedMemory *SharedMem::getShm(std::size_t size) {
|
||||
static QSharedMemory shMem;
|
||||
if (size > 0) {
|
||||
#ifdef linux
|
||||
static const long nativeKey = ftok("/etc/os-release", 'H');
|
||||
static const QString fkey = std::to_string(nativeKey).c_str();
|
||||
//static const QString fkey = "0123456?000=7";
|
||||
#else
|
||||
static const QString fkey = "0123456?000=9";
|
||||
#endif
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": size" << size;
|
||||
|
||||
shMem.setKey(fkey);
|
||||
if (!shMem.isAttached()) {
|
||||
if (shMem.create(size)) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << ": created shared memory";
|
||||
|
||||
#ifdef linux
|
||||
if ((size != (std::size_t)shMem.size()) || (sizeof(SharedMem) != shMem.size())) {
|
||||
qCritical() << __func__ << ":" << __LINE__
|
||||
<< "size=" << size
|
||||
<< "shMem.size=" << shMem.size()
|
||||
<< "sizeof(SharedMem)=" << sizeof(SharedMem)
|
||||
<< "ABOUT TO REBOOT SYSTEM...";
|
||||
if (system("reboot")) {
|
||||
// reboot system -> shared memory re-created
|
||||
}
|
||||
}
|
||||
|
||||
struct SharedMem *sh = (SharedMem *)(shMem.data());
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
sh->mem_guard_0 = 0;
|
||||
sh->mem_guard_1 = 0; sh->mem_guard_2 = 0; sh->mem_guard_3 = 0;
|
||||
sh->mem_guard_4 = 0; sh->mem_guard_5 = 0; sh->mem_guard_6 = 0;
|
||||
sh->mem_guard_7 = 0; sh->mem_guard_8 = 0; sh->mem_guard_9 = 0;
|
||||
|
||||
sh->mem_guard_10 = 0;
|
||||
sh->mem_guard_11 = 0; sh->mem_guard_12 = 0; sh->mem_guard_13 = 0;
|
||||
sh->mem_guard_14 = 0; sh->mem_guard_15 = 0; sh->mem_guard_16 = 0;
|
||||
sh->mem_guard_17 = 0; sh->mem_guard_18 = 0; sh->mem_guard_19 = 0;
|
||||
|
||||
sh->mem_guard_20 = 0;
|
||||
sh->mem_guard_21 = 0; sh->mem_guard_22 = 0; sh->mem_guard_23 = 0;
|
||||
sh->mem_guard_24 = 0; sh->mem_guard_25 = 0; sh->mem_guard_26 = 0;
|
||||
sh->mem_guard_27 = 0; sh->mem_guard_28 = 0; sh->mem_guard_29 = 0;
|
||||
|
||||
sh->mem_guard_30 = 0;
|
||||
sh->mem_guard_31 = 0; sh->mem_guard_32 = 0; sh->mem_guard_33 = 0;
|
||||
sh->mem_guard_34 = 0; sh->mem_guard_35 = 0; sh->mem_guard_36 = 0;
|
||||
sh->mem_guard_37 = 0; sh->mem_guard_38 = 0; sh->mem_guard_39 = 0;
|
||||
|
||||
sh->mem_guard_40 = 0;
|
||||
sh->mem_guard_41 = 0; sh->mem_guard_42 = 0; sh->mem_guard_43 = 0;
|
||||
sh->mem_guard_44 = 0; sh->mem_guard_45 = 0; sh->mem_guard_46 = 0;
|
||||
sh->mem_guard_47 = 0;
|
||||
#endif
|
||||
|
||||
memset(sh->indat_HWversion, 0x00, sizeof(sh->indat_HWversion));
|
||||
memset(sh->indat_SWversion, 0x00, sizeof(sh->indat_SWversion));
|
||||
|
||||
memset(sh->os_release, 0x00, sizeof(sh->os_release));
|
||||
memset(sh->date_of_creation, 0x00, sizeof(sh->date_of_creation));
|
||||
memset(sh->creator, 0x00, sizeof(sh->creator));
|
||||
|
||||
QString const &os_release = read1stLineOfFile("/etc/os-release");
|
||||
strncpy(sh->os_release, os_release.toStdString().c_str(),
|
||||
std::min((int)os_release.size(), (int)sizeof(sh->os_release)-1));
|
||||
|
||||
QString const ¤tDateTime = QDateTime::currentDateTime().toString(Qt::ISODate);
|
||||
char const *current = currentDateTime.toUtf8().constData();
|
||||
strncpy(sh->date_of_creation, current,
|
||||
std::min((int)strlen(current), (int)sizeof(sh->date_of_creation)-1));
|
||||
|
||||
QString const &appPid = QString("%1 (%2)").arg(QCoreApplication::applicationName())
|
||||
.arg(QCoreApplication::applicationPid());
|
||||
|
||||
strncpy(sh->creator, appPid.toStdString().c_str(),
|
||||
std::min((int)strlen(appPid.toStdString().c_str()),
|
||||
(int)sizeof(sh->creator)-1));
|
||||
|
||||
qCritical() << "os-release:" << sh->os_release;
|
||||
qCritical() << " creator:" << sh->creator;
|
||||
qCritical() << " date:" << sh->date_of_creation;
|
||||
|
||||
#else
|
||||
Q_ASSERT_X(size != shMem.size(), "compare sizes", "sizes different");
|
||||
Q_ASSERT_X(sizeof(SharedMem) != shMem.size(), "compare sizes", "sizes different");
|
||||
#endif
|
||||
return &shMem;
|
||||
} else {
|
||||
if (shMem.error() == QSharedMemory::AlreadyExists) {
|
||||
if (shMem.attach()) {
|
||||
#ifdef linux
|
||||
if ((size != (std::size_t)shMem.size()) || (sizeof(SharedMem) != shMem.size())) {
|
||||
qCritical() << __func__ << ":" << __LINE__
|
||||
<< "size=" << size
|
||||
<< "shMem.size=" << shMem.size()
|
||||
<< "sizeof(SharedMem)=" << sizeof(SharedMem)
|
||||
<< "ABOUT TO REBOOT SYSTEM...";
|
||||
if (system("reboot")) {
|
||||
// reboot system -> shared memory re-created
|
||||
}
|
||||
}
|
||||
#else
|
||||
Q_ASSERT_X(size != shMem.size(), "compare sizes", "sizes different");
|
||||
Q_ASSERT_X(sizeof(SharedMem) != shMem.size(), "compare sizes", "sizes different");
|
||||
#endif
|
||||
|
||||
QString const &appPid = QString("%1 (%2)").arg(QCoreApplication::applicationName())
|
||||
.arg(QCoreApplication::applicationPid());
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << appPid << "attached shared memory";
|
||||
|
||||
struct SharedMem const *sh = (SharedMem const *)(shMem.data());
|
||||
qCritical() << "os-release:" << sh->os_release;
|
||||
qCritical() << " creator:" << sh->creator;
|
||||
qCritical() << " date:" << sh->date_of_creation;
|
||||
|
||||
return &shMem;
|
||||
}
|
||||
}
|
||||
}
|
||||
qCritical() << shMem.nativeKey() << shMem.key() << shMem.data()
|
||||
<< shMem.error() << shMem.errorString();
|
||||
return nullptr;
|
||||
} else {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "shared memory already attached";
|
||||
|
||||
struct SharedMem const *sh = (SharedMem const *)(shMem.data());
|
||||
qCritical() << "os-release:" << sh->os_release;
|
||||
qCritical() << " creator:" << sh->creator;
|
||||
qCritical() << " date:" << sh->date_of_creation;
|
||||
}
|
||||
}
|
||||
return &shMem;
|
||||
}
|
||||
|
||||
|
||||
// std::atomic_bool SharedMemBuffer::__sharedMemLocked{false};
|
||||
/*
|
||||
//QSharedMemory *SharedMemBuffer::getShm(std::size_t size) {
|
||||
QSharedMemory *SharedMem::getShm(std::size_t size) {
|
||||
|
||||
static QSharedMemory shMem;
|
||||
if (size > 0) {
|
||||
#ifdef __linux__
|
||||
static const long nativeKey = ftok("/etc/os-release", 'H');
|
||||
static const QString fkey = std::to_string(nativeKey).c_str();
|
||||
#else
|
||||
static const QString fkey = "0123456?000=9";
|
||||
#endif
|
||||
shdMemFirstUse=false;
|
||||
shMem.setKey(fkey);
|
||||
if (!shMem.isAttached())
|
||||
{
|
||||
if (shMem.create(size))
|
||||
{
|
||||
// sm was created successful, did not exist before
|
||||
shdMemFirstUse=true;
|
||||
return &shMem;
|
||||
} else
|
||||
{
|
||||
// create was false because mem already existed
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
bool shdMem_firstUse(void)
|
||||
{
|
||||
return shdMemFirstUse;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user