Add updated sources of thomas.

This commit is contained in:
Gerhard Hoffmann 2023-03-29 14:32:22 +02:00
parent 49396c22ee
commit 7f23e3ea46
15 changed files with 2036 additions and 756 deletions

View File

@ -33,7 +33,7 @@ class T_com : public QMainWindow //, public QPlainTextEdit
//char oeffneSerialPort();
char open_Serial_Port();
void closeSerialPort();
void receiveByLength(void);
private slots:
void readSomeBytes(void);
@ -54,6 +54,8 @@ public:
void writeToSerial(const QByteArray &data, uint16_t sendLength);
void receiveFixLen(int64_t nrOfbytesToReceive);
bool readFromSerial(QByteArray &data, uint16_t &sendLength);
// retval: true: data available

View File

@ -21,6 +21,115 @@
#include <QTime>
#define CMD2DC_sendTime 20
#define CMD2DC_setWakeFrequ 112
#define CMD2DC_MOV_UPLOCK 113
#define CMD2DC_MOV_DNLOCK 114
#define CMD2DC_UPPER_DOOR 115
#define CMD2DC_LOWER_DOOR 116
#define CMD2DC_VAULT_DOOR 117
#define CMD2DC_REJMOT_ON 118
#define CMD2DC_REJMOT_RUN 119
#define CMD2DC_LED_COIN 100
#define CMD2DC_LED_ILLU 101
#define CMD2DC_LED_TICKET 102
#define CMD2DC_LED_START 104
#define CMD2DC_LED_PIN 103
#define CMD2DC_LED_IN 105
#define CMD2DC_FAN 106
#define CMD2DC_SIREN 107
#define CMD2DC_BARRIER 108
#define CMD2DC_WAKEPTU 109
#define CMD2DC_SWITCHAUXPWR 110
#define CMD2DC_SWITCHAUXDDR 18
#define CMD2DC_SWITCHAUXOUT 19
#define CMD2DC_UCONTACTON 111
#define CMD2DC_DEVICE_PARAM 23
#define CMD2DC_SEND_MACH_ID 11
#define CMD2DC_RDBK_DEV_PARA 14
#define CMD2DC_RDBK_MACH_ID 15
#define CMD2DC_MDB_ON 120
#define CMD2DC_MDB_GET_STATE 107 // REQ
#define CMD2DC_MDB_DORESET 121
#define CMD2DC_MDB_SETWAK 122
//#define CMD2DC_MDB_GETWAK 0x2812 // REQ not nec.
#define CMD2DC_MDB_SENDCMD 123
#define CMD2DC_MDB_SENDMSG 12
#define CMD2DC_MDB_GETRESP 22 // REQ
#define CMD2DC_EMP_SET 24
#define CMD2DC_EMP_GET_ALL 23 // REQ
#define CMD2DC_EMP_STARTPOLL 124
#define CMD2DC_EMP_STARTPAY 125
#define CMD2DC_EMP_STOPPAY 126
#define CMD2DC_EMP_GOTCOIN 108 // REQ
#define CMD2DC_SHUTTER_OPEN 129
#define CMD2DC_ESCR_OPEN 132
#define CMD2DC_ESCR_TAKE 133
#define CMD2DC_ESCR_RETURN 134
#define CMD2DC_MOD_ON 135
#define CMD2DC_MOD_WAK 136
#define CMD2DC_CRED_ON 137
#define CMD2DC_CRED_WAK 138
// READ Commands ((e.g. get input)
#define CMD2DC_TestSerial 10
#define CMD2DC_GetSerialConfig 105
#define CMD2DC_RdBkHWversion 11
#define CMD2DC_RdBkSWversion 12
#define CMD2DC_RdBkDCstate 101
#define CMD2DC_RdBkUID 18
#define CMD2DC_RdBkTime 104
#define CMD2DC_RdBkAnalog 106
#define CMD2DC_GetAllInputs 102
#define CMD2DC_RdBkAllOutputs 103
#define CMD2DC_MIFREADERON 127
#define CMD2DC_ATB_CREATE 128
// Mif read data:
#define CMD2DC_RdBk_MifState 109
#define CMD2DC_RdBk_MifData 24
#define CMD2DC_RdBk_AtbCardType 25
#define CMD2DC_SHUTTER_COIN 131
#define CMD2DC_SHUTTER_OPEN3S 130
#define CMD2DC_SEND_SHUT_TIME 0x2915
#define CMD2DC_ESCR_TAKE 133
#define CMD2DC_ESCR_RETURN 134
#define CMD2DC_PRINTERON 139
#define CMD2DC_RdBk_PrnState 110
#define CMD2DC_RdBk_PrnFonts 26
#define CMD2DC_RdBk_AllPrnData 27
// nr of params:
#define CMD2DC_PRI_SYS_CMD 25 // 3
#define CMD2DC_PRI_ESC_CMD 26 // 4
#define CMD2DC_PRI_SETUP 27 // 5
#define CMD2DC_PRI_MOVE 140 // 2
#define CMD2DC_PRI_SETFONT 141 // 4
#define CMD2DC_PRI_SETLETTER 142 // 3
#define CMD2DC_PRI_CUT 143 // 1
#define CMD2DC_PRI_PRINT_TXT 13 // 64
#define CMD2DC_PRI_LF 144 // 1
#define CMD2DC_PRI_PRIFONTTABLE 145
#define CMD2DC_PRI_BARCODE 14 // ca 15...25
#define CMD2DC_STOR_QR_DATA 15 // 150
#define CMD2DC_PRI_QR_CODE 146 // 0
#define CMD2DC_PRI_LOGOFROMFLASH 147 // 2
#define CMD2DC_PRI_STORE_DOC 16 // 1
#define CMD2DC_PRI_DOCUMENT_NR 17 // 1 + 64
#define CMD2DC_PRI_CLEAR_DOC 148 // 1
/*
// WRITE Commands (e.g. switch relay)
#define CMD2DC_sendTime 0x1310
#define CMD2DC_setWakeFrequ 0x1320
@ -110,8 +219,8 @@
#define CMD2DC_MIFREADERON 0x2900
#define CMD2DC_ATB_CREATE 0x2907
// Mif read data:
#define CMD2DC_RdBk_MifReader 0x2902
#define CMD2DC_RdBk_Mifcard 0x2903
#define CMD2DC_RdBk_MifState 0x2902
#define CMD2DC_RdBk_MifData 0x2903
#define CMD2DC_RdBk_AtbCardType 0x2905
//#define CMD2DC_RdBk_CardData 0x2906
@ -157,7 +266,7 @@
#define CMD2DC_PRI_DOCUMENT_NR 0x2A42 // 1 + 64
#define CMD2DC_PRI_CLEAR_DOC 0x2A43 // 1
*/

View File

@ -62,6 +62,12 @@ uint8_t dcBL_startChain(void);
uint8_t dcBL_runChain(void);
void dcBL_iniLoading(void);
void dcBL_startLoading(void);
uint8_t dcBL_sendHexfile(void);
uint8_t dcBL_getResult(void);
// call after every step to what's going on....
@ -85,7 +91,9 @@ QString epi_getRawReceivedString();
void epi_clrRawReceivedString();
uint8_t dcBL_sendSuccess(uint8_t lastCommand);
// return val: 0: no response by now 1:error 10: OK
// lastCommand=0x21 for sendAddr or 0x22 for send data

View File

