Added additional variables into shared memory.
Cleaned source.
This commit is contained in:
parent
81c610c48b
commit
c99d0730ce
@ -1,19 +1,14 @@
|
||||
#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,
|
||||
@ -38,7 +33,6 @@ 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
|
||||
@ -49,7 +43,6 @@ uint8_t gpi_getSerialConn(void) {
|
||||
return SharedMemBuffer::getDataConst()->rs.connect;
|
||||
}
|
||||
|
||||
|
||||
int gpi_getBaudNr(void) {
|
||||
return SharedMemBuffer::getDataConst()->rs.baudNr;
|
||||
}
|
||||
@ -106,14 +99,12 @@ 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) // gpi
|
||||
{
|
||||
void gpi_setTxt4comStateLine(QString txtline) {
|
||||
// serial: write Text to be displayed in serial Comport-State line (like "connected")
|
||||
txt4comStateLine.clear();
|
||||
if (txtline=="")
|
||||
@ -122,26 +113,20 @@ void gpi_setTxt4comStateLine(QString txtline) // gpi
|
||||
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();
|
||||
@ -149,26 +134,19 @@ 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();
|
||||
@ -176,13 +154,10 @@ 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
|
||||
@ -192,13 +167,11 @@ 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();
|
||||
@ -206,26 +179,22 @@ 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=="")
|
||||
@ -234,8 +203,7 @@ void gpi_setTxt4dataStateLine(QString txtline)
|
||||
txt4dataLine=txtline;
|
||||
}
|
||||
|
||||
void epi_clrTxt4dataStateLine()
|
||||
{
|
||||
void epi_clrTxt4dataStateLine() {
|
||||
txt4dataLine.clear();
|
||||
}
|
||||
|
||||
@ -245,16 +213,11 @@ 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();
|
||||
@ -262,8 +225,7 @@ void gpi_setTxt4datifLine(QString txtline)
|
||||
txt4datifReceive=txtline;
|
||||
}
|
||||
|
||||
void epi_clrTxt4datifLine()
|
||||
{
|
||||
void epi_clrTxt4datifLine() {
|
||||
txt4datifReceive.clear();
|
||||
}
|
||||
|
||||
@ -272,14 +234,11 @@ 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();
|
||||
@ -287,8 +246,7 @@ void gpi_setTxt4RsDiagWin(QString txtline)
|
||||
txt4diagWindow=txtline;
|
||||
}
|
||||
|
||||
void epi_clrTxt4RsDiagWin()
|
||||
{
|
||||
void epi_clrTxt4RsDiagWin() {
|
||||
txt4diagWindow.clear();
|
||||
}
|
||||
|
||||
@ -296,14 +254,11 @@ 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();
|
||||
@ -311,90 +266,61 @@ void gpi_set2ndTxt4RsDiagWin(QString txtline)
|
||||
sndTxt4diagWindow=txtline;
|
||||
}
|
||||
|
||||
void epi_clr2ndTxt4RsDiagWin()
|
||||
{
|
||||
void epi_clr2ndTxt4RsDiagWin() {
|
||||
sndTxt4diagWindow.clear();
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////
|
||||
// Memory for Slave responses, common data
|
||||
// ///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
static bool Sdata_serialTestResult;
|
||||
|
||||
void gpi_storeResult_serialTestOK(bool wasOk)
|
||||
{
|
||||
Sdata_serialTestResult=wasOk;
|
||||
void gpi_storeResult_serialTestOK(bool wasOk) {
|
||||
SharedMemBuffer::getData()->Sdata.serialTestResult = wasOk;
|
||||
}
|
||||
|
||||
bool epi_getResult_serialTestOK()
|
||||
{
|
||||
bool epi_getResult_serialTestOK() {
|
||||
// retval: true: test was successful, got right response
|
||||
return Sdata_serialTestResult;
|
||||
return SharedMemBuffer::getDataConst()->Sdata.serialTestResult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////
|
||||
// Store received data for hwapi
|
||||
// ///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
static uint8_t Sdata_pProtResultOk;
|
||||
|
||||
void gpi_startNewRequest()
|
||||
{
|
||||
Sdata_pProtResultOk=0;
|
||||
void gpi_startNewRequest() {
|
||||
SharedMemBuffer::getData()->Sdata.pProtResultOk = 0;
|
||||
}
|
||||
|
||||
void gpi_storeResultOfLastRequest(bool answisok)
|
||||
{
|
||||
if (answisok)
|
||||
Sdata_pProtResultOk=1;
|
||||
else
|
||||
Sdata_pProtResultOk=2;
|
||||
void gpi_storeResultOfLastRequest(bool answisok) {
|
||||
SharedMemBuffer::getData()->Sdata.pProtResultOk = answisok ? 1 : 2;
|
||||
}
|
||||
|
||||
uint8_t epi_getResultOfLastRequest()
|
||||
{
|
||||
uint8_t epi_getResultOfLastRequest() {
|
||||
// retval: 0: in progress 1: OK 2: error
|
||||
return Sdata_pProtResultOk;
|
||||
return SharedMemBuffer::getDataConst()->Sdata.pProtResultOk;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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=plBufSiz;
|
||||
if (ml>64) ml=64;
|
||||
if (Sdata_receivedDataLength<ml)
|
||||
ml=Sdata_receivedDataLength;
|
||||
tslib_strcpy(Sdata_receivedDataBlock, payLoad, ml);
|
||||
return Sdata_receivedDataLength;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user