Compare commits

..

No commits in common. "01140c523b600912e83302c988059c1cfd0a5488" and "1eb2ac3a1df01a7af3244f6fe495a8b143d946bf" have entirely different histories.

4 changed files with 144 additions and 66 deletions

View File

@ -170,7 +170,7 @@ uint8_t epi_getResultOfLastRequest();
// retval: 0: in progress 1: OK 2: error
void gpi_storeRecPayLoad(uint8_t RdDlen, uint8_t const *receivedData);
void gpi_storeRecPayLoad(uint8_t RdDlen, uint8_t *receivedData);
// stored by Datif
uint16_t epi_getLastPayLoad(uint16_t plBufSiz, uint8_t *payLoad);

View File

@ -189,10 +189,6 @@ struct SharedMemBuffer {
uint8_t UIDstr[8];
#define MAXNROF_MEASURE 4
uint32_t measurement[MAXNROF_MEASURE];
bool serialTestResult;
uint8_t pProtResultOk;
uint16_t receivedDataLength;
uint8_t receivedDataBlock[64];
} Sdata;
uint8_t mif_cardType;

View File

@ -1,14 +1,19 @@
#include <stdint.h>
#include <algorithm>
#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
void epi_setSerial(int BaudNr,
QString BaudStr,
QString ComName,
@ -33,6 +38,7 @@ void epi_closeSerial(void) {
SharedMemBuffer::getData()->rs.connect = 0;
}
void gpi_serialChanged(void) {
// serial confirms that port was closed or opened
// rs_connect=2; // Flanke, nur 1x öffnen/schließen
@ -43,6 +49,7 @@ uint8_t gpi_getSerialConn(void) {
return SharedMemBuffer::getDataConst()->rs.connect;
}
int gpi_getBaudNr(void) {
return SharedMemBuffer::getDataConst()->rs.baudNr;
}
@ -99,12 +106,14 @@ bool gpi_PeriodicSendTimeHasChanged() {
// linke Spalte, über Connect Button
static QString txt4comStateLine;
QString epi_getTxt4comStateLine(void) {
QString epi_getTxt4comStateLine(void)
{
// GUI: get Text for serial Comport-State Line
return txt4comStateLine;
}
void gpi_setTxt4comStateLine(QString txtline) {
void gpi_setTxt4comStateLine(QString txtline) // gpi
{
// serial: write Text to be displayed in serial Comport-State line (like "connected")
txt4comStateLine.clear();
if (txtline=="")
@ -113,20 +122,26 @@ void gpi_setTxt4comStateLine(QString txtline) {
txt4comStateLine=txtline;
}
void epi_clrTxt4comStateLine() {
void epi_clrTxt4comStateLine()
{
txt4comStateLine.clear();
}
//---------------------------------------------------------------------------------------------
// rechte Spalte, oberste Statuszeile
// I) "Handshakes" (serial Control) flow.cpp
// geht überhaupt was raus? kommt überhaupt was zurück?
static QString txt4HsStateLine;
QString epi_getTxt4HsStateLine(void) {
QString epi_getTxt4HsStateLine(void)
{
return txt4HsStateLine;
}
void gpi_setTxt4HsStateLine(QString txtline) {
void gpi_setTxt4HsStateLine(QString txtline)
{
txt4HsStateLine.clear();
if (txtline=="")
txt4HsStateLine.clear();
@ -134,19 +149,26 @@ void gpi_setTxt4HsStateLine(QString txtline) {
txt4HsStateLine=txtline;
}
void epi_clrTxt4HsStateLine() {
void epi_clrTxt4HsStateLine()
{
txt4HsStateLine.clear();
}
//---------------------------------------------------------------------------------------------
// II) Master receive state (empfangenes Telgramm OK? crc? length? )
// Statuszeile Auswertung der SlaveResponse (serial Frame, CRC usw) (prot.cpp)
static QString txt4masterStateLine;
QString epi_getTxt4masterStateLine(void) {
QString epi_getTxt4masterStateLine(void)
{
return txt4masterStateLine;
}
void gpi_setTxt4masterStateLine(QString txtline) {
void gpi_setTxt4masterStateLine(QString txtline)
{
txt4masterStateLine.clear();
if (txtline=="")
txt4masterStateLine.clear();
@ -154,10 +176,13 @@ void gpi_setTxt4masterStateLine(QString txtline) {
txt4masterStateLine=txtline;
}
void epi_clrTxt4masterStateLine() {
void epi_clrTxt4masterStateLine()
{
txt4masterStateLine.clear();
}
//---------------------------------------------------------------------------------------------
// III Slave receive (from Master) OK? if then show results, if not then show errors
@ -167,11 +192,13 @@ void epi_clrTxt4masterStateLine() {
static QString txt4resultStateLine;
QString epi_getTxt4resultStateLine(void) {
QString epi_getTxt4resultStateLine(void)
{
return txt4resultStateLine;
}
void gpi_setTxt4resultStateLine(QString txtline) {
void gpi_setTxt4resultStateLine(QString txtline)
{
txt4resultStateLine.clear();
if (txtline=="")
txt4resultStateLine.clear();
@ -179,22 +206,26 @@ void gpi_setTxt4resultStateLine(QString txtline) {
txt4resultStateLine=txtline;
}
void epi_clrTxt4resultStateLine() {
void epi_clrTxt4resultStateLine()
{
txt4resultStateLine.clear();
}
//---------------------------------------------------------------------------------------------
// IV Statuszeile Empfangsdaten
static QString txt4dataLine;
QString epi_getTxt4dataStateLine(void) {
QString epi_getTxt4dataStateLine(void)
{
// GUI: get Text for serial Comport-State Line
return txt4dataLine;
}
void gpi_setTxt4dataStateLine(QString txtline) {
void gpi_setTxt4dataStateLine(QString txtline)
{
// serial: write Text to be displayed in serial Comport-State line (like "connected")
txt4dataLine.clear();
if (txtline=="")
@ -203,7 +234,8 @@ void gpi_setTxt4dataStateLine(QString txtline) {
txt4dataLine=txtline;
}
void epi_clrTxt4dataStateLine() {
void epi_clrTxt4dataStateLine()
{
txt4dataLine.clear();
}
@ -213,11 +245,16 @@ void epi_clrTxt4dataStateLine() {
static QString txt4datifReceive;
QString epi_getTxt4datifLine(void) {
QString epi_getTxt4datifLine(void)
{
return txt4datifReceive;
}
void gpi_setTxt4datifLine(QString txtline) {
void gpi_setTxt4datifLine(QString txtline)
{
txt4datifReceive.clear();
if (txtline=="")
txt4datifReceive.clear();
@ -225,7 +262,8 @@ void gpi_setTxt4datifLine(QString txtline) {
txt4datifReceive=txtline;
}
void epi_clrTxt4datifLine() {
void epi_clrTxt4datifLine()
{
txt4datifReceive.clear();
}
@ -234,11 +272,14 @@ void epi_clrTxt4datifLine() {
static QString txt4diagWindow;
QString epi_getTxt4RsDiagWin(void) {
QString epi_getTxt4RsDiagWin(void)
{
return txt4diagWindow;
}
void gpi_setTxt4RsDiagWin(QString txtline) {
void gpi_setTxt4RsDiagWin(QString txtline)
{
txt4diagWindow.clear();
if (txtline=="")
txt4diagWindow.clear();
@ -246,7 +287,8 @@ void gpi_setTxt4RsDiagWin(QString txtline) {
txt4diagWindow=txtline;
}
void epi_clrTxt4RsDiagWin() {
void epi_clrTxt4RsDiagWin()
{
txt4diagWindow.clear();
}
@ -254,11 +296,14 @@ void epi_clrTxt4RsDiagWin() {
static QString sndTxt4diagWindow;
QString epi_get2ndTxt4RsDiagWin(void) {
QString epi_get2ndTxt4RsDiagWin(void)
{
return sndTxt4diagWindow;
}
void gpi_set2ndTxt4RsDiagWin(QString txtline) {
void gpi_set2ndTxt4RsDiagWin(QString txtline)
{
sndTxt4diagWindow.clear();
if (txtline=="")
sndTxt4diagWindow.clear();
@ -266,61 +311,90 @@ void gpi_set2ndTxt4RsDiagWin(QString txtline) {
sndTxt4diagWindow=txtline;
}
void epi_clr2ndTxt4RsDiagWin() {
void epi_clr2ndTxt4RsDiagWin()
{
sndTxt4diagWindow.clear();
}
// ///////////////////////////////////////////////////////////////////////////////////
// Memory for Slave responses, common data
// ///////////////////////////////////////////////////////////////////////////////////
void gpi_storeResult_serialTestOK(bool wasOk) {
SharedMemBuffer::getData()->Sdata.serialTestResult = wasOk;
static bool Sdata_serialTestResult;
void gpi_storeResult_serialTestOK(bool wasOk)
{
Sdata_serialTestResult=wasOk;
}
bool epi_getResult_serialTestOK() {
bool epi_getResult_serialTestOK()
{
// retval: true: test was successful, got right response
return SharedMemBuffer::getDataConst()->Sdata.serialTestResult;
return Sdata_serialTestResult;
}
// ///////////////////////////////////////////////////////////////////////////////////
// Store received data for hwapi
// ///////////////////////////////////////////////////////////////////////////////////
void gpi_startNewRequest() {
SharedMemBuffer::getData()->Sdata.pProtResultOk = 0;
static uint8_t Sdata_pProtResultOk;
void gpi_startNewRequest()
{
Sdata_pProtResultOk=0;
}
void gpi_storeResultOfLastRequest(bool answisok) {
SharedMemBuffer::getData()->Sdata.pProtResultOk = answisok ? 1 : 2;
void gpi_storeResultOfLastRequest(bool answisok)
{
if (answisok)
Sdata_pProtResultOk=1;
else
Sdata_pProtResultOk=2;
}
uint8_t epi_getResultOfLastRequest() {
uint8_t epi_getResultOfLastRequest()
{
// retval: 0: in progress 1: OK 2: error
return SharedMemBuffer::getDataConst()->Sdata.pProtResultOk;
return Sdata_pProtResultOk;
}
void gpi_storeRecPayLoad(uint8_t RdDlen, uint8_t const *receivedData) {
SharedMemBuffer::getData()->Sdata.receivedDataLength
= std::min(RdDlen, (uint8_t)(64));
memset((char *)(&SharedMemBuffer::getData()->Sdata.receivedDataBlock[0]),
0x00, sizeof(SharedMemBuffer::getData()->Sdata.receivedDataBlock));
strncpy((char *)(&SharedMemBuffer::getData()->Sdata.receivedDataBlock[0]),
(char const *)receivedData,
sizeof(SharedMemBuffer::getData()->Sdata.receivedDataBlock)-1);
static uint16_t Sdata_receivedDataLength;
static uint8_t Sdata_receivedDataBlock[64];
void gpi_storeRecPayLoad(uint8_t RdDlen, uint8_t *receivedData)
{
Sdata_receivedDataLength=uint16_t(RdDlen);
if (Sdata_receivedDataLength>64)
Sdata_receivedDataLength=64;
tslib_strclr(Sdata_receivedDataBlock,0,64);
tslib_strcpy(receivedData, Sdata_receivedDataBlock, Sdata_receivedDataLength);
}
uint16_t epi_getLastPayLoad(uint16_t plBufSiz, uint8_t *payLoad) {
uint16_t epi_getLastPayLoad(uint16_t plBufSiz, uint8_t *payLoad)
{
// get data back in *pl, max 64 byte
// retval = nr of bytes received. If host buffer too small then
// only plBufSíz bytes are copied to pl
// plBufSíz=size of host buffer
uint16_t ml = std::min(plBufSiz, (uint16_t)(64));
if (SharedMemBuffer::getDataConst()->Sdata.receivedDataLength < ml) {
ml = SharedMemBuffer::getDataConst()->Sdata.receivedDataLength;
}
strncpy((char *)payLoad,
(char const *)(&SharedMemBuffer::getData()->Sdata.receivedDataBlock[0]),
ml);
return SharedMemBuffer::getDataConst()->Sdata.receivedDataLength;
uint16_t ml=plBufSiz;
if (ml>64) ml=64;
if (Sdata_receivedDataLength<ml)
ml=Sdata_receivedDataLength;
tslib_strcpy(Sdata_receivedDataBlock, payLoad, ml);
return Sdata_receivedDataLength;
}

View File

@ -1,6 +1,4 @@
#include <stdint.h>
#include <algorithm>
#include <QString>
#include <QDebug>
#include "storeINdata.h"
@ -1032,7 +1030,9 @@ void epi_restoreMdbResponse(uint8_t *leng, uint8_t *data) {
}
void gpi_storeEmpSettings(uint8_t leng, uint8_t const *data) {
leng = std::min(leng, (uint8_t)(64));
if (leng > 64) {
leng = 64;
}
memset(&SharedMemBuffer::getData()->Sdata.emp_settingsBuff[0], 0x00,
sizeof(SharedMemBuffer::getData()->Sdata.emp_settingsBuff));
SharedMemBuffer::getData()->Sdata.empNrOfsettings = leng;
@ -1095,7 +1095,9 @@ void epi_restoreEmpCoinSignal(uint8_t *valid, uint8_t *signal,
}
void gpi_storeRbDeviceSettings(uint8_t leng, uint8_t const *data) { // getestet am 12.4.23TS
leng = std::min(leng, (uint8_t)(64));
if (leng > 64) {
leng = 64;
}
SharedMemBuffer::getData()->Sdata.NrOfDeviceSetting = leng;
memset((char *)&SharedMemBuffer::getData()->Sdata.DeviceSettingBuff[0],
0x00, sizeof(SharedMemBuffer::getData()->Sdata.DeviceSettingBuff));
@ -1111,7 +1113,9 @@ void epi_restoreRbDeviceSettings(uint8_t *leng, uint8_t *data) { // getestet am
}
void gpi_storeMachineIDsettings(uint8_t leng, uint8_t const *data) {
leng = std::min(leng, (uint8_t)(64));
if (leng > 64) {
leng = 64;
}
SharedMemBuffer::getData()->Sdata.NrOfMachineIDSetting = leng;
memset((char *)&SharedMemBuffer::getData()->Sdata.NrOfMachineIDBuff[0],
0x00, sizeof(SharedMemBuffer::getData()->Sdata.NrOfMachineIDBuff));
@ -1184,7 +1188,9 @@ uint64_t epi_getWakeSources(void) {
}
void gpi_storeExtendedTime(uint8_t leng, uint8_t const *data) {
leng = std::min(leng, (uint8_t)(64));
if (leng > 64) {
leng = 64;
}
SharedMemBuffer::getData()->store.rbDevParamLen = leng;
memset((char *)(&SharedMemBuffer::getData()->store.rbDevParams[0]), 0x00,
sizeof(SharedMemBuffer::getData()->store.rbDevParams));
@ -1201,7 +1207,9 @@ void epi_restoreExtendedTime(uint8_t *leng, uint8_t *data) {
// store device conditions
void gpi_storeDeviceConditions(uint8_t leng, uint8_t const *data) {
leng = std::min(leng, (uint8_t)(64));
if (leng > 64) {
leng = 64;
}
SharedMemBuffer::getData()->store.deviceCondLen = leng;
memset((char *)(&SharedMemBuffer::getData()->store.deviceCond[0]), 0x00,
sizeof(SharedMemBuffer::getData()->store.deviceCond));