@ -71,7 +71,7 @@ Level 3): send command: "start payment process"
#include <QTabWidget>
#include <QtPlugin>
#include <QObject>
#include "interfaces.h"
#include <plugins/interfaces.h>
#include "datIf.h"
@ -162,8 +162,8 @@ class hwapi : public QObject,
public hwinf
{
Q_OBJECT
//Q_PLUGIN_METADATA(IID "Atb.Psa2020.software.HWapi/1.0" ) //FILE "HWapi.json")
//Q_INTERFACES(hwinf)
Q_PLUGIN_METADATA(IID "Atb.Psa2020.software.HWapi/1.0" ) //FILE "HWapi.json")
Q_INTERFACES(hwinf)
public:
explicit hwapi(QWidget *parent = nullptr);
@ -371,7 +371,7 @@ public:
uint32_t dc_getVoltage(void) const override; // in mV, 0...65,535V
QString dc_getVoltagStr(void) const override;
bool dc_mainFuseIsOk(void) const ; // override
bool dc_mainFuseIsOk(void) const override;
// ------------------------------------------------------------------------------
// Level 3: digital outputs and simple switching of connected devices
@ -385,11 +385,11 @@ public:
// dir 0=off 1=up 2=down
uint8_t lock_switchLowerLock(uint8_t dir) const override;
// dir 0=off 1=up 2=down
void lock_switchVaultDoor(void) const; // override;
void lock_switchVaultDoor(void) const override;
void coin_switchRejectMotor(uint8_t dir) const; // override;
void coin_switchRejectMotor(uint8_t dir) const override;
void coin_rejectCoins(void) const; // override;
void coin_rejectCoins(void) const override;
// LEDs
void led_switchLedIllumination(uint8_t on) const override;
@ -400,14 +400,13 @@ public:
void led_switchLedCoinbassin(uint8_t on, uint8_t ton, uint8_t tof) const override;
void fan_switchFan(bool on) const override;
void laerm_switchSiren(bool on) const override;
void alarm_switchSiren(bool on) const override;
void bar_OpenBarrier(bool open) const override;
void ptu_switchWake(bool WAKEACTIVE) const override;
void prn_switchPower(bool on) const override;
void mif_readerOn(bool on) const override;
void shut_move(bool open) const override;
void esc_moveFlaps(uint8_t flap ) const override;
// 0: close both 1: open take-flap 2: open return
@ -473,7 +472,7 @@ public:
bool ptu_WakeINisActive(void) const override;
bool prn_isPrinterPowerOn(void) const override;
uint8_t prn_PrnFuseIsOk(void) const; // override;
uint8_t prn_PrnFuseIsOk(void) const override;
//retval: 0: fuse blown 1: fuse OK 2:unknown as printer power is off
bool prn_readyINisActive(void) const override;
@ -496,10 +495,10 @@ public:
bool cred_isCreditPowerOn(void) const override;
bool cash_getRejectMotorHomePos(void) const; // override;
bool cash_getLowPaperSensor(void) const; // override;
bool cash_getRejectMotorHomePos(void) const override;
uint8_t cash_getLowPaperSensor(void) const override;
// 0: Sensor sees paper 1: no paper 99: off
// ------------------------------------------------------------------------------
@ -531,7 +530,9 @@ public:
void request_MifareReaderState() const override;
void request_MifareCardType() const override;
void request_MifareAtbType() const override;
void request_MifareData() const override;
void request_MifareID() const override;
void request_MifareData(uint8_t dataBlockNumber) const override;
// dataBlockNumber must be 0....11, returns 64byte of data
void request_MDB_Status() const override;
void request_MDB_lastResponse() const override;
@ -597,6 +598,13 @@ public:
void sendDeviceSettings(uint8_t kindOfPrinter, uint8_t kindOfCoinChecker,
uint8_t kindOfMifareReader, uint8_t suppressSleep,
uint8_t kindOfModem, uint8_t kindOfCredit ) const override;
// enable hardware in device controller:
// kindOfPrinter: 0:off 1: GPT4672 (only this one implemented)
// kindOfCoinChecker: 0:off 1:EMP820 2:EMP900 3: C²_changer
// kindOfMifareReader: 0:off 1: SL025 (only this one implemented)
// suppressSleep: 0:sleep allowed 1: sleep surpressed for special reason
// kindOfModem: 0:off 1: ATB_Sunlink_LTE (not yet implemented)
// kindOfCredit: 0:off 1: cVendTopp 2:cVendPin (not yet implemented)
void request_ReadbackDeviceSettings() const override;
@ -626,7 +634,7 @@ public:
uint8_t lock_closeUpperDoor(void) const override;
uint8_t lock_openLowerDoor(void) const override;
//uint8_t lock_closeLowerDoor(void) const override;
uint8_t lock_closeLowerDoor(void) const override;
void shut_openOnce(void) const override;
@ -652,29 +660,23 @@ public:
// read response from DC2 (input data)
// ------------------------------------------------------------------------------
/* data description:
byte 0: current read state: 0=power off 1=reader-fault 2=ready
uint8_t mif_returnReaderStateAndCardType(uint8_t *buf, uint8_t maxBufferSize) const override;
// retval 0=OK 1=error host buffer too small
/* data description, new fast version:
byte 0= still the same: current read state:
0=power off 1=reader-fault 2=ready
3=just reading 4=read complete
5=read partial, removed too early
6=state unknown
byte 1,2: read data length from card
3: 1=reader is OK (reported serial nr is OK) 0=wrong or no reader
4...15: reader version, expected "ATB25-1.8"
byte16: 1=card is present 0:not
17: 0
18: card type reported from reader
19: 1=allowed card type 0=not
20: card size: 1 or 4 (dec) = card size
21: LengthOfUID: 4 or 7 (dec) (byte)
22: UID 8 byte in hex
byte 30: sector logged: 0
byte 31: current sector: 0
byte 32: result, always 0
byte 1: reader state 1=ok 0=nok
byte 2: card preent (0,1)
byte 3: card selected (0)
byte 4: card type: 0...5
byte 5: card allowed (0=no 1=MifareClassic 1k or 4k)
byte 6: CardSize: 1 or 4 (kB)
byte 7: length of UID 4 or 7 (byte)
*/
uint8_t mif_returnReaderStateAndCardType(uint8_t *buf, uint8_t maxBufferSize) const override;
// retval 0=OK 1=error host buffer too small
bool mif_readerIsOK(void) const override;
@ -965,6 +967,53 @@ public:
// signal: channel nr reported from checker 0...15
// neu, 25.3.23
void bl_rebootDC(void) const override;
void bl_startBL(void) const override;
void bl_checkBL(void) const override;
bool bl_isUp(void) const override;
// return true is bl is up and running
// also initializes "sendFile"
void bl_sendAddress(u_int16_t blockNumber) const override;
// send start address, nr of 64byte-block, start with 0
// will be sent only for folling block-numbers:
// 0, 1024, 2048, 3072 and 4096, so basically every 64kByte
uint8_t bl_wasSendingAddOK(void) const override;
// return val: 0: no response by now 1:error 10: OK
void bl_sendDataBlock(uint8_t length, u_int8_t *buffer) const override;
// send 64 byte from bin file
void bl_sendLastBlock(void) const override;
uint8_t bl_wasSendingDataOK(void) const override;
// return val: 0: no response by now 1:error 10: OK
void bl_stopBL(void) const override;
bool bl_isDiagAvailable(void) const override;
QString dc_getDiagText(void) const override;
// Komplett-schreib Funktion, noch nicht getestet
// Nachteil: keine Rückmeldung wie lang's noch dauert
void bl_startSending(void) const override;
void bl_sendFile(void) const override;
/*
// neu, 25.8.21

File diff suppressed because it is too large Load Diff

View File

@ -26,6 +26,23 @@
#define FRAME_MAXLEN FRAME_DATALEN+20
#define BL_DATA_LEN 150
#define DATALEN_SEND_FAST 4
#define DATALEN_SEND_LONG 64
#define HEADERLEN_SEND 4
#define TELEGRAMLEN_SEND_FAST 12
#define TELEGRAMLEN_SEND_LONG 70
#define STARTSIGN_SEND_FAST 0x3F
#define STARTSIGN_SEND_LONG 0x3D
#define DATALEN_RECEIVE_FAST 8
#define DATALEN_RECEIVE_LONG 64
#define HEADERLEN_RECEIVE 2
#define TELEGRAMLEN_RECEIVE_FAST 12
#define TELEGRAMLEN_RECEIVE_LONG 68
#define STARTSIGN_RECEIVE_FAST 0x5F
#define STARTSIGN_RECEIVE_LONG 0x5D
class T_prot : public QMainWindow
{
Q_OBJECT
@ -62,9 +79,15 @@ class T_prot : public QMainWindow
T_com *mySerialPort;
void startPacking(void);
void startFastPacking(void);
uint8_t FramecheckInData(uint8_t *Inbuf, uint16_t LL);
uint8_t FastCheckInData(uint8_t *Inbuf, uint16_t LL);
uint8_t CheckInResult(uint8_t *Inbuf);
uint8_t CheckInData(uint8_t *recBuffer);
uint8_t ShowFastInData(uint8_t *recBuffer);
uint8_t ShowInData(uint8_t *recBuffer); // was CheckInData
void setRecLen(uint16_t WriteCmd);
private slots:
void analyseRecData(void);
@ -87,6 +110,8 @@ public:
void setBLsendData( uint8_t len, uint8_t *buf);
void receiveFixLen(int64_t nrOfbytesToReceive);
void sendUserData(uint16_t slaveAdr);
bool ifDataReceived();
bool getReceivedInData(uint8_t *SlavAddr, uint16_t *readSrc, uint16_t *readAddr,

View File

@ -73,10 +73,10 @@
#define SEND_REQU_PRN_FONTS 121
#define SEND_REQU_PRN_ALL 122
#define SEND_REQU_MIFREADER 123
#define SEND_REQU_MIFSTATE 123
// Type and state of reader
#define SEND_REQU_MIFCARD 124
#define SEND_REQU_MIFDATA 124
// Type, UID, Header of card
// read one card sector
// sectors must be addressed by RD_ADD

View File

@ -210,10 +210,10 @@ void gpi_storeDI_rejMot_home(bool di);
bool epi_getDI_rejectMotor_homepos(void);
void gpi_storeDI_paperLow(bool di);
bool epi_getDI_npe_sensor(void);
void gpi_storeDI_paperLow(uint8_t di);
uint8_t epi_getDI_npe_sensor(void);
// 0: Sensor sees paper 1: no paper 99: off
@ -407,7 +407,7 @@ void gpi_storeMifCardData(uint8_t blkNr, uint8_t *receivedData);
uint8_t epi_restoreMifData(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize);
// blkNr=0...11 return buf[64]
// retval: 1=error 0=OK

View File

@ -8,7 +8,7 @@
///
//////////////////////////////////////////////////////////////////////////////////
static int64_t com_want2read;
// -------------------------------------------------------------------------------------------------------------
// --------- PUBLIC --------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------------------
@ -78,7 +78,7 @@ T_com::T_com(QWidget *parent) : QMainWindow(parent)
connect(ChkConnectTimer, SIGNAL(timeout()), this, SLOT(ser_ISR100ms()));
ChkConnectTimer->setSingleShot(false);
ChkConnectTimer->start(100); // in ms
com_want2read=0;
}
@ -202,9 +202,48 @@ void T_com::readSomeBytes(void)
{
// called by serial-read-detection
// restart off-time as input flow is ongoing
serRecTime->stop();
serRecTime->start(20); // in ms
// timer for slow receive
// and serves as timeout for fast receive is msg is shorter as expected
serRecTime->stop();
serRecTime->start(20); // in ms
//qDebug()<< "com-rec read some bytes";
this->receiveByLength(); // since 14.12.21: fast receive
}
void T_com::receiveFixLen(int64_t nrOfbytesToReceive)
{
// call this before sending a request to slave
// then we know exactly when reception is complete -> much faster
com_want2read=nrOfbytesToReceive;
// since 14.12.21: FastDevice Protocol has two lengthen:
// fast: 12byte reception long: 68byte
}
void T_com::receiveByLength(void)
{
if (CatSerial->isOpen())
{
QString myString=nullptr, tmpStr=nullptr;
int64_t nrOfBytesreceived = CatSerial->bytesAvailable(); // nr of received bytes
//qDebug()<< "com-rec current Len: "<< nrOfBytesreceived;
if (nrOfBytesreceived >= com_want2read)
{
QByteArray data = CatSerial->readAll(); // erst auslesen wenn alles da! löscht den Empfangspuffer
serRecTime->stop(); // stop timeout to avoid 2nd emit
rawInLen=uint16_t (nrOfBytesreceived);
rawInput.clear();
rawInput.append(data);
// report "new data received" to other objects
//qDebug()<< "com-recFinished by Len "<< rawInLen;
emit receivingFinished();
}
}
}
void T_com::receiveTO(void)
@ -252,6 +291,7 @@ void T_com::receiveTO(void)
//gpi_set2ndTxt4RsDiagWin(myString);
// report "new data received" to other objects
//qDebug()<< "com-recFinished by TO";
emit receivingFinished();
}
}

View File

@ -15,7 +15,7 @@ static uint8_t dif_scanStep, RDBLKNR;
static uint8_t datif_OutCmdpara1, datif_OutCmdpara2, datif_OutCmdpara3, datif_OutCmdpara4;
static uint16_t datif_OutCmdpara5;
static uint32_t datif_OutCmdpara6;
static uint8_t cycl_running;
T_datif::T_datif(QWidget *parent) : QMainWindow(parent)
{
@ -32,7 +32,7 @@ T_datif::T_datif(QWidget *parent) : QMainWindow(parent)
datif_trigger = new QTimer();
connect(datif_trigger, SIGNAL(timeout()), this, SLOT(datif_cycleSend()));
datif_trigger->setSingleShot(false);
datif_trigger->start(100); // in ms, 80 gut, default 100 50....200
datif_trigger->start(10); // in ms, 80 gut, default 100 50....200
// passing Signal through
//connect(myDCIF, SIGNAL(framerecieved()), this, SLOT( ResponseRecieved() ));
@ -45,7 +45,7 @@ T_datif::T_datif(QWidget *parent) : QMainWindow(parent)
dif_scanStep=0;
selectedSlaveAddr=FIX_SLAVE_ADDR;
cycl_running=0;
}
void T_datif::resetChain(void)
@ -61,6 +61,16 @@ char T_datif::datif_cycleSend()
uint8_t dataSendBuf[160], dataBufLen, dbl, who;
static uint8_t BlockCounter;
if (cycl_running)
{
// request is still running, wait for response before next sending
datif_trigger->stop();
datif_trigger->start(10);
cycl_running++;
if (cycl_running>10)
cycl_running=0;
return 0;
}
if (myDCIF->isPortOpen())
{
#ifdef USEHANDSHAKES
@ -71,7 +81,8 @@ char T_datif::datif_cycleSend()
nxtAsCmd=sendWRcmd_getSendCommand0(); // command was stored by Gui
if (nxtAsCmd>0)
{
qDebug() << "datif: send next cmd0";
cycl_running=1;
// qDebug() << "datif: send next cmd0";
sendWRcommand(nxtAsCmd);
send_requests(nxtAsCmd);
sendHighLevel(nxtAsCmd);
@ -83,7 +94,8 @@ char T_datif::datif_cycleSend()
// command was stored by Gui
if (nxtAsCmd>0)
{
qDebug() << "datif: send next cmd4";
cycl_running=1;
//qDebug() << "datif: send next cmd4";
sendWRcommand(nxtAsCmd);
send_requests(nxtAsCmd);
sendHighLevel(nxtAsCmd);
@ -95,7 +107,8 @@ char T_datif::datif_cycleSend()
// command was stored by Gui
if (nxtAsCmd>0)
{
qDebug() << "datif: send next cmd8";
cycl_running=1;
//qDebug() << "datif: send next cmd8";
sendWRcommand(nxtAsCmd);
send_requests(nxtAsCmd);
sendHighLevel(nxtAsCmd);
@ -106,7 +119,8 @@ char T_datif::datif_cycleSend()
dbl=sendWRcmd_getSendBlock160(&dataBufLen, dataSendBuf); // used for bootloader
if (dbl>0)
{
qDebug() << "datif: sending 160 byte block, len: " << dataBufLen;
cycl_running=1;
qDebug() << "datif: sending 160 byte block, len: " << dataBufLen;
datif_OUT_SendRandomData(dataSendBuf, dataBufLen);
BlockCounter=0;
return 0;
@ -115,7 +129,8 @@ char T_datif::datif_cycleSend()
dbl=gpi_chk4remainingText();
if (dbl>0)
{
qDebug() << "datif: sending printer text ";
cycl_running=1;
//qDebug() << "datif: sending printer text ";
gpi_restorePrnText(&dataSendBuf[0]);
// can hold 1280 byte, get next 64
//for (uint8_t nn=0; nn<64; nn++)
@ -149,7 +164,10 @@ char T_datif::datif_cycleSend()
if (gpi_isEmmisionOn()) // auto send button is pressed
sendINrequestsAutomatic(); // sendCyclicCmd(); // request all cyclic data sequential
{
//qDebug() << "auto request is on";
sendINrequestsAutomatic(); // sendCyclicCmd(); // request all cyclic data sequential
}
else
dif_scanStep=0; // always start from beginning
}
@ -280,7 +298,8 @@ void T_datif::sendWRcommand(uint16_t nextWrCmd)
case SENDDIRCMD_MIF_SWONOFF:
datif_sendIOrequest(CMD2DC_MIFREADERON, 0, 1); // 0x2900
indat_storeMifarePower(datif_OutCmdpara1);
break;
qDebug()<<"switching mifare on/off "<< datif_OutCmdpara1;
break;
case SENDDIRCMD_MOD_SWONOFF:
datif_sendIOrequest(CMD2DC_MOD_ON, 0, 1);
@ -321,17 +340,17 @@ void T_datif::sendWRcommand(uint16_t nextWrCmd)
case SENDDIR_OPENVAULT:
datif_sendIOrequest(CMD2DC_VAULT_DOOR, 0, 0);
qDebug() << "Datif: send cmd open vault";
//qDebug() << "Datif: send cmd open vault";
break;
case SENDDIR_REJMOT_ON:
datif_sendIOrequest(CMD2DC_REJMOT_ON, 0, 0);
qDebug() << "Datif: send cmd open vault";
datif_sendIOrequest(CMD2DC_REJMOT_ON, 0, 1);
qDebug() << "Datif: send cmd reject motor";
break;
case SENDDIR_REJMOT_RUN:
datif_sendIOrequest(CMD2DC_REJMOT_RUN, 0, 0);
qDebug() << "Datif: send cmd open vault";
qDebug() << "Datif: send cmd do coin reject";
break;
@ -387,9 +406,6 @@ void T_datif::send_requests(uint16_t nextWrCmd)
datif_sendIOrequest(0, CMD2DC_RdBkAllOutputs, 0);
break;
case SEND_REQU_PRN_STATE:
datif_sendIOrequest(0, CMD2DC_RdBk_PrnState, 0);
break;
@ -398,34 +414,34 @@ void T_datif::send_requests(uint16_t nextWrCmd)
datif_sendIOrequest(0, CMD2DC_RdBk_PrnFonts, 0);
break;
case SEND_REQU_PRN_ALL :
datif_sendIOrequest(0, CMD2DC_RdBk_AllPrnData, 0);
break;
case SEND_REQU_PRN_ALL :
datif_sendIOrequest(0, CMD2DC_RdBk_AllPrnData, 0);
break;
case SEND_REQU_MIFREADER :
case SEND_REQU_MIFSTATE :
// Type and state of reader
datif_sendIOrequest(0, CMD2DC_RdBk_MifReader, 0);
datif_sendIOrequest(0, CMD2DC_RdBk_MifState, 0);
break;
case SEND_REQU_MIFCARD :
case SEND_REQU_MIFDATA :
// Type, UID, Header of card
datif_sendIOrequest(0, CMD2DC_RdBk_Mifcard, 0);
datif_sendIOrequest(0, CMD2DC_RdBk_MifData, 1); // immer nur blk 0 anfordern
qDebug()<<"manual requesting mif card data";
break;
case SEND_REQU_MIF_ATB_TYPE :
// read one card sector
// sectors must be addressed by RD_ADD
datif_sendIOrequest(0, CMD2DC_RdBk_AtbCardType, 0);
break;
// case SEND_REQU_MIF_ATB_TYPE :
// // read one card sector
// // sectors must be addressed by RD_ADD
// datif_sendIOrequest(0, CMD2DC_RdBk_AtbCardType, 0);
// break;
//case SEND_REQU_MIF_DATA :
// read one card sector
// sectors must be addressed by RD_ADD
//datif_sendIOrequest(0, CMD2DC_RdBk_CardData, 0);
//break;
// case SEND_REQU_MIF_DATA :
// // read one card sector
// // sectors must be addressed by RD_ADD
// //datif_sendIOrequest(0, CMD2DC_RdBk_CardData, 1); ist das gleiche
// datif_sendIOrequest(0, CMD2DC_RdBk_MifData, 1); // jeden beliebigen Block anfordern
// break;
case SEND_REQU_MDB_GETSTAT :
datif_sendIOrequest(0, CMD2DC_MDB_GET_STATE, 0);
@ -467,7 +483,6 @@ void T_datif::sendHighLevel(uint16_t nxtHLCmd)
{
case SENDDIRCMD_SHUTOPENBYTIME:
// void datif_sendIOrequest(uint16_t WRcmd, uint16_t RDcmd, uint8_t nrOfWrData);
qDebug() << "open by time " << datif_OutCmdpara1 << " "<< datif_OutCmdpara2;
datif_sendIOrequest(CMD2DC_SHUTTER_OPEN3S, 0, 1);
break;
@ -607,11 +622,11 @@ void T_datif::sendHighLevel(uint16_t nxtHLCmd)
// sende alle Befehle um die Eingangsdaten abzufragen der Reihe nach:
char T_datif::sendINrequestsAutomatic(void)
{
//qDebug() << "send IN request " << dif_scanStep;
switch (dif_scanStep)
{
// first 5 items are performed only one time after startup as this data never change
qDebug() << "send IN request " << dif_scanStep;
case 0:
datif_sendIOrequest(0, CMD2DC_GetSerialConfig, 0);
@ -675,10 +690,10 @@ char T_datif::sendINrequestsAutomatic(void)
case 14:
if (indat_isMifareOn())
{
datif_sendIOrequest(0, CMD2DC_RdBk_MifReader, 0);
datif_sendIOrequest(0, CMD2DC_RdBk_MifState, 0);
//qDebug()<<"requesting MIF reader state";
}
break;
break;
case 15:
datif_sendIOrequest(0, CMD2DC_GetAllInputs, 0);
@ -687,9 +702,9 @@ char T_datif::sendINrequestsAutomatic(void)
case 16:
if (indat_isMifareOn())
{
datif_sendIOrequest(0, CMD2DC_RdBk_Mifcard, 1);
//qDebug()<<"requesting mif card data";
datif_OutCmdpara1=0; // data block number 0 contains the Mifare-ID
datif_sendIOrequest(0, CMD2DC_RdBk_MifData, 1);
// qDebug()<<"automatically requesting mif card data";
if (++RDBLKNR>11)
RDBLKNR=0;
datif_OutCmdpara1=RDBLKNR;
@ -703,8 +718,8 @@ char T_datif::sendINrequestsAutomatic(void)
case 18:
if (indat_isMdbOn())
datif_sendIOrequest(0, CMD2DC_MDB_GET_STATE, 0);
else
dif_scanStep=24;
//else
// dif_scanStep=24; unsinn
break;
case 19:
@ -739,7 +754,7 @@ char T_datif::sendINrequestsAutomatic(void)
dif_scanStep++;
if (dif_scanStep>=25)
dif_scanStep=5;
dif_scanStep=0; //dif_scanStep=5;
return 0;
@ -760,7 +775,6 @@ char T_datif::isPortOpen(void)
//void T_datif::StoredRecData(bool neu)
void T_datif::StoredRecData()
{
//qDebug() << "StoreRecData called";
@ -772,6 +786,7 @@ void T_datif::StoredRecData()
// "neu" is the same as "INdataValid"
loadRecDataFromFrame();
}
cycl_running=0;
}
char T_datif::loadRecDataFromFrame()
@ -779,28 +794,28 @@ char T_datif::loadRecDataFromFrame()
// necessary data in T_prot:
uint16_t readSource, uitmp;
uint16_t readAddress;
uint8_t pp;
//uint8_t pp;
uint8_t SlaveAdr, RdDleng;
uint8_t receivedData[FRAME_DATALEN];
QString localStr;
uint32_t ultmp;
int portNr;
//uint32_t ultmp;
//int portNr;
bool ret;
uint8_t maxai;
uint8_t uctmp; // maxai
ret=myDCIF->getReceivedInData(&SlaveAdr, &readSource, &readAddress, &RdDleng, receivedData);
// retval: data valid, only one time true, true if CommandState OK and readState OK
gpi_storeResultOfLastRequest(ret);
if (ret==false)
{
qDebug() << "datif: rec data not valid";
// qDebug() << "datif: rec data not valid";
return 0;
}
gpi_storeRecPayLoad(RdDleng, receivedData); // save for host (user of hwapi)
// qDebug() << "\n +++datif: got valid data, rdsrc:" << readSource << " rdadd:" << readAddress
// << " rdlen:" << RdDleng;
//qDebug() << "\n datif: got valid data, rdsrc:" << readSource << " rdadd:" << readAddress
// << " rdlen:" << RdDleng;
// qDebug("datif_recData: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d ",
// receivedData[0], receivedData[1], receivedData[2], receivedData[3],
// receivedData[4], receivedData[5], receivedData[6], receivedData[7],
@ -847,18 +862,20 @@ char T_datif::loadRecDataFromFrame()
break;
case CMD2DC_RdBkHWversion:
qDebug() << "got HW version: " << localStr;
//qDebug() << "got HW version: " << localStr;
gpi_storeGenerals(0, localStr);
// 0=HW 1=SW 2=State
//gpi_storeSlaveBusAddr(SlaveAdr);
break;
case CMD2DC_RdBkSWversion:
qDebug() << "got SW version: " << localStr;
//qDebug() << "got SW version: " << localStr;
gpi_storeGenerals(1, localStr);
break;
case CMD2DC_RdBkDCstate:
//qDebug() << "got DC state " << localStr;
localStr[8]=0;
gpi_storeGenerals(2, localStr);
// 0=HW 1=SW 2=State
break;
@ -868,140 +885,180 @@ char T_datif::loadRecDataFromFrame()
break;
case CMD2DC_RdBkTime: // slave returned RTC time and date
// new, FastProt: 0=dayOfWeek 1=min 2=sec 3=hours 4=year 5=month 6=dayOfYear
gpi_backupTime(receivedData, RdDleng); // function reads 20 bytes from the buffer
break;
case CMD2DC_RdBkAnalog: // get ALL AIs 0...3, 4byte + 2byte each
// DB0...3: Value0=Temperature
// DB4...7: Value1=Voltage
// ...DB31 for Value7
// DB32,33: ADC0 input value 0...1023
// DB34,35: ADC1 input value 0...1023
// DB36,37: ADC2 input value 0...1023
// …
// DB46,47: ADC7 input value 0...1023
pp=0;
ultmp=uchar2uint(receivedData[1], receivedData[0]);
gpi_storeMeasureValue(0, ultmp);
pp=1;
ultmp=uchar2uint(receivedData[5], receivedData[4]);
gpi_storeMeasureValue(1, ultmp);
pp=32;
maxai=gpi_getMaxNrAIs();
for (portNr=0; portNr<maxai; portNr++)
{
uitmp=uchar2uint(receivedData[pp+1], receivedData[pp]);
gpi_storeAIs(uint8_t(portNr), uitmp);
pp+=2;
}
// DB0,1: Value0=Temperature
// DB2,3: Value1=Voltage
// DB4,5: ADC0 input value 0...1023
// DB6,7: ADC1 input value 0...1023
uitmp=uchar2uint(receivedData[1], receivedData[0]);
gpi_storeMeasureValue(0, uitmp);
uitmp=uchar2uint(receivedData[3], receivedData[2]);
gpi_storeMeasureValue(1, uitmp);
uitmp=uchar2uint(receivedData[5], receivedData[4]);
gpi_storeAIs(0, uitmp);
uitmp=uchar2uint(receivedData[7], receivedData[6]);
gpi_storeAIs(1, uitmp);
break;
case CMD2DC_GetAllInputs:
/*
D0: upper door D1: low door D2:vault door
D3: cash box D4: bill box in
D5: bit 0: upper lockbar up bit1:down
D6: bit 0: lower lockbar up bit1:down
// alle DI's in einen 8byte Puffer zusammenstellen, werden in einen Rutsch zum Master gesendet
D7: DI_contact Power Is On
outBuf[0]: door switches and cash boxes:
bit 0: service
1: battery
2: vault
3: coin box
4: bill box
D8: OptoIn 1,2
D9: Aux0...5
D10:Wake from ptu
D11: DI Wake From Mdb
D12: Ready from printer
D13: Coin Shutter Input
D14: CoinEscrow switch
D15: Mifare IN
D16: Modem_Wake In
outBuf[1]: lock bar switches:
bit 0: upper lock up
1: down
bit 2: lower lock up
3: down
4: contact pwr on
6: opto in2
D18: DI Mif Pwr is on
D19: DI MDB_TxD_rdBack
D20: DI Aux Pwr is on
D21: DI GSM Pwr from PO2 is ON
D22: DI Credit Pwr from PO2 is on
=DI RdBack Credit Wake
D23: DI Printer Pwr from PO2 is on
D24: DI MDB Pwr from PO2 is on
new since 7.10.21:
D25: coin reject switch 1=home position
D26: Paper-Low-Sensor Input (printer must be ON!)
outBuf[2]: aux inputs:
2: aux2....6:aux6
outBuf[3]: 0: ptu wake
1: rdBack MdbTx = 5V on if Tx low
2: prn ready
3: coin attached
4: Escrow
5: MifCardPresent
6: reject switch
outBuf[4]: 0: rdMdbWake 1: Wake=Low=Active
1: rdBackVmif
2: rdBack_MdbBusPwr5V
3: rdBackVbar
4: rdBackVgsm
5: rdBack_CreditPwr
6: rdBack_Vprint
7: rdBack_VmdbDevice
outBuf[5]: 0: coin Reject SwitchOn
1: PaperLowSensor
*/
gpi_storeDI_doorSwitches(receivedData[0], receivedData[1], receivedData[2]);
gpi_storeDI_vaultSwitches(receivedData[3], receivedData[4]);
gpi_storeDI_lockSwitches(receivedData[5], receivedData[6]);
// qDebug()<<"datif got DIs: "<< receivedData[0] << " "
// << receivedData[1] << " " << receivedData[2] << " "
//<< receivedData[3] << " " << receivedData[4] << " " << receivedData[5];
gpi_storeDI_contactPowerIsOn(receivedData[7]);
gpi_storeDI_optos(receivedData[8]);
gpi_storeDI_auxIn(receivedData[9]);
gpi_storeDI_ptuWake(receivedData[10]);
gpi_storeDI_readbackMdbTxD(receivedData[11]);
gpi_storeDI_prnReady(receivedData[12]);
gpi_storeDI_CoinAttach(receivedData[13]);
gpi_storeDI_CoinEscrow(receivedData[14]);
gpi_storeDI_mifareCardTapped(receivedData[15]);
gpi_storeDI_modemWake(receivedData[16]); // gibt's gar nicht!
gpi_storeDI_mbdWake(receivedData[17]);
gpi_storeDI_MifarePowerIsOn(receivedData[18]);
gpi_storeDI_readbackMdbTxD(receivedData[19]);
gpi_storeDI_AuxPowerIsOn(receivedData[20]);
gpi_storeDI_GsmPowerIsOn(receivedData[21]);
gpi_storeDI_CreditPowerIsOn(receivedData[22]);
gpi_storeDI_PrinterPowerIsOn(receivedData[23]);
gpi_storeDI_MdbPowerIsOn(receivedData[24]);
uctmp=receivedData[0];
// qDebug()<<"datif single bits: "<< (uctmp&1) << (uctmp&2) << (uctmp&4);
gpi_storeDI_doorSwitches(uctmp&1, uctmp&2, uctmp&4);
gpi_storeDI_rejMot_home(receivedData[25]);
gpi_storeDI_paperLow(receivedData[26]);
gpi_storeDI_vaultSwitches(uctmp&8, uctmp&16);
uctmp=receivedData[1];
gpi_storeDI_lockSwitches((uctmp&3), ((uctmp>>2)&3));
uctmp=receivedData[1];
gpi_storeDI_contactPowerIsOn(uctmp&0x10);
gpi_storeDI_optos((uctmp>>5)&3);
uctmp=receivedData[2];
gpi_storeDI_auxIn(uctmp);
break;
uctmp=receivedData[3];
gpi_storeDI_ptuWake(uctmp&1);
gpi_storeDI_readbackMdbTxD(uctmp&2);
gpi_storeDI_prnReady(uctmp&4);
gpi_storeDI_CoinAttach(uctmp&8);
gpi_storeDI_CoinEscrow(uctmp&16);
gpi_storeDI_mifareCardTapped(uctmp&32);
gpi_storeDI_rejMot_home(uctmp&64);
uctmp=receivedData[4];
//gpi_storeDI_modemWake(0); // gibt's gar nicht!
gpi_storeDI_mbdWake(uctmp&1);
gpi_storeDI_MifarePowerIsOn(uctmp&2);
gpi_storeDI_AuxPowerIsOn(uctmp&8);
gpi_storeDI_GsmPowerIsOn(uctmp&16);
gpi_storeDI_CreditPowerIsOn(uctmp&32);
gpi_storeDI_PrinterPowerIsOn(uctmp&64);
//gpi_storeMdbState(uctmp&4, uctmp&128, uctmp&4); // hat ein eigenes Cmd weiter unten!
gpi_storeDI_MdbPowerIsOn(uctmp&128);
gpi_storeDI_paperLow(receivedData[5]);
break;
case CMD2DC_RdBkAllOutputs:
/*
D0 = mdb Rx-test out
// alle DO's in einen 8byte Puffer zusammenstellen, werden in einen Rutsch zum Master gesendet
D1: motor outputs bit0: upper lock forw bit 1 backw
Bit2: lowLock forw bit3: LL backw
outBuf[0]: bit 0: TestMdbInput
1: RS1 drv enabled
2: RS1switch: 1=GSM 0=printer
3: RS2switch: H: mifare L: credit
4: Vbarcode=Vaux is on
D5: serial drv on/off, Serial mux1, Serial mux2
D6: Leds, Fan,
D7: Siren and relay
D8: PtuWakeOut
D9: Power Aux/Barcode
D12: Coin shutter output, input-test-output
D13: CoinEscrow Outputs bit0=return bit1=take
D14: printer power is switched on/off
*/
outBuf[1]: bit 0: coin led
1: 0
2: paper led
3: pinpad led
4: start led
5: service led
gpi_storeDO_mdbRxTst(receivedData[0]);
gpi_storeDO_motorOutputs(receivedData[1]);
gpi_storeDO_serialSwitch(receivedData[5]);
gpi_storeDO_ledsAndFan(receivedData[6]);
gpi_storeDO_sirenAndRelay(receivedData[7]);
gpi_storeDO_ptuWake(receivedData[8]);
gpi_storeDO_auxPower(receivedData[9]);
gpi_storeDO_coinShutter(receivedData[12]);
gpi_storeDO_coinEscrow(receivedData[13]);
gpi_storeDO_printerPwrOn(receivedData[14]);
outBuf[2]: bit 0: siren
1: relay
2: ptu wake
3: shutter
4: shutter test
5: escrowGive
6: escrowTake
7: prn power
outBuf[3]: Motor 1: 0:off 1=vorwärts / öffnen 2=rückw./zu 3: beide ein
outBuf[4]: Motor 2: 0:off 1=vorwärts / öffnen 2=rückw./zu 3: beide ein
*/
uctmp=receivedData[0];
gpi_storeDO_mdbRxTst(uctmp&1);
gpi_storeDO_auxPower(uctmp&0x10);
gpi_storeDO_serialSwitch((uctmp>>1)&7); // serial drv 0:on/off, 1:Serial mux1, 2:Serial mux2
uctmp=receivedData[1];
gpi_storeDO_ledsAndFan(uctmp);
// bit0: coinled 1:front_illu 2: paper-led 3:pinpad-led 4:start-led 5:service-led 6:fan
uctmp=receivedData[2];
gpi_storeDO_sirenAndRelay(uctmp&3); // bit0: siren 1:relay
gpi_storeDO_ptuWake(uctmp&4);
gpi_storeDO_coinShutter(uctmp>>3); // bit0: Coin shutter output, bit1: input-test-output
gpi_storeDO_coinEscrow(uctmp>>5); // retval: 1:return flap is open 2:take flap is open 0:closed
gpi_storeDO_printerPwrOn(uctmp&0x80);
uctmp=(receivedData[4] & 3);
uctmp<<=2;
if (receivedData[3] & 1) uctmp |=1;
if (receivedData[3] & 2) uctmp |=2;
gpi_storeDO_motorOutputs(uctmp);
// bit0: upper lock forw bit 1 backw bit2: lowLock forw bit3: LL backw
break;
case CMD2DC_RdBk_MifReader:
case CMD2DC_RdBk_MifState:
// get reader status and card type
gpi_storeMifReaderStateAndCardType(receivedData);
break;
case CMD2DC_RdBk_Mifcard:
case CMD2DC_RdBk_MifData:
// one block of data (64byte) comes in
// blkNr 0...11 in "Addr"
gpi_storeMifCardData(readAddress, receivedData);
//qDebug()<<"datif storing mif data: (adr/data) "<<readAddress<<receivedData;
break;
case CMD2DC_RdBk_AtbCardType:
@ -1054,6 +1111,8 @@ char T_datif::loadRecDataFromFrame()
// DB0: mdb_bus_ready (switched on)
// DB1: rdBackV12devicePower
// DB2: rdBackV5busPwr
//qDebug() << "got MDB state " << receivedData[0] << " " << receivedData[1] << " " << receivedData[2];
gpi_storeMdbState(receivedData[0],receivedData[1],receivedData[2]);
break;
@ -1118,6 +1177,8 @@ void T_datif::datif_startSending(void)
// egal ob WR und RD Daten gesetzt wurden
myDCIF->sendUserData(selectedSlaveAddr); // starte Sendung
gpi_startNewRequest();
cycl_running=1;
}
// allgemeine Schreib/Lese-Funktion
@ -1135,12 +1196,14 @@ void T_datif::datif_sendIOrequest(uint16_t WRcmd, uint16_t RDcmd, uint8_t nrOfWr
if (nrOfWrData>2)
data[2]=datif_OutCmdpara3;
if (nrOfWrData>3)
data[3]=datif_OutCmdpara3;
data[3]=datif_OutCmdpara4;
data[4]=0; data[5]=0;
myDCIF->setUserWriteData(WRcmd, 0, nrOfWrData, data);
myDCIF->setUserReadData(RDcmd);
myDCIF->sendUserData(selectedSlaveAddr);
cycl_running=1;
}
void T_datif::datif_send8byteOutCmd(uint16_t WRcmd, uint16_t RDcmd)
@ -1173,12 +1236,14 @@ void T_datif::datif_send8byteOutCmd(uint16_t WRcmd, uint16_t RDcmd)
myDCIF->setUserWriteData(WRcmd, 0, 8, data);
myDCIF->setUserReadData(RDcmd);
myDCIF->sendUserData(selectedSlaveAddr);
cycl_running=1;
}
bool T_datif::verifyLineTestresponse(uint8_t RdDlen, uint8_t *receivedData)
{
if (RdDlen !=16)
if (RdDlen < 16)
return false;
QString myStr;
myStr.clear();
@ -1186,7 +1251,13 @@ bool T_datif::verifyLineTestresponse(uint8_t RdDlen, uint8_t *receivedData)
for (int nn=0; nn<16; nn++)
if (myStr[nn] !=receivedData[nn])
{
//qDebug() << " datif cmd 10: got wrong string ";
//qDebug() << myStr;
//qDebug() << receivedData;
//qDebug() << nn;
return false;
}
return true;
}
@ -1234,6 +1305,7 @@ void T_datif::datif_OUT_setTime(void)
myDCIF->setUserWriteData(CMD2DC_sendTime,0,8, buff);
myDCIF->setUserReadData(0);
myDCIF->sendUserData(selectedSlaveAddr); // jetzt wegsckicken
cycl_running=1;
}
@ -1247,6 +1319,8 @@ uint8_t T_datif::datif_OUT_SendRandomData(uint8_t *buf, uint8_t Length)
myDCIF->setBLsendData(len, buf );
myDCIF->setUserReadData(0);
myDCIF->sendUserData(selectedSlaveAddr);
cycl_running=1;
return 0;
}
@ -1266,6 +1340,7 @@ void T_datif::datif_send64byteOutCmd(uint16_t WRcmd, uint16_t addr, uint16_t RDc
myDCIF->setUserWriteData(WRcmd, addr, LL, data);
myDCIF->setUserReadData(RDcmd);
myDCIF->sendUserData(selectedSlaveAddr);
cycl_running=1;
}
@ -1285,6 +1360,7 @@ void T_datif::datif_sendToMemory(uint16_t WRcmd, uint16_t docNr, uint16_t blockN
myDCIF->setUserWriteData(WRcmd, aa, 64, data64);
myDCIF->setUserReadData(0);
myDCIF->sendUserData(selectedSlaveAddr);
cycl_running=1;
}

View File

@ -283,24 +283,28 @@ uint8_t dcBL_restartDC(uint8_t *sendData)
uint8_t dcBL_activatBootloader(uint8_t *sendData)
{
// minimum size of sendData-buffer: 20 byte retval: length
uint8_t nn=0;
//sendData[nn++]='U'; nötig??
sendData[nn++]='U';
sendData[nn++]='U';
sendData[nn++]='U';
sendData[nn++]='U';
sendData[nn++]='U';
sendData[nn++]=2;
sendData[nn++]='c';
sendData[nn++]='4';
sendData[nn++]='5';
sendData[nn++]='b';
sendData[nn++]='3';
sendData[nn++]=3;
sendData[nn++]='U';
sendData[nn++]='U';
sendData[nn++]='U';
sendData[nn++]='U';
sendData[nn++]='U';
sendData[nn++]='U';
sendData[nn++]='U';
sendData[nn++]='U';
sendData[nn++]='U';
sendData[nn++]='U';
sendData[nn++]=0;
sendData[nn++]=0;
return nn;
}
@ -315,9 +319,11 @@ uint8_t dcBL_getResponse(uint8_t *respBuff, bool display)
{
epi_getRawReceivedData(respBuff);
epi_clrRawReceivedString();
dcBL_writeText("dcBL gotResponse");
if (display)
{
/*
// Antwort ins Fenster schreiben:
QString tmpStr="", myStr="~~> ";
@ -332,8 +338,8 @@ uint8_t dcBL_getResponse(uint8_t *respBuff, bool display)
myStr.append(" ");
}
dcBL_writeText(myStr);
*/
}
}
return recLen;
}
@ -355,6 +361,10 @@ uint8_t dcBL_ChkResponse()
recLen=dcBL_getResponse(buf,0);
if (recLen==0)
return 0; // no response by now
qDebug()<<" DCBL_chkResp got answer " << recLen ;
dcBL_writeText("DCBL_chkResp got answer");
if (buf[0]==2 && buf[1]==(dcBL_LastBLcmd | 0x80) )
return 10; // OK
@ -365,24 +375,28 @@ uint8_t dcBL_ChkResponse()
{
dcBL_writeText("error wrong length");
//exactError=1;
qDebug()<<" DCBL_chkResp wrong length ";
return 10; // OK
}
if (buf[0] !=2)
{
dcBL_writeText("error wrong start");
//exactError=2;
qDebug()<<" DCBL_chkResp wrong start ";
return 10; // OK
}
if (buf[0]==2 && buf[1]=='e' && buf[2]=='0' )
{
dcBL_writeText("error wrong crc");
//exactError=3; // DC reports wrong crc
qDebug()<<" DCBL_chkResp wrong crc";
return 1; // error
}
if (buf[0]==2 && buf[1]==dcBL_LastBLcmd )
{
dcBL_writeText("error wrong cmd");
//exactError=4; // wrong cmd
qDebug()<<" DCBL_chkResp wrong cmd";
return 10; // OK
}
//tmpStr.clear();
@ -393,6 +407,21 @@ uint8_t dcBL_ChkResponse()
uint8_t dcBL_sendSuccess(uint8_t lastCommand)
{
// return val: 0: no response by now 1:error 10: OK
uint8_t buf[152], recLen;
recLen=dcBL_getResponse(buf,0);
if (recLen==0)
return 0; // no response by now
if (buf[0]==2 && buf[1]==(lastCommand | 0x80) )
return 10; // OK
return 1;
}
// -----------------------------------------------------------------------------------------------
// --- ATB Bin-File Handling ---------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------
@ -502,7 +531,8 @@ static QByteArray dcBL_AtbBinFile;
static uint32_t dcBL_fileSize;
static uint16_t dcBL_nrOfBlocks;
static uint16_t dcBL_fileCrc;
static uint8_t dcBL_myBuf[257000]; // same content like "dcBL_AtbBinFile" but bytewise
//static uint8_t dcBL_myBuf[2570000]; // same content like "dcBL_AtbBinFile" but bytewise
static uint8_t dcBL_myBuf[300000]; // same content like "dcBL_AtbBinFile" but bytewise
bool dcBL_importBinFile(QByteArray readBinFile, uint32_t fileSize, char withDispl)
{
@ -514,7 +544,10 @@ bool dcBL_importBinFile(QByteArray readBinFile, uint32_t fileSize, char withDisp
dcBL_AtbBinFile=readBinFile;
dcBL_fileSize=fileSize;
if (dcBL_fileSize>258048)
//if (dcBL_fileSize>258048) // 27.3.23TS woher kommt die Zahl???
// das hex file hat 278kB
// hex file nicht erlaubt???
if (dcBL_fileSize>=300000)
return false; // keep last file
ultmp=dcBL_fileSize;
ultmp %=64;
@ -718,7 +751,7 @@ uint8_t dcBL_getFileBlock(uint16_t blockPointer, uint8_t *buf)
/*
// Kontrolle:
qDebug()<<"dcBL_getFileBlock myBuf: ";
qDebug()<<"dcBL getFileBlock myBuf: ";
int ii=0;
do
{
@ -729,7 +762,7 @@ uint8_t dcBL_getFileBlock(uint16_t blockPointer, uint8_t *buf)
} while (ii<64);
qDebug()<<"dcBL_getFileBlock myBuf: ";
qDebug()<<"dcBL getFileBlock myBuf: ";
ii=0;
do
{
@ -809,7 +842,6 @@ QString dcBL_readText(void)
// -------------------------------------------------------------------------
static uint8_t dcBL_step, dcBL_state;
static uint16_t dcBL_BlkCtr, dcBL_cyclCtr, repeatCtr;
@ -826,8 +858,8 @@ void dcBL_iniChain(void)
pBlResp=0;
for (nn=0;nn<SIZEBLRESP; nn++)
BlResp[nn]="";
dcBL_writeText("**CLEAR**");
//dcBL_writeText("**CLEAR**");
dcBL_writeText("bl chain ini");
}
uint8_t dcBL_startChain(void)
@ -836,13 +868,15 @@ uint8_t dcBL_startChain(void)
{
dcBL_iniChain();
dcBL_step=1;
epi_clrRawReceivedString();
//epi_clrRawReceivedString();
qDebug()<<"starting chain...";
//qDebug()<<pBlResp;
dcBL_writeText("bl chain start");
}
return 0;
}
uint8_t dcBL_runChain(void)
{
// starting BL
@ -857,17 +891,14 @@ uint8_t dcBL_runChain(void)
QString tmpStr="";
uint8_t buf[70], sendBuf[160], len, sendLen, gotResp; //, uit8tmp; //, recLen; recBuff[160], ii,
uint8_t buf[70], sendBuf[160], len, sendLen, gotResp, ii, uit8tmp;
//static uint8_t lastBlkLength;
QString stemp=" ";
uint32_t ultmp;
bool ret;
//uint8_t recLen, recBuff[160], ;
//recLen=dcBL_getResponse(recBuff, (dcBL_step<=11)?1:0); // reads all responses
// Antwort nur bis step 11 anzeigen
// wird schon in dcBL_responseOK() gelesen
gotResp=dcBL_ChkResponse();
gotResp=dcBL_ChkResponse(); //zum test hier raus, unten gehts nicht, darf nur 1x
switch (dcBL_step)
{
@ -904,6 +935,7 @@ uint8_t dcBL_runChain(void)
case 5: // wait for answer: 2 99 52 53 98 51 3
// Problem: kommt von app, nicht vom BL. Also wenn BL schon aktiv ist dann gehts nicht
/*
dcBL_cyclCtr++;
if (recLen>6 && recBuff[0]==2 && recBuff[1]==99 && recBuff[2]==52)
@ -922,7 +954,7 @@ uint8_t dcBL_runChain(void)
dcBL_state=3;
dcBL_step=0; // stop chain
return 0;
}*/
} */
dcBL_step++;
repeatCtr=0;
@ -1002,49 +1034,15 @@ uint8_t dcBL_runChain(void)
dcBL_step=0; // stop chain
}
break;
/*
case 10: // send length and crc
len=dcBL_getAtbFileHeader(buf);
sendWRcmd_setSendBlock160(len, buf);
dcBL_writeText("sending header");
dcBL_BlkCtr=0; // normal 0
dcBL_cyclCtr=0;
dcBL_step++;
break;
case 11: // wait for answer 2 178 102 105 3
if (gotResp==ISOK)
{
dcBL_step++;
repeatCtr=0;
return 0;
} else
if (gotResp==ISWRONG)
{
if (++repeatCtr<3)
{
dcBL_step--;
} else
{
dcBL_step=0; // stop chain
}
}
if (++dcBL_cyclCtr>10)
{
dcBL_writeText("cancel");
dcBL_step=0; // stop chain
}
break;
*/
case 12: // send binary 64 byte wise
len=dcBL_getFileBlock(dcBL_BlkCtr, buf); // read from file, len = 0...64
//lastBlkLength=len; // recognize last block or end
sendLen=dcBL_prepareDC_BLcmd(0x22, len, buf, sendBuf); // pack into protocol frame
/*
// Kontrolle:
qDebug()<<"dcBL sending: ";
ii=0;
@ -1056,7 +1054,7 @@ uint8_t dcBL_runChain(void)
qDebug() << stemp << " "; // Anzeige in hex
} while (ii<100);
*/
sendWRcmd_setSendBlock160(sendLen, sendBuf); // send 140 bytes
delay(100);
@ -1174,12 +1172,199 @@ uint8_t dcBL_runChain(void)
case 18:
dcBL_step=0;
break;
}
return 0;
}
void dcBL_iniLoading(void)
{
dcBL_iniChain();
}
void dcBL_startLoading(void)
{
if (dcBL_step==0 || dcBL_step>17)
{
//dcBL_iniChain();
dcBL_step=1;
//epi_clrRawReceivedString();
qDebug()<<"DCBL start sending hexfile...";
dcBL_writeText("DCBL start sending hexfile...");
dcBL_BlkCtr=0;
dcBL_cyclCtr=0;
}
}
uint8_t dcBL_sendHexfile(void)
{
QString tmpStr="";
uint8_t buf[70], sendBuf[160], len, sendLen, gotResp; //, recLen; recBuff[160], ii,
QString stemp=" ";
uint32_t ultmp;
uint8_t uit8tmp, ii;
gotResp=dcBL_ChkResponse();
switch (dcBL_step)
{
case 1: // send start address
if (dcBL_BlkCtr==0 || dcBL_BlkCtr==1024 || dcBL_BlkCtr==2048 || dcBL_BlkCtr==3072 || dcBL_BlkCtr==4096)
{
ultmp=uint32_t(dcBL_BlkCtr);
ultmp*=64;
len=dcBL_sendFlashStartAddr2BL(ultmp, buf);
sendWRcmd_setSendBlock160(len, buf);
qDebug()<<" DCBL_CYCL_sending HexFile address ";
dcBL_writeText("sending addr");
dcBL_step++;
return 0;
} else
dcBL_step=12;
break;
case 2: // wait for answer 2 161 68 59 3
if (gotResp==ISOK)
{
dcBL_step=12; // Header nicht senden, unnötig
dcBL_BlkCtr=0; // 0
repeatCtr=0;
return 0;
} else
if (gotResp==ISWRONG)
{
if (++repeatCtr<3)
{
dcBL_step--;
} else
{
dcBL_step=0; // stop chain
qDebug()<<" DCBL_CYCL_got wrong resp to addr";
dcBL_writeText("wrong resp");
}
}
if (++dcBL_cyclCtr>100)
{
dcBL_writeText("cancel");
qDebug()<<" DCBL_CYCL_step 2 got NO resp to addr";
dcBL_step=0; // stop chain
}
break;
case 12: // send binary 64 byte wise
len=dcBL_getFileBlock(dcBL_BlkCtr, buf); // read from file, len = 0...64
//lastBlkLength=len; // recognize last block or end
sendLen=dcBL_prepareDC_BLcmd(0x22, len, buf, sendBuf); // pack into protocol frame
// Kontrolle:
qDebug()<<"dcBL sending: ";
ii=0;
do
{
uit8tmp=(uint8_t)sendBuf[ii++];
//qDebug() << uit8tmp << " "; // Anzeige in dez
stemp.setNum(uit8tmp,16);
qDebug() << stemp << " "; // Anzeige in hex
} while (ii<100);
sendWRcmd_setSendBlock160(sendLen, sendBuf); // send 140 bytes
delay(100);
dcBL_writeText("blk nr: ");
tmpStr.setNum(dcBL_BlkCtr);
dcBL_writeText(tmpStr);
delay(100);
qDebug()<<"DCBL sending blk nr: " << dcBL_BlkCtr;
dcBL_cyclCtr=0;
dcBL_BlkCtr++;
dcBL_step++;
break;
case 13: // wait for answer 2 162 116 88 3
if (gotResp==ISOK)
{
// check if next address is needed (every 1024Blocks = 65536bytes)
if (dcBL_BlkCtr==1024 || dcBL_BlkCtr==2048 || dcBL_BlkCtr==3072 || dcBL_BlkCtr==4096)
{
dcBL_step=8;
return 0;
}
// check for EOF:
if (dcBL_BlkCtr >= dcBL_nrOfBlocks)
{
dcBL_writeText("last block successful sent...");
dcBL_step++; // stop chain
dcBL_state=3; // transmission SUCCESSFUL
return 0;
}
dcBL_state=2; // transmission started
dcBL_step--; // send next data block
repeatCtr=0;
return 0;
}
if (gotResp==ISWRONG)
{
if (++repeatCtr<3)
{
dcBL_writeText("error");
dcBL_BlkCtr--;
dcBL_step--; // send same block again
} else
{
dcBL_step=0; // stop chain
}
}
if (++dcBL_cyclCtr>30) // longer TO due to flashing
{
dcBL_writeText("cancel");
dcBL_step=0; // stop chain
}
break;
case 14: //
dcBL_writeText("finish writing flash");
len=dcBL_writeLastPage(buf); // nur zur Sicherheit
sendWRcmd_setSendBlock160(len, buf);
dcBL_step++;
break;
case 15: // wait for answer
if (gotResp==ISOK)
{
dcBL_step++;
repeatCtr=0;
return 0;
} else
if (gotResp==ISWRONG)
{
if (++repeatCtr>3)
{
dcBL_step--;
}
}
if (++dcBL_cyclCtr>10)
{
dcBL_writeText("cancel");
dcBL_step=0; // stop chain
}
break;
}
return 0;
}
uint8_t dcBL_getResult(void)
{
// call after every step to what's going on....
@ -1190,6 +1375,9 @@ uint8_t dcBL_getResult(void)
return dcBL_state;
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
static uint8_t Sdata_rawData[RAW_BL_DATALEN];
@ -1204,6 +1392,8 @@ void gpi_storeRawReceivedData(uint8_t RdDlen, uint8_t *receivedData)
Sdata_LengthRawData=RAW_BL_DATALEN;
for (nn=0; nn<Sdata_LengthRawData; nn++)
Sdata_rawData[nn]=receivedData[nn];
qDebug()<<"dcBL got data"<< Sdata_LengthRawData << "bytes :)";
}
uint8_t epi_getRawReceivedData(uint8_t *receivedData)
@ -1230,8 +1420,8 @@ QString epi_getRawReceivedString()
QString myString=nullptr, tmpStr=nullptr;
myString.clear();
//if (Sdata_LengthRawData==0)
// return myString;
if (Sdata_LengthRawData==0)
return myString;
for (nn=0; nn<Sdata_LengthRawData; nn++)
{

View File

@ -17,7 +17,7 @@
#include "storeINdata.h"
#include "dcBL.h"
#include <QDebug>
#include "interfaces.h"
#include <../plugins/interfaces.h>
@ -458,28 +458,23 @@ uint8_t hwapi::lock_switchLowerLock(uint8_t dir) const
void hwapi::lock_switchVaultDoor(void) const
{
//qDebug() << "HWapi: send cmd open vault";
sendWRcmd_setSendCommand0(SENDDIR_OPENVAULT);
}
void hwapi::coin_switchRejectMotor(uint8_t dir) const
{
//qDebug() << "HWapi: send cmd open vault";
sendWRcmd_setSendCommand4(SENDDIR_REJMOT_ON, dir, 0,0,0);
}
void hwapi::coin_rejectCoins(void) const
{
//qDebug() << "HWapi: send cmd open vault";
sendWRcmd_setSendCommand0(SENDDIR_REJMOT_RUN);
}
void hwapi::led_switchLedIllumination(uint8_t on) const
{
sendWRcmd_setSendCommand4(SENDDIRCMD_LEDILLU, on, 0, 0, 0);
}
void hwapi::led_switchLedService(uint8_t on) const
{
sendWRcmd_setSendCommand4(SENDDIRCMD_LEDINSIDE, on, 0, 0, 0);
@ -511,7 +506,7 @@ void hwapi::fan_switchFan(bool on) const
sendWRcmd_setSendCommand4(SENDDIRCMD_FAN, on, 0, 0, 0);
}
void hwapi::laerm_switchSiren(bool on) const
void hwapi::alarm_switchSiren(bool on) const
{
//return epi_storeDOsToSend(DOBYTE4, LAERM, on);
sendWRcmd_setSendCommand4(SENDDIRCMD_LAERM, on, 0, 0, 0);
@ -844,7 +839,11 @@ bool hwapi::door_isContactPowerOn(void) const
bool hwapi::mif_isMifarePowerOn(void) const
{
return epi_getDI_mifarePwr();
bool mo=indat_isMifareOn();
bool mi=epi_getDI_mifarePwr();
if (mo && mi)
return true;
return false;
}
bool hwapi::mdb_testIsmdbTxDon(void) const
@ -893,9 +892,11 @@ bool hwapi::cash_getRejectMotorHomePos(void) const
return epi_getDI_rejectMotor_homepos();
}
bool hwapi::cash_getLowPaperSensor(void) const
uint8_t hwapi::cash_getLowPaperSensor(void) const
{
// 0: Sensor sees paper 1: no paper 99: off
return epi_getDI_npe_sensor();
}
// ------------------------------------------------------------------------------
@ -972,24 +973,39 @@ void hwapi::request_PrinterStateComplete() const
sendWRcmd_setSendCommand0(SEND_REQU_PRN_ALL);
}
void hwapi::request_MifareReaderState() const
{
sendWRcmd_setSendCommand0(SEND_REQU_MIFREADER);
sendWRcmd_setSendCommand0(SEND_REQU_MIFSTATE);
}
void hwapi::request_MifareCardType() const
{
sendWRcmd_setSendCommand0(SEND_REQU_MIFCARD);
//uint8_t blkAdr=0;
//sendWRcmd_setSendCommand4(SEND_REQU_MIFDATA, blkAdr,0,0,0);
sendWRcmd_setSendCommand0(SEND_REQU_MIFSTATE);
}
void hwapi::request_MifareAtbType() const
{
sendWRcmd_setSendCommand0(SEND_REQU_MIF_ATB_TYPE);
//sendWRcmd_setSendCommand0(SEND_REQU_MIF_ATB_TYPE);
sendWRcmd_setSendCommand0(SEND_REQU_MIFSTATE);
}
void hwapi::request_MifareData() const
void hwapi::request_MifareID() const
{
//sendWRcmd_setSendCommand0(SEND_REQU_MIF_DATA);
uint8_t sequenceNumber=0;
sendWRcmd_setSendCommand4(SEND_REQU_MIFDATA, sequenceNumber,0,0,0); // 1st data = card sequence =blk nr (0...15)
}
void hwapi::request_MifareData(uint8_t dataBlockNumber) const
{
if (dataBlockNumber<12) // 1k cards return 12 data blocks, 4k cards would return 54 data blocks (not implemented)
sendWRcmd_setSendCommand4(SEND_REQU_MIFDATA, dataBlockNumber,0,0,0); // 1st data = card sequence =blk nr (0...15)
}
@ -1279,11 +1295,11 @@ uint8_t hwapi::lock_openLowerDoor(void) const
return 0;
}
//uint8_t hwapi::lock_closeLowerDoor(void) const
//{
// sendWRcmd_setSendCommand4(SENDDIRCMD_OPENDN_DOOR, 2, 0, 0, 0);
// return 0;
//}
uint8_t hwapi::lock_closeLowerDoor(void) const
{
sendWRcmd_setSendCommand4(SENDDIRCMD_OPENDN_DOOR, 2, 0, 0, 0);
return 0;
}
void hwapi::shut_openOnce(void) const
{
@ -1342,10 +1358,28 @@ uint8_t hwapi::mif_returnReaderStateAndCardType(uint8_t *buf, uint8_t maxBufferS
{
// retval 0=OK 1=error host buffer too small
/* data description:
new fast version:
byte 0= still the same: current read state:
0=power off 1=reader-fault 2=ready
3=just reading 4=read complete
5=read partial, removed too early
6=state unknown
byte 1: reader state 1=ok 0=nok
byte 2: card present (0,1)
byte 3: card selected (0)
byte 4: card type: 0...5
byte 5: card allowed (0=no 1=MifareClassic 1k or 4k)
byte 6: CardSize: 1 or 4 (kB)
byte 7: length of UID 4 or 7 (byte)
*/
return epi_restoreMifState(buf, maxBufferSize);
}
/* data description:
/* OLD data description:
byte 0: current read state: 0=power off 1=reader-fault 2=ready
3=just reading 4=read complete
5=read partial, removed too early
@ -1368,9 +1402,9 @@ byte 32: result, always 0
bool hwapi::mif_readerIsOK(void) const
{
uint8_t buf[40];
uint8_t buf[40]; // old version had 40 bytes, new version only 8
uint8_t ret= epi_restoreMifState(buf, 40);
if (ret==0 && buf[0]>1 && buf[3]>0)
if (ret==0 && buf[0]>1 && buf[1]>0)
return 1;
return 0; // error
}
@ -1380,7 +1414,7 @@ bool hwapi::mif_cardAttached(void) const
uint8_t buf[40];
uint8_t ret= epi_restoreMifState(buf, 40);
if (ret==0 && buf[0]>1 && buf[3]>0) // reader OK
if (ret==0 && buf[0]>1 && buf[2]>0) // reader OK
if (buf[16]>0)
return 1;
return 0; // error
@ -1395,7 +1429,7 @@ uint8_t hwapi::mif_readResult(void) const
uint8_t buf[40];
uint8_t ret= epi_restoreMifState(buf, 40);
// data read successful && Reader OK && card attached && ...
if (ret==0 && buf[3]>0 && buf[16]>0)
if (ret==0 && buf[1]>0 && buf[2]>0)
{
// byte 0: current read state: 0=power off 1=reader-fault 2=ready
// 3=just reading 4=read complete
@ -1417,10 +1451,11 @@ QString hwapi::mif_cardUID(void) const
{
QString myStr;
uint8_t buf[40];
uint8_t ret= epi_restoreMifState(buf, 40);
myStr.clear();
uint8_t buf[65], ret;
//uint8_t ret= epi_restoreMifState(buf, 40);
myStr.clear();
/*
if (ret==0 && buf[0]==4 && buf[3]>0 && buf[16]>0 && buf[19]>0)
{
// UID in buf[22...29]
@ -1431,7 +1466,26 @@ QString hwapi::mif_cardUID(void) const
myStr+=" "; // make a gap between numbers
}
}
return myStr;
*/
ret=epi_restoreMifData(0, buf, 64);
if (ret)
return myStr; // return empty string on error
else
{
buf[8]=0;
//myStr.append(buf);
for (int ii=0;ii<8; ii++)
{
myStr+=QString::number(buf[ii],16); // 16: return in hex format
myStr+=" "; // make a gap between numbers
}
return myStr;
}
}
@ -2494,7 +2548,178 @@ uint8_t hwapi::bl_exitBL(uint8_t *sendData) const
return dcBL_exitBL(sendData);
}
void hwapi::led_switchLedIllumination(uint8_t on) const
{
if (on)
{
}
}
// neu, 25.3.23
void hwapi::bl_rebootDC(void) const
{
uint8_t len, buf[20];
len=dcBL_restartDC(buf);
sendWRcmd_setSendBlock160(len, buf);
}
void hwapi::bl_startBL(void) const
{
uint8_t len, buf[20];
len=dcBL_activatBootloader(buf);
sendWRcmd_setSendBlock160(len, buf);
}
void hwapi::bl_checkBL(void) const
{
uint8_t len, buf[20];
//len=dcBL_readBLversion(buf);
len=dcBL_readFWversion(buf);
sendWRcmd_setSendBlock160(len, buf);
}
bool hwapi::bl_isUp(void) const
{
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);
//epi_clrRawReceivedString();
//qDebug() << " *** got " << LL << " data bytes from BL: " <<
// receivedData[0] << " " << receivedData[1] << " " << receivedData[2] << " " <<
// receivedData[3] << " " << receivedData[4] << " " << receivedData[5] << " ";
// response to "readFWversion"
if (receivedData[0]==2 && receivedData[1]==146 && receivedData[2]==45 &&
receivedData[3]==45 && receivedData[4] ==95 && receivedData[5]==176)
{
dcBL_iniLoading();
return true;
}
// response to "start BL"
if (receivedData[0]==2 && receivedData[1]==101 && receivedData[2]==48 &&
receivedData[3]==223 && receivedData[4] ==131 )
{
dcBL_iniLoading();
return true;
}
}
return false;
}
void hwapi::bl_sendAddress(u_int16_t blockNumber) const
{
// send start address, nr of 64byte-block, start with 0
// will be sent only for folling block-numbers:
// 0, 1024, 2048, 3072 and 4096, so basically every 64kByte
uint32_t dcBL_BlkCtr=(uint32_t)blockNumber;
uint8_t len, buf[20];
tslib_strclr(buf, 0, 20);
if (dcBL_BlkCtr==0 || dcBL_BlkCtr==1024 || dcBL_BlkCtr==2048 || dcBL_BlkCtr==3072 || dcBL_BlkCtr==4096)
{
dcBL_BlkCtr*=64;
len=dcBL_sendFlashStartAddr2BL(dcBL_BlkCtr, buf); // make command string
// uint8_t dcBL_sendFlashStartAddr2BL(uint32_t startAddr, uint8_t *sendData)
// minimum size of sendData-buffer: 13byte retval: length (9...13)
sendWRcmd_setSendBlock160(len, buf); // send command to BL
}
}
uint8_t hwapi::bl_wasSendingAddOK(void) const
{
// return val: 0: no response by now 1:error 10: OK
return dcBL_sendSuccess(0x21);
// return val: 0: no response by now 1:error 10: OK
// lastCommand=0x21 for sendAddr or 0x22 for send data
}
void hwapi::bl_sendDataBlock(uint8_t length, u_int8_t *buffer) const
{
// send 64 byte from bin file
uint8_t LL=length, sendBuf[66], sendLen;
if (LL>64) LL=64;
sendLen=dcBL_prepareDC_BLcmd(0x22, LL, buffer, sendBuf); // pack into protocol frame
sendWRcmd_setSendBlock160(sendLen, sendBuf); // send 140 bytes
delay(100);
}
void hwapi::bl_sendLastBlock(void) const
{
uint8_t len, buf[20];
len=dcBL_writeLastPage(buf);
sendWRcmd_setSendBlock160(len, buf);
}
uint8_t hwapi::bl_wasSendingDataOK(void) const
{
// return val: 0: no response by now 1:error 10: OK
return dcBL_sendSuccess(0x22);
// return val: 0: no response by now 1:error 10: OK
// lastCommand=0x21 for sendAddr or 0x22 for send data
}
void hwapi::bl_stopBL(void) const
{
uint8_t len, buf[20];
len=dcBL_exitBL(buf);
sendWRcmd_setSendBlock160(len, buf);
}
bool hwapi::bl_isDiagAvailable(void) const
{
return dcBL_checkForText();
}
QString hwapi::dc_getDiagText(void) const
{
return dcBL_readText(); // read from 0...9 (oldest first)
}
// geht noch nicht //////
void hwapi::bl_startSending(void) const
{
dcBL_startLoading();
}
void hwapi::bl_sendFile(void) const
{
//qDebug()<<" HWAPI_BL_CYCL_ISrunning ";
dcBL_sendHexfile();
}

View File

@ -9,9 +9,33 @@ T_prot::T_prot()
mySerialPort = new T_com();
connect(mySerialPort, SIGNAL(receivingFinished()), this, SLOT( analyseRecData() ));
//connect(mySerialPort, SIGNAL(receivingFinished()), this, SLOT( receivFin() ));
//connect(mySerialPort, SIGNAL(sendingFinished()), this, SLOT(sendeFin()));
kindOfData=0; // 0: binaries, 1:text
for (int nn=0; nn<FRAME_DATALEN; nn++)
{
chOut_Data[nn]=0;
ui8OutputData[nn]=0;
InputData[nn]=0;
}
for (int nn=0; nn<BL_DATA_LEN; nn++)
{
ui8BLsendData[nn]=0;
}
WriteCommand=0;
WriteAddr=0;
WrDataLength=0;
SendDataValid=0;
kindOfData=0;
slaveAddr=0;
ReadCommand=0;
ReadAddr=0;
reserve =0;
RecSlaveAddr =0;
INdataValid=0;
readSource =0;
readAddress=0;
RdDataLength=0;
BLsendDataLength=0;
}
@ -30,6 +54,19 @@ bool T_prot::isSerialFree(void)
return true; // ohne HS's kann er nicht blockiert sein
}
void T_prot::setRecLen(uint16_t WriteCmd)
{
if (WriteCmd<100)
{
RdDataLength=DATALEN_RECEIVE_LONG; // store here already because it's no longer
// returned from slave
mySerialPort->receiveFixLen(TELEGRAMLEN_RECEIVE_LONG);
} else
{
RdDataLength=DATALEN_RECEIVE_FAST;
mySerialPort->receiveFixLen(TELEGRAMLEN_RECEIVE_FAST);
}
}
void T_prot::setUserWriteData(uint16_t WriteCmd, uint16_t WrAddr, uint8_t WrDatLen, uint8_t *data)
{
@ -43,6 +80,8 @@ void T_prot::setUserWriteData(uint16_t WriteCmd, uint16_t WrAddr, uint8_t WrDat
ui8OutputData[nn]=data[nn];
SendDataValid=1; // always set WR first
kindOfData=0; // 0: binaries, 1:text
this->setRecLen(WriteCmd);
}
void T_prot::setUserWriteData(uint16_t WriteCmd, uint16_t WrAddr)
@ -54,6 +93,8 @@ void T_prot::setUserWriteData(uint16_t WriteCmd, uint16_t WrAddr)
ui8OutputData[nn]=0;
SendDataValid=1; // always set WR first
kindOfData=0; // 0: binaries, 1:text
this->setRecLen(WriteCmd);
}
void T_prot::setUserWriteData(uint16_t WriteCmd)
@ -65,6 +106,8 @@ void T_prot::setUserWriteData(uint16_t WriteCmd)
ui8OutputData[nn]=0;
SendDataValid=1; // always set WR first
kindOfData=0; // 0: binaries, 1:text
this->setRecLen(WriteCmd);
}
void T_prot::setUserWrite1DB(uint16_t WriteCmd, uint16_t WrAddr, uint8_t val)
@ -76,6 +119,8 @@ void T_prot::setUserWrite1DB(uint16_t WriteCmd, uint16_t WrAddr, uint8_t val)
ui8OutputData[0]=val;
SendDataValid=1; // always set WR first
kindOfData=0; // 0: binaries, 1:text
this->setRecLen(WriteCmd);
}
void T_prot::setUserWrite2DB(uint16_t WriteCmd, uint16_t WrAddr, uint8_t val0, uint8_t val1)
@ -87,6 +132,8 @@ void T_prot::setUserWrite2DB(uint16_t WriteCmd, uint16_t WrAddr, uint8_t val0, u
ui8OutputData[1]=val1;
SendDataValid=1; // always set WR first
kindOfData=0; // 0: binaries, 1:text
this->setRecLen(WriteCmd);
}
void T_prot::setUserWriteText(uint16_t WriteCmd, uint16_t WrAddr, uint8_t WrDatLen, char *data)
@ -101,6 +148,8 @@ void T_prot::setUserWriteText(uint16_t WriteCmd, uint16_t WrAddr, uint8_t WrDat
chOut_Data[nn]=data[nn];
SendDataValid=1; // always set WR first
kindOfData=1; // 0: binaries, 1:text
this->setRecLen(WriteCmd);
}
void T_prot::setUserReadData( uint16_t ReadCmd, uint16_t RdAddr, uint16_t reserv)
@ -109,6 +158,8 @@ void T_prot::setUserReadData( uint16_t ReadCmd, uint16_t RdAddr, uint16_t reser
ReadAddr=RdAddr;
reserve=reserv;
SendDataValid |=2;
readAddress=RdAddr; // store here already because it's no longer returned from slave
readSource=ReadCmd;
}
void T_prot::setUserReadData( uint16_t ReadCmd, uint16_t RdAddr)
@ -117,6 +168,8 @@ void T_prot::setUserReadData( uint16_t ReadCmd, uint16_t RdAddr)
ReadAddr=RdAddr;
reserve=0;
SendDataValid |=2;
readAddress=RdAddr; // store here already because it's no longer returned from slave
readSource=ReadCmd;
}
void T_prot::setUserReadData( uint16_t ReadCmd)
@ -125,6 +178,8 @@ void T_prot::setUserReadData( uint16_t ReadCmd)
ReadAddr=0;
reserve=0;
SendDataValid |=2;
readAddress=0; // store here already because it's no longer returned from slave
readSource=ReadCmd;
}
void T_prot::setBLsendData( uint8_t len, uint8_t *buf)
@ -137,8 +192,13 @@ void T_prot::setBLsendData( uint8_t len, uint8_t *buf)
for (int nn=0; nn<BLsendDataLength; nn++)
ui8BLsendData[nn]=buf[nn];
WriteCommand=0xFFFF;
this->setRecLen(100); // how many??
//readAddress= // needed??
qDebug()<<"prot: got BL data " << len << "bytes, ";
for (int i=0; i<len; ++i) {
printf("%02x ", (unsigned char)buf[i]);
} printf("\n");
/*
qDebug()<<buf[0] <<buf[1] <<buf[2] <<buf[3] <<buf[4] <<buf[5] <<buf[6] <<buf[7];
qDebug() <<buf[8] <<buf[9] <<buf[10] <<buf[11] <<buf[12] <<buf[13]<<buf[14]<<buf[15];
@ -153,6 +213,11 @@ qDebug() <<buf[72] <<buf[73] <<buf[74] <<buf[75] <<buf[76] <<buf[77] <<buf[78]<<
*/
}
void T_prot::receiveFixLen(int64_t nrOfbytesToReceive)
{
mySerialPort->receiveFixLen(nrOfbytesToReceive);
}
void T_prot::sendUserData(uint16_t slaveAdr)
{
// man könnte hier noch "SendDataValid" abfragen,
@ -167,14 +232,90 @@ void T_prot::sendUserData(uint16_t slaveAdr)
// Bypass for bootloader, no protocol frame but send as is...
packBuf_2.clear();
for (int nn=0; nn<BLsendDataLength; nn++)
packBuf_2[nn]=char(ui8BLsendData[nn]);
packBuf_2[nn]=char(ui8BLsendData[nn]);
mySerialPort->writeToSerial(packBuf_2, BLsendDataLength);
} else
startPacking();
startFastPacking(); // quicker since 15.12.21TS
//startPacking();
}
void T_prot::startFastPacking(void)
{
uint16_t mycrc;
uint16_t sendLen;
uint8_t uctmp, nn, pp, CrcLp;
char sendBuffer[FRAME_MAXLEN], ctmp;
//qDebug() << "prot start fast packing "<<slaveAddr;
for (int nn=0; nn<FRAME_MAXLEN; nn++)
sendBuffer[nn]=0;
if (WriteCommand>9 && WriteCommand<100)
{
// long command 10...99
// WriteCommand==0 if only read request, then use short sending
sendBuffer[0]=STARTSIGN_SEND_LONG;
WrDataLength=DATALEN_SEND_LONG; // immer
//qDebug() << "send long cmd, len: " << WrDataLength;
} else
{
// fast command
sendBuffer[0]=STARTSIGN_SEND_FAST;
WrDataLength=DATALEN_SEND_FAST; // immer
//qDebug() << "send fast cmd, len: " << WrDataLength;
}
sendBuffer[1]= uint8_t(WriteCommand);
sendBuffer[2]= uint8_t(ReadCommand);
if (WriteAddr>0)
sendBuffer[3]= char(WriteAddr); // bei fast nur EINE adresse, wr hat Vorrang
else
sendBuffer[3]= char(ReadAddr);
// beim Fast prot. ist das reserve dann ists egal was drin steht
if (kindOfData) // 0: binaries, 1:text
{
for (nn=0; nn<WrDataLength; nn++)
{
pp=HEADERLEN_SEND+nn;
ctmp=(chOut_Data[nn]); // text
sendBuffer[pp]= char(ctmp);
}
} else
{
for (nn=0; nn<WrDataLength; nn++)
{
pp=HEADERLEN_SEND+nn;
uctmp=(ui8OutputData[nn]); // bin
sendBuffer[pp]= char(uctmp);
}
}
CrcLp= HEADERLEN_SEND + WrDataLength;
mycrc=0;
for (nn=0; nn<CrcLp; nn++)
{
uctmp=sendBuffer[nn];
mycrc+=uint16_t(uctmp);
//qDebug() << mycrc;
}
sendBuffer[CrcLp]=char(mycrc);
mycrc>>=8;
sendBuffer[CrcLp+1]=char(mycrc);
sendLen=CrcLp+2;
// send to VCP:
QByteArray packBuff;
packBuff.clear();
packBuff.append(sendBuffer, sendLen); // ohne sendLen wird beim ersten \0 abgeschnitten!!!
mySerialPort->writeToSerial(packBuff, sendLen);
}
/*
void T_prot::startPacking(void)
{
uint16_t mycrc;
@ -262,10 +403,8 @@ void T_prot::startPacking(void)
packBuff.append(sendBuffer, sendLen); // ohne sendLen wird beim ersten \0 abgeschnitten!!!
mySerialPort->writeToSerial(packBuff, sendLen);
// void T_com::writeToSerial(const QByteArray &data, uint16_t sendLength)
}
*/
// ---------------------------------------------------------------------------------------------------------
// receiving.....
@ -293,7 +432,7 @@ uint8_t recBuffer[FRAME_MAXLEN];
// read from "VCP":
mySerialPort->readFromSerial(Indata, recLength);
qDebug()<<"prot: got data " << recLength;
if (recLength>FRAME_MAXLEN)
recLength=FRAME_MAXLEN;
for (int nn=0; nn<recLength; nn++)
@ -301,10 +440,11 @@ uint8_t recBuffer[FRAME_MAXLEN];
myString.clear();
tempStr.clear();
uint8_t result=FramecheckInData(recBuffer, recLength); // check input data (response from slave)
//uint8_t result=FramecheckInData(recBuffer, recLength); // check input data (response from slave)
uint8_t result=FastCheckInData(recBuffer, recLength); // check input data (response from slave)
if (result>0)
{
// dann anzeigen und ende
// dann anzeige
switch (result)
{
case 1: gpi_setTxt4masterStateLine("wrong length received"); break;
@ -316,6 +456,7 @@ uint8_t recBuffer[FRAME_MAXLEN];
}
myString.setNum(result);
// Daten abspeichern, könnten vom BL sein:
gpi_storeRawReceivedData(uint8_t(recLength), recBuffer);
emit rawDataRecieved();
@ -328,16 +469,59 @@ uint8_t recBuffer[FRAME_MAXLEN];
// konnte der Slave die geforderten Daten ausgeben (DOs, AOs)?
// konnte der Slave die geforderten Daten einlesen (AIs, DIs)?
CheckInResult(recBuffer); // Ergebnisse des Slaves anzeigen
//CheckInResult(recBuffer); // Ergebnisse des Slaves anzeigen
// stimmt nicht mehr bei FastProt
CheckInData(recBuffer); // Eingangs-Daten des Slaves anzeigen
ShowFastInData(recBuffer); // Eingangs-Daten des Slaves anzeigen
}
emit framerecieved();
//qDebug() << "framereceived emitted";
}
uint8_t T_prot::FastCheckInData(uint8_t *Inbuf, uint16_t LL)
{
uint16_t rawInLen=LL, crcL_Addr, recCrc, myCrc, nn, datalen, nxt;
if (Inbuf[0]!=STARTSIGN_RECEIVE_FAST && Inbuf[0]!=STARTSIGN_RECEIVE_LONG)
{
//qDebug() << "prot: got wrong start sign: " << Inbuf[0];
return 2; // wrong start sign
}
if ( (rawInLen<TELEGRAMLEN_RECEIVE_FAST && Inbuf[0]==STARTSIGN_RECEIVE_FAST) ||
(rawInLen<TELEGRAMLEN_RECEIVE_LONG && Inbuf[0]==STARTSIGN_RECEIVE_LONG) )
{
//qDebug("prot: got %d bytes only", rawInLen);
return 1; // wrong length
}
if (Inbuf[0]==0x5F)
datalen=DATALEN_RECEIVE_FAST;
else
datalen=DATALEN_RECEIVE_LONG;
crcL_Addr=datalen+HEADERLEN_RECEIVE; // weil im definierten protocol 2 bytes vor den Daten stehen
recCrc=0;
recCrc=uchar2uint(uint8_t(Inbuf[crcL_Addr+1]), uint8_t(Inbuf[crcL_Addr]));
myCrc=0;
for (nn=0; nn<crcL_Addr; nn++)
{
nxt=uint16_t (Inbuf[nn]);
nxt &=0x00FF; // the casting makes 0xFFFF out of 0xFF !!!!!!!!!
myCrc+=nxt;
//qDebug("CRC: nxt: %d sum: %d", nxt, myCrc);
}
if (myCrc != recCrc)
{
//qDebug() << "crc does not match: mycrc=" << myCrc<< " receivedCRC=" << recCrc;
//qDebug("calculated over %d bytes", crcL_Addr);
return 5; // crc wrong
}
return 0;
}
/*
uint8_t T_prot::FramecheckInData(uint8_t *Inbuf, uint16_t LL)
{
@ -385,7 +569,7 @@ uint8_t T_prot::FramecheckInData(uint8_t *Inbuf, uint16_t LL)
}
return 0;
}
*/
uint8_t T_prot::CheckInResult(uint8_t *Inbuf)
{
@ -438,24 +622,27 @@ uint8_t T_prot::CheckInResult(uint8_t *Inbuf)
uint8_t T_prot::CheckInData(uint8_t *recBuffer)
uint8_t T_prot::ShowFastInData(uint8_t *recBuffer)
{
QString myString=nullptr, tempStr=nullptr;
uint8_t result;
RecSlaveAddr=recBuffer[1];
if (recBuffer[2]==0 && recBuffer[4]==0) // comand result=OK und read result =OK,
// dann sind die Eingangsdaten gültig
RecSlaveAddr=0;
result=recBuffer[1]; // total result
result &=0x60; // only read result (bit 5,6)
if (result==0) // read result =OK,
// dann sind die Eingangsdaten gültig
{
myString.append("valid INdata: ");
INdataValid=true;
readSource=uchar2uint(recBuffer[6],recBuffer[5]);
readAddress=uchar2uint(recBuffer[8],recBuffer[7]);
//lastWakeSrc=uint8_t(recBuffer[4]);
RdDataLength=uint8_t(recBuffer[9]);
//readSource already set with sending
readAddress=0;
// RdDataLength already set with sending
if (RdDataLength>FRAME_DATALEN)
RdDataLength=FRAME_DATALEN;
for (int ii=0; ii<RdDataLength; ii++)
InputData[ii]=uint8_t(recBuffer[ii+10]);
InputData[ii]=uint8_t(recBuffer[ii+HEADERLEN_RECEIVE]);
tempStr.setNum(readSource,16);
myString.append(tempStr);
@ -486,6 +673,57 @@ uint8_t T_prot::CheckInData(uint8_t *recBuffer)
return 0;
}
/*
uint8_t T_prot::ShowInData(uint8_t *recBuffer)
{
QString myString=nullptr, tempStr=nullptr;
RecSlaveAddr=recBuffer[1];
if (recBuffer[2]==0 && recBuffer[4]==0) // comand result=OK und read result =OK,
// dann sind die Eingangsdaten gültig
{
myString.append("valid INdata: ");
INdataValid=true;
readSource=uchar2uint(recBuffer[6],recBuffer[5]);
readAddress=uchar2uint(recBuffer[8],recBuffer[7]);
//lastWakeSrc=uint8_t(recBuffer[4]);
RdDataLength=uint8_t(recBuffer[9]);
if (RdDataLength>FRAME_DATALEN)
RdDataLength=FRAME_DATALEN;
for (int ii=0; ii<RdDataLength; ii++)
InputData[ii]=uint8_t(recBuffer[ii+10]);
tempStr.setNum(readSource,16);
myString.append(tempStr);
myString.append(" add:");
tempStr.setNum(readAddress);
myString.append(tempStr);
//myString.append(" wakeSrc:");
//tempStr.setNum(lastWakeSrc);
//myString.append(tempStr);
myString.append(" Dlen:");
tempStr.setNum(RdDataLength);
myString.append(tempStr);
} else
{
myString=" "; // Eingangsdaten nicht gültig, sieht man aber weiter oben schon
}
gpi_setTxt4dataStateLine(myString);
//qDebug() << myString;
//qDebug("prot_checkInData_bindata: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d ",
// InputData[0], InputData[1], InputData[2], InputData[3],
// InputData[4], InputData[5], InputData[6], InputData[7],
// InputData[8], InputData[9], InputData[10], InputData[11],
// InputData[12], InputData[13], InputData[14], InputData[15]);
return 0;
}
*/
bool T_prot::ifDataReceived()
{

View File

@ -53,7 +53,7 @@ bool sendWRcmd_setSendCommand0(uint16_t nextCmd)
return false; // not possible
}
nextAsynchsendCmd0[nrOfCmdsInQueue++]=nextCmd;
qDebug() << "PI cmd queued:"<< nextCmd << ", saved, pp=" << nrOfCmdsInQueue;
//qDebug() << "PI cmd queued:"<< nextCmd << ", saved, pp=" << nrOfCmdsInQueue;
return true; // ok, will be sent
}
@ -69,7 +69,7 @@ uint16_t sendWRcmd_getSendCommand0(void)
nextAsynchsendCmd0[nn]=nextAsynchsendCmd0[nn+1];
if (nrOfCmdsInQueue>0)
nrOfCmdsInQueue--;
qDebug() << "PI cmd queued:"<< nxtAsynchCmd << ", restored, pp now =" << nrOfCmdsInQueue;
//qDebug() << "PI cmd queued:"<< nxtAsynchCmd << ", restored, pp now =" << nrOfCmdsInQueue;
return nxtAsynchCmd;
}

View File

@ -99,13 +99,13 @@ QString epi_getSlaveParamSTR()
static QString genStrings[3];
static QString genStrings[MAXNROF_GENSTR];
// 0=HW 1=SW 2=State
void gpi_storeGenerals(uint8_t genNr, QString text)
{
// 0=HW 1=SW 2=State
if (genNr<3)
if (genNr<MAXNROF_GENSTR)
{
genStrings[genNr]=text;
//qDebug() << "store gen's: " << genNr << " " <<text;
@ -116,7 +116,13 @@ void gpi_storeGenerals(uint8_t genNr, QString text)
QString epi_loadGenerals(uint8_t genNr)
{
if (genNr<MAXNROF_GENSTR)
{
if (genNr==2) // DC2 State is shorter (8byte, not 64)
//genStrings[2][8]=0;
genStrings[2].chop(8);
return genStrings[genNr];
}
return " ";
}
@ -132,8 +138,12 @@ void gpi_storeUID(uint8_t *buf8byteUid)
{
uint64_t udltmp=0;
//qDebug()<< "store UID ";
for (int ii=0; ii<8; ii++)
{
//qDebug()<< buf8byteUid[ii] << " ";
Sdata_UIDstr[ii]=buf8byteUid[ii];
udltmp|=buf8byteUid[ii];
udltmp<<=8;
@ -143,8 +153,10 @@ void gpi_storeUID(uint8_t *buf8byteUid)
void epi_getUIDdec(uint8_t *buf8byteUid)
{
//qDebug()<< "get UID ";
for (int ii=0; ii<8; ii++)
{
//qDebug()<<Sdata_UIDstr[ii] << " ";
buf8byteUid[ii]=Sdata_UIDstr[ii];
}
}
@ -156,8 +168,12 @@ QString epi_getUIDstr()
QString myStr;
for (int ii=0;ii<8; ii++)
{
myStr+=QString::number(Sdata_UIDstr[ii],16);
return myStr;
myStr+=" ";
}
return myStr;
}
@ -232,6 +248,7 @@ uint8_t epi_getSquareMode()
void gpi_backupTime(uint8_t *timeBuffer, uint8_t Leng)
{
/*
// Daten kommen in gleicher Reihenfolge vom Slave
uint8_t *pTime;
pTime=&getGlobalTime.hour;
@ -239,7 +256,20 @@ void gpi_backupTime(uint8_t *timeBuffer, uint8_t Leng)
for (int nn=0; nn<Leng; nn++)
{
*pTime++=timeBuffer[nn];
}
}*/
// new, FastProt: 0=dayOfWeek 1=min 2=sec 3=hours 4=year 5=month 6=dayOfMonth
getGlobalTime.second=Leng; // nur damit CompilerWarnung weg ist
getGlobalTime.DayOfWeek=timeBuffer[0];
getGlobalTime.minute=timeBuffer[1];
getGlobalTime.second=timeBuffer[2];
getGlobalTime.hour=timeBuffer[3];
getGlobalTime.Year=timeBuffer[4];
getGlobalTime.Month=timeBuffer[5];
getGlobalTime.DayOfMonth=timeBuffer[6];
}
void epi_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss)
@ -604,6 +634,9 @@ void gpi_storeDI_doorSwitches(uint8_t upperDoor, uint8_t lowerDoor, uint8_t vaul
if (lowerDoor) di_doorSwitch |=2;
if (vaultDoor) di_doorSwitch |=4;
// qDebug()<<"storeINdata: "<<upperDoor << lowerDoor << vaultDoor;
// qDebug()<<"storeINdata: "<<di_doorSwitch;
}
uint8_t epi_getDI_doorSwitches(void)
@ -897,14 +930,15 @@ bool epi_getDI_rejectMotor_homepos(void)
return di_rejMot_home;
}
static bool di_npe_sensor;
static uint8_t di_npe_sensor;
void gpi_storeDI_paperLow(bool di)
void gpi_storeDI_paperLow(uint8_t di)
{
// 0: Sensor sees paper 1: no paper 99: off
di_npe_sensor=di;
}
bool epi_getDI_npe_sensor(void)
uint8_t epi_getDI_npe_sensor(void)
{
return di_npe_sensor;
}
@ -966,8 +1000,8 @@ uint8_t epi_getDO_motorOuts(void)
static uint8_t do_serialSwitch; // serial drv on/off, Serial mux1, Serial mux2
void gpi_storeDO_serialSwitch(uint8_t state)// serial drv on/off, Serial mux1, Serial mux2
static uint8_t do_serialSwitch; // serial drv on/off, Serial mux1, Serial mux2
void gpi_storeDO_serialSwitch(uint8_t state) // serial drv on/off, Serial mux1, Serial mux2
{
do_serialSwitch=state;
}
@ -1026,6 +1060,7 @@ bool epi_getDO_serialMux2isSetToMifare(void)
static uint8_t do_ledsAndFan;
void gpi_storeDO_ledsAndFan(uint8_t ledState)
{
// bit0: coinled 1:front_illu 2: paper-led 3:pinpad-led 4:start-led 5:service-led 6:fan
do_ledsAndFan=ledState;
}
@ -1083,6 +1118,7 @@ bool epi_getDO_fan(void)
static uint8_t do_laermUndRelay;
void gpi_storeDO_sirenAndRelay(uint8_t sirenRelay)
{
// bit0: siren 1:relay
do_laermUndRelay=sirenRelay;
}
@ -1190,11 +1226,31 @@ uint8_t gpi_storeMifReaderStateAndCardType(uint8_t *buf)
{
// retval 0=OK 1=error host buffer too small
for (uint8_t nn=0; nn<NROFMIFSTATEBYTES; nn++)
Sdata_MIF_STATE[nn]=0;
for (uint8_t nn=0; nn<8; nn++)
Sdata_MIF_STATE[nn]=buf[nn];
return 0; // OK
}
/* data description:
new fast version:
byte 0= still the same: current read state:
0=power off 1=reader-fault 2=ready
3=just reading 4=read complete
5=read partial, removed too early
6=state unknown
byte 1: reader state 1=ok 0=nok
byte 2: card preent (0,1)
byte 3: card selected (0)
byte 4: card type: 0...5
byte 5: card allowed (0=no 1=MifareClassic 1k or 4k)
byte 6: CardSize: 1 or 4 (kB)
byte 7: length of UID 4 or 7 (byte)
old long version
byte 0: current read state: 0=power off 1=reader-fault 2=ready
3=just reading 4=read complete
5=read partial, removed too early
@ -1217,10 +1273,10 @@ byte 32: result, always 0
uint8_t epi_restoreMifState(uint8_t *buf, uint8_t maxBufferSize)
{
// HWapi can read States from DC
if (maxBufferSize<NROFMIFSTATEBYTES)
if (maxBufferSize<8)
return 1; // error
for (uint8_t nn=0; nn<NROFMIFSTATEBYTES; nn++)
for (uint8_t nn=0; nn<8; nn++)
buf[nn]=Sdata_MIF_STATE[nn];
return 0; // OK
@ -1425,15 +1481,15 @@ void gpi_storeEmpCoinSignal(uint8_t leng, uint8_t *data)
uint8_t LL=leng; // nr of coin records
uint16_t vv, pp=0;
qDebug()<<"store emp data, len: "<<LL;
//qDebug()<<"store emp data, len: "<<LL;
while (LL>0)
//while (LL>0) // with FastProtocol only one coin
{
vv=uchar2uint(data[pp+4], data[pp+3]);
sub_enterData(data[pp], data[pp+1], data[pp+2], vv );
qDebug()<< "emp IN data: " << data[pp] << " " << data[pp+1]
<< " " <<data[pp+2] <<" " <<data[pp+3] <<" " <<data[pp+4] <<" ";
//qDebug()<< "emp IN data: " << data[pp] << " " << data[pp+1]
// << " " <<data[pp+2] <<" " <<data[pp+3] <<" " <<data[pp+4] <<" ";
pp+=5;
LL--;
@ -1456,12 +1512,12 @@ void epi_restoreEmpCoinSignal(uint8_t *valid, uint8_t *signal, uint8_t *error, u
*error=gotCoin[ctr_gotCoin].error;
*value=gotCoin[ctr_gotCoin].value;
}
/*
qDebug()<<"read emp data, nr "<<ctr_gotCoin << "valid: " << *valid
<< "signal: " << *signal
<< "error: " << *error
<< "value: " << *value;
*/
